diff options
author | Dan Mick <dan.mick@inktank.com> | 2012-11-15 22:41:36 -0800 |
---|---|---|
committer | Dan Mick <dan.mick@inktank.com> | 2012-11-26 21:38:05 -0800 |
commit | c219698149c2fe4d2539f0bc1e2009b937aa4250 (patch) | |
tree | 3583da3f75ad696bd1ef77de546a91f59ec3adfa | |
parent | 3b0c36052806a4574ede6a9f0594dc83f7997bcc (diff) | |
download | ceph-c219698149c2fe4d2539f0bc1e2009b937aa4250.tar.gz |
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 <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
-rw-r--r-- | src/rbd.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/rbd.cc b/src/rbd.cc index 9d02d994ba3..ecdcfbe2ad0 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"; |