From 16f64a4c01068603736af476f640268d0baa338d Mon Sep 17 00:00:00 2001 From: Pan Liu Date: Sun, 3 Sep 2017 12:12:15 +0800 Subject: [PATCH] rbd-nbd: fix generic option issue Fixes: http://tracker.ceph.com/issues/20426 Signed-off-by: Pan Liu --- src/tools/rbd_nbd/rbd-nbd.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/tools/rbd_nbd/rbd-nbd.cc b/src/tools/rbd_nbd/rbd-nbd.cc index 6d432f86eb5..1ad70ce7e38 100644 --- a/src/tools/rbd_nbd/rbd-nbd.cc +++ b/src/tools/rbd_nbd/rbd-nbd.cc @@ -917,15 +917,27 @@ static int do_list_mapped_devices() static int parse_args(vector& args, std::ostream *err_msg, Config *cfg) { - std::vector::iterator i; - std::ostringstream err; + std::string conf_file_list; + std::string cluster; + CephInitParameters iparams = ceph_argparse_early_args( + args, CEPH_ENTITY_TYPE_CLIENT, &cluster, &conf_file_list); md_config_t config; - config.parse_config_files(nullptr, nullptr, 0); + config.name = iparams.name; + config.cluster = cluster; + + if (!conf_file_list.empty()) { + config.parse_config_files(conf_file_list.c_str(), nullptr, 0); + } else { + config.parse_config_files(nullptr, nullptr, 0); + } config.parse_env(); config.parse_argv(args); cfg->poolname = config.get_val("rbd_default_pool"); + std::vector::iterator i; + std::ostringstream err; + for (i = args.begin(); i != args.end(); ) { if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) { return HELP_INFO;