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>
destname = imgname;
if (!destname)
destname = imgname_from_path(path);
+ imgname = NULL;
}
if (opt_cmd != OPT_LOCK_ADD && lock_tag) {
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";