From 194d6af65db462541368ab8f83b31c8eccdfeabd Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 11 Jun 2018 10:40:42 -0700 Subject: [PATCH] nvmf: allow setting namespace UUID in config file Change-Id: I768129eec3b08c43ef27c3ba8c237d77ebd49178 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/414681 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto --- etc/spdk/nvmf.conf.in | 4 ++-- lib/event/subsystems/nvmf/conf.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/etc/spdk/nvmf.conf.in b/etc/spdk/nvmf.conf.in index f222b1d01..2da074389 100644 --- a/etc/spdk/nvmf.conf.in +++ b/etc/spdk/nvmf.conf.in @@ -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 [] +# Namespace [ []] # Namespaces backed by physical NVMe devices [Subsystem1] diff --git a/lib/event/subsystems/nvmf/conf.c b/lib/event/subsystems/nvmf/conf.c index ec26094fb..53ff4bafc 100644 --- a/lib/event/subsystems/nvmf/conf.c +++ b/lib/event/subsystems/nvmf/conf.c @@ -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);