From: Ilya Dryomov Date: Tue, 21 Jul 2015 14:55:55 +0000 (+0300) Subject: rbd: error out if dest_snapname is specified X-Git-Tag: v9.0.3~14^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b60e144cebc9f5f1916adbb7e43f67af4988699f;p=ceph.git rbd: error out if dest_snapname is specified No command uses it as of now, but only clone command fails; cp, mv and import simply ignore it. Check if it's set and exit with a generic error message. Signed-off-by: Ilya Dryomov --- diff --git a/src/rbd.cc b/src/rbd.cc index 685ebcc509e8..51dbe781f216 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -3408,6 +3408,12 @@ if (!set_conf_param(v, p1, p2, p3)) { \ set_pool_image_name(destname, (char **)&dest_poolname, (char **)&destname, (char **)&dest_snapname); + if (dest_snapname) { + // no command uses dest_snapname + cerr << "rbd: destination snapname specified for a command that doesn't use it" + << std::endl; + return EXIT_FAILURE; + } if (opt_cmd == OPT_IMPORT) { if (poolname && dest_poolname) { @@ -3454,11 +3460,6 @@ if (!set_conf_param(v, p1, p2, p3)) { \ return EXIT_FAILURE; } - if ((opt_cmd == OPT_CLONE) && dest_snapname) { - cerr << "rbd: cannot clone to a snapshot" << std::endl; - return EXIT_FAILURE; - } - if ((opt_cmd == OPT_CLONE) && size) { cerr << "rbd: clone must begin at size of parent" << std::endl; return EXIT_FAILURE; diff --git a/src/test/cli/rbd/invalid-snap-usage.t b/src/test/cli/rbd/invalid-snap-usage.t index 40fc606bf2a6..cfe48936a163 100644 --- a/src/test/cli/rbd/invalid-snap-usage.t +++ b/src/test/cli/rbd/invalid-snap-usage.t @@ -34,3 +34,19 @@ $ rbd lock remove --snap=snap img id client.1234 rbd: snapname specified for a command that doesn't use it [1] + + $ rbd clone foo@snap bar@snap + rbd: destination snapname specified for a command that doesn't use it + [1] + $ rbd import /bin/ls ls@snap + rbd: destination snapname specified for a command that doesn't use it + [1] + $ rbd cp foo bar@snap + rbd: destination snapname specified for a command that doesn't use it + [1] + $ rbd cp foo@snap bar@snap + rbd: destination snapname specified for a command that doesn't use it + [1] + $ rbd mv foo bar@snap + rbd: destination snapname specified for a command that doesn't use it + [1] diff --git a/src/test/cli/rbd/not-enough-args.t b/src/test/cli/rbd/not-enough-args.t index 958f5c2b6dda..dc48a64439e2 100644 --- a/src/test/cli/rbd/not-enough-args.t +++ b/src/test/cli/rbd/not-enough-args.t @@ -4,9 +4,6 @@ $ rbd unmap rbd: unmap requires either image name or device path [1] - $ rbd clone foo@snap bar@snap - rbd: cannot clone to a snapshot - [1] $ rbd cp foo rbd: destination image name was not specified [1]