From e612afc2c02c9d46c2542dfe8c1f6150a39b5878 Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Thu, 15 Nov 2012 22:41:36 -0800 Subject: [PATCH] rbd: fix import pool assumptions 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 Reviewed-by: Josh Durgin (cherry picked from commit c219698149c2fe4d2539f0bc1e2009b937aa4250) --- src/rbd.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/rbd.cc b/src/rbd.cc index 9d02d994ba3d9..ecdcfbe2ad073 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -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"; -- 2.39.5