diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index a9d61388693..ff65c55c6be 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -63,6 +63,7 @@ int main(int argc, const char **argv) global_init(args, CEPH_ENTITY_TYPE_MON, CODE_ENVIRONMENT_DAEMON, 0); + uuid_d fsid; std::string val; for (std::vector::iterator i = args.begin(); i != args.end(); ) { if (ceph_argparse_double_dash(args, i)) { @@ -76,6 +77,11 @@ int main(int argc, const char **argv) osdmapfn = val; } else if (ceph_argparse_witharg(args, i, &val, "--inject_monmap", (char*)NULL)) { inject_monmap = val; + } else if (ceph_argparse_witharg(args, i, &val, "--fsid", (char*)NULL)) { + if (!fsid.parse(val.c_str())) { + cerr << "unable to parse fsid '" << val << "'" << std::endl; + exit(1); + } } else { ++i; } @@ -122,6 +128,16 @@ int main(int argc, const char **argv) } } + if (!fsid.is_zero()) { + cout << argv[0] << ": setting fsid to " << fsid << std::endl; + monmap.fsid = fsid; + } + + if (monmap.fsid.is_zero()) { + cerr << argv[0] << ": generated monmap has no fsid; use --fsid" << std::endl; + exit(10); + } + // osdmap err = osdmapbl.read_file(osdmapfn.c_str(), &error); if (err < 0) { diff --git a/src/include/uuid.h b/src/include/uuid.h index 8c7ce8faf44..60049b173af 100644 --- a/src/include/uuid.h +++ b/src/include/uuid.h @@ -15,6 +15,10 @@ extern "C" { struct uuid_d { uuid_t uuid; + uuid_d() { + memset(&uuid, 0, sizeof(uuid)); + } + bool is_zero() { return uuid_is_null(uuid); } @@ -23,7 +27,7 @@ struct uuid_d { uuid_generate(uuid); } - bool parse(char *s) { + bool parse(const char *s) { return uuid_parse(s, uuid) == 0; } void print(char *s) {