nvmf: allow setting namespace UUID in config file

Change-Id: I768129eec3b08c43ef27c3ba8c237d77ebd49178
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/414681
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Daniel Verkamp 2018-06-11 10:40:42 -07:00 committed by Jim Harris
parent c06345bfaf
commit 194d6af65d
2 changed files with 13 additions and 2 deletions

View File

@ -133,9 +133,9 @@
# The user must specify a bdev name for each namespace, and may optionally
# specify a namespace ID. If nsid is omitted, the namespace will be
# assigned the next available NSID. The NSID must be unique within the
# subsystem.
# subsystem. An optional namespace UUID may also be specified.
# Syntax:
# Namespace <bdev_name> [<nsid>]
# Namespace <bdev_name> [<nsid> [<uuid>]]
# Namespaces backed by physical NVMe devices
[Subsystem1]

View File

@ -279,6 +279,7 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
struct spdk_nvmf_ns_opts ns_opts;
struct spdk_bdev *bdev;
const char *bdev_name;
const char *uuid_str;
char *nsid_str;
bdev_name = spdk_conf_section_get_nmval(sp, "Namespace", i, 0);
@ -311,6 +312,16 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
ns_opts.nsid = (uint32_t)nsid_ul;
}
uuid_str = spdk_conf_section_get_nmval(sp, "Namespace", i, 2);
if (uuid_str) {
if (spdk_uuid_parse(&ns_opts.uuid, uuid_str)) {
SPDK_ERRLOG("Invalid UUID %s\n", uuid_str);
spdk_nvmf_subsystem_destroy(subsystem);
subsystem = NULL;
goto done;
}
}
if (spdk_nvmf_subsystem_add_ns(subsystem, bdev, &ns_opts, sizeof(ns_opts)) == 0) {
SPDK_ERRLOG("Unable to add namespace\n");
spdk_nvmf_subsystem_destroy(subsystem);