]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: fix import pool assumptions
authorDan Mick <dan.mick@inktank.com>
Fri, 16 Nov 2012 06:41:36 +0000 (22:41 -0800)
committerDan Mick <dan.mick@inktank.com>
Tue, 27 Nov 2012 05:38:05 +0000 (21:38 -0800)
import allows specifying one image, implicitly or explicitly the
"source" image, even though it's really the destination.  Fix up
the reassignment of 'source' to 'dest', and check for and complain
about specifying two different pools or images for import.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
src/rbd.cc

index 9d02d994ba3d961e4b4dd4e0eaeec3b91cb2d54c..ecdcfbe2ad073eebf296b6be5270b5cf1c2fc037 100644 (file)
@@ -1607,6 +1607,7 @@ if (!set_conf_param(v, p1, p2, p3)) { \
     destname = imgname;
     if (!destname)
       destname = imgname_from_path(path);
+    imgname = NULL;
   }
 
   if (opt_cmd != OPT_LOCK_ADD && lock_tag) {
@@ -1656,6 +1657,19 @@ if (!set_conf_param(v, p1, p2, p3)) { \
 
   set_pool_image_name(dest_poolname, destname, (char **)&dest_poolname, (char **)&destname, (char **)&dest_snapname);
 
+  if (opt_cmd == OPT_IMPORT) {
+    if (poolname && dest_poolname) {
+      cerr << "rbd: source and destination pool both specified" << std::endl;
+      return EXIT_FAILURE;
+    }
+    if (imgname && destname) {
+      cerr << "rbd: source and destination image both specified" << std::endl;
+      return EXIT_FAILURE;
+    }
+    if (poolname)
+      dest_poolname = poolname;
+  }
+
   if (!poolname)
     poolname = "rbd";