From bca862c317101524303e134b62576416879a6791 Mon Sep 17 00:00:00 2001 From: MingXin Liu Date: Mon, 5 Jan 2015 17:30:02 +0800 Subject: [PATCH] rbd: parse merge-diff arguments Signed-off-by: MingXin Liu Signed-off-by: Yunchuan Wen Signed-off-by: Li Wang --- src/rbd.cc | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/rbd.cc b/src/rbd.cc index cd595df4cca11..4e28e6491e85e 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -2101,7 +2101,8 @@ int main(int argc, const char **argv) *dest_poolname = NULL, *dest_snapname = NULL, *path = NULL, *devpath = NULL, *lock_cookie = NULL, *lock_client = NULL, *lock_tag = NULL, *output_format = "plain", - *fromsnapname = NULL; + *fromsnapname = NULL, + *first_diff = NULL, *second_diff = NULL; bool lflag = false; int pretty_format = 0; long long stripe_unit = 0, stripe_count = 0; @@ -2288,6 +2289,9 @@ if (!set_conf_param(v, p1, p2, p3)) { \ case OPT_EXPORT_DIFF: SET_CONF_PARAM(v, &imgname, &path, NULL); break; + case OPT_MERGE_DIFF: + SET_CONF_PARAM(v, &first_diff, &second_diff, &path); + break; case OPT_IMPORT: case OPT_IMPORT_DIFF: SET_CONF_PARAM(v, &path, &imgname, NULL); @@ -2392,7 +2396,8 @@ if (!set_conf_param(v, p1, p2, p3)) { \ opt_cmd != OPT_IMPORT && opt_cmd != OPT_IMPORT_DIFF && opt_cmd != OPT_UNMAP && - opt_cmd != OPT_SHOWMAPPED && !imgname) { + opt_cmd != OPT_SHOWMAPPED && + opt_cmd != OPT_MERGE_DIFF && !imgname) { cerr << "rbd: image name was not specified" << std::endl; return EXIT_FAILURE; } @@ -2446,6 +2451,20 @@ if (!set_conf_param(v, p1, p2, p3)) { \ if (!dest_poolname) dest_poolname = "rbd"; + if (opt_cmd == OPT_MERGE_DIFF) { + if (!first_diff) { + cerr << "rbd: first diff was not specified" << std::endl; + return EXIT_FAILURE; + } + if (!second_diff) { + cerr << "rbd: second diff was not specified" << std::endl; + return EXIT_FAILURE; + } + if (!path) { + cerr << "rbd: path was not specified" << std::endl; + return EXIT_FAILURE; + } + } if (opt_cmd == OPT_EXPORT && !path) path = imgname; -- 2.39.5