diff options
author | Josh Durgin <josh.durgin@dreamhost.com> | 2011-10-18 16:50:08 -0700 |
---|---|---|
committer | Josh Durgin <josh.durgin@dreamhost.com> | 2011-10-24 15:32:47 -0700 |
commit | 4b10cad88e8895ac4dbefe77ada73d6acad8c84c (patch) | |
tree | 07b6ae4d57e41a81854d16a178d10036739b68f2 /src/rbd.cc | |
parent | df2967a602baaffd62c6fffecf16d8698181b9f1 (diff) | |
download | ceph-4b10cad88e8895ac4dbefe77ada73d6acad8c84c.tar.gz |
rbd: check command before opening the image
Now map/unmap won't use librbd, and commands that don't take --snap
will give an error when it's used.
Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
Diffstat (limited to 'src/rbd.cc')
-rw-r--r-- | src/rbd.cc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/rbd.cc b/src/rbd.cc index ca8a055f594..cdd8bbccf0e 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -1007,8 +1007,12 @@ int main(int argc, const char **argv) opt_cmd == OPT_SNAP_CREATE || opt_cmd == OPT_SNAP_ROLLBACK || opt_cmd == OPT_SNAP_REMOVE || opt_cmd == OPT_MAP || opt_cmd == OPT_UNMAP) { - set_pool_image_name(poolname, imgname, (char **)&poolname, (char **)&imgname, (char **)&snapname); - } else if (snapname) { + set_pool_image_name(poolname, imgname, (char **)&poolname, + (char **)&imgname, (char **)&snapname); + } + if (snapname && opt_cmd != OPT_SNAP_CREATE && opt_cmd != OPT_SNAP_ROLLBACK && + opt_cmd != OPT_SNAP_REMOVE && opt_cmd != OPT_INFO && + opt_cmd != OPT_EXPORT && opt_cmd != OPT_COPY) { cerr << "error: snapname specified for a command that doesn't use it" << std::endl; usage_exit(); } @@ -1053,7 +1057,7 @@ int main(int argc, const char **argv) } } - if (imgname && + if (imgname && talk_to_cluster && (opt_cmd == OPT_RESIZE || opt_cmd == OPT_INFO || opt_cmd == OPT_SNAP_LIST || opt_cmd == OPT_SNAP_CREATE || opt_cmd == OPT_SNAP_ROLLBACK || opt_cmd == OPT_SNAP_REMOVE || opt_cmd == OPT_EXPORT || opt_cmd == OPT_WATCH || @@ -1065,7 +1069,8 @@ int main(int argc, const char **argv) } } - if (snapname) { + if (snapname && talk_to_cluster && + (opt_cmd == OPT_INFO || opt_cmd == OPT_EXPORT || opt_cmd == OPT_COPY)) { r = image.snap_set(snapname); if (r < 0 && !(r == -ENOENT && opt_cmd == OPT_SNAP_CREATE)) { cerr << "error setting snapshot context: " << cpp_strerror(-r) << std::endl; |