From: Sage Weil Date: Thu, 5 Apr 2012 20:35:07 +0000 (-0700) Subject: config: add distinct UUID type X-Git-Tag: v0.46~120^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2c14c8b2061e65a9607fccdf290485ba1497c4cf;p=ceph.git config: add distinct UUID type Signed-off-by: Sage Weil --- diff --git a/src/common/config.cc b/src/common/config.cc index 762c9a569b58..80b6e1999549 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -422,7 +422,8 @@ int md_config_t::parse_option(std::vector& args, else if (ceph_argparse_witharg(args, i, &val, as_option.c_str(), (char*)NULL)) { if (oss && ( - ((opt->type == OPT_STR) || (opt->type == OPT_ADDR)) && + ((opt->type == OPT_STR) || (opt->type == OPT_ADDR) || + (opt->type == OPT_UUID)) && (observers.find(opt->name) == observers.end()))) { *oss << "You cannot change " << opt->name << " using injectargs.\n"; ret = -ENOSYS; @@ -595,7 +596,8 @@ int md_config_t::set_val(const char *key, const char *val) if (strcmp(opt->name, k.c_str()) == 0) { if (internal_safe_to_start_threads) { // If threads have been started... - if ((opt->type == OPT_STR) || (opt->type == OPT_ADDR)) { + if ((opt->type == OPT_STR) || (opt->type == OPT_ADDR) || + (opt->type == OPT_UUID)) { // And this is NOT an integer valued variable.... if (observers.find(opt->name) == observers.end()) { // And there is no observer to safely change it... @@ -662,10 +664,12 @@ int md_config_t::_get_val(const char *key, char **buf, int len) const case OPT_U64: oss << *(uint64_t*)opt->conf_ptr(this); break; - case OPT_ADDR: { + case OPT_ADDR: oss << *(entity_addr_t*)opt->conf_ptr(this); break; - } + case OPT_UUID: + oss << *(uuid_d*)opt->conf_ptr(this); + break; } string str(oss.str()); int l = strlen(str.c_str()) + 1; @@ -801,6 +805,12 @@ int md_config_t::set_val_raw(const char *val, const config_option *opt) } return 0; } + case OPT_UUID: { + uuid_d *u = (uuid_d*)opt->conf_ptr(this); + if (!u->parse(val)) + return -EINVAL; + return 0; + } } return -ENOSYS; } diff --git a/src/common/config.h b/src/common/config.h index 262f4201fa9e..274a4c817565 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -183,6 +183,7 @@ public: #define OPTION_OPT_ADDR(name) const entity_addr_t name; #define OPTION_OPT_U32(name) const uint32_t name; #define OPTION_OPT_U64(name) const uint64_t name; +#define OPTION_OPT_UUID(name) const uuid_d name; #define OPTION(name, ty, init) OPTION_##ty(name) #define SUBSYS(name, log, gather) #define DEFAULT_SUBSYS(log, gather) @@ -196,6 +197,7 @@ public: #undef OPTION_OPT_ADDR #undef OPTION_OPT_U32 #undef OPTION_OPT_U64 +#undef OPTION_OPT_UUID #undef OPTION #undef SUBSYS #undef DEFAULT_SUBSYS @@ -209,7 +211,7 @@ public: typedef enum { OPT_INT, OPT_LONGLONG, OPT_STR, OPT_DOUBLE, OPT_FLOAT, OPT_BOOL, - OPT_ADDR, OPT_U32, OPT_U64 + OPT_ADDR, OPT_U32, OPT_U64, OPT_UUID } opt_type_t; bool ceph_resolve_file_search(const std::string& filename_list,