From: songweibin Date: Thu, 22 Feb 2018 05:48:16 +0000 (+0800) Subject: rbd: set a default value for options in `nbd map` X-Git-Tag: v13.0.2~178^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2545f972dfec0532c665d957688ed166eea27019;p=ceph.git rbd: set a default value for options in `nbd map` Since `vm` does not contain an `options` item and `vm.at("options").value()` will throw an exception. root@s222:/ceph-dev/build# rbd nbd map img1 rbd: 'nbd map' command is deprecated, use 'device map -t nbd' instead terminate called after throwing an instance of 'std::out_of_range' what(): map::at *** Caught signal (Aborted) ** in thread 7f0e5e046400 thread_name:rbd ceph version 12.0.3-11022-ga09b319 (a09b319a5e984185bd56064e52f2e8ec3da49b73) mimic (dev) 1: (()+0x1afb00) [0x55a07d677b00] 2: (()+0x10340) [0x7f0e545a0340] 3: (gsignal()+0x39) [0x7f0e531b0cc9] 4: (abort()+0x148) [0x7f0e531b40d8] 5: (__gnu_cxx::__verbose_terminate_handler()+0x125) [0x7f0e53ac8415] 6: (()+0x6a206) [0x7f0e53ac6206] 7: (()+0x6a251) [0x7f0e53ac6251] 8: (()+0x6a493) [0x7f0e53ac6493] 9: (std::__throw_out_of_range(char const*)+0x3f) [0x7f0e53aeac3f] 10: (rbd::action::nbd::execute_map_deprecated(boost::program_options::variables_map const&, std::vector > const&)+0xa35) [0x55a07d5f6a15] 11: (rbd::Shell::execute(int, char const**)+0xb5b) [0x55a07d581adb] 12: (main()+0x15) [0x55a07d546615] 13: (__libc_start_main()+0xf5) [0x7f0e5319bec5] 14: (()+0xa141f) [0x55a07d56941f] 2018-02-22 13:43:59.212 7f0e5e046400 -1 *** Caught signal (Aborted) ** in thread 7f0e5e046400 thread_name:rbd Signed-off-by: songweibin --- diff --git a/src/tools/rbd/action/Nbd.cc b/src/tools/rbd/action/Nbd.cc index de64b5e89fc8..93012cf68b2c 100644 --- a/src/tools/rbd/action/Nbd.cc +++ b/src/tools/rbd/action/Nbd.cc @@ -221,7 +221,8 @@ int execute_map_deprecated(const po::variables_map &vm_deprecated, options.add_options() ("read-only", po::bool_switch(), "") ("exclusive", po::bool_switch(), "") - ("options,o", po::value>(), ""); + ("options,o", po::value>() + ->default_value(std::vector(), ""), ""); po::variables_map vm; po::store(po::command_line_parser({}).options(options).run(), vm);