]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: error out if dest_snapname is specified
authorIlya Dryomov <idryomov@gmail.com>
Tue, 21 Jul 2015 14:55:55 +0000 (17:55 +0300)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 27 Jul 2015 09:22:04 +0000 (12:22 +0300)
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 <idryomov@gmail.com>
src/rbd.cc
src/test/cli/rbd/invalid-snap-usage.t
src/test/cli/rbd/not-enough-args.t

index 685ebcc509e80fcc61346354677836e95ee37ec9..51dbe781f216f083b594b4aacd44110f98d14097 100644 (file)
@@ -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;
index 40fc606bf2a6b79dfa90ba36629cf6cf14178657..cfe48936a163f8fa16717514a5a97d250b448a61 100644 (file)
   $ 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]
index 958f5c2b6ddabb55e876c90e9bedc544540e4b27..dc48a64439e2947279b612831e882fea759d5d3a 100644 (file)
@@ -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]