From 2e5d70c848e714642bff7af11cb772fa3b819d13 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Thu, 19 May 2022 10:49:40 +0200 Subject: [PATCH] fabrics: Consider config from file when adding new controller nvme_read_config() function is attaching the configuration to tree. But when we create a new controller via nvme_create_ctrl() and then call nvmf_add_ctrl() we ignore this previously read in configuration. Hence lookup if there exist a controller/config and merge into the fabrics config. Note, the order of the merge is important. For example we want the config from the command line to have higher priority than the one from the config file. Signed-off-by: Daniel Wagner --- src/nvme/fabrics.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c index 90ec04db..62059f91 100644 --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -559,10 +559,28 @@ out_close: int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c, const struct nvme_fabrics_config *cfg) { + nvme_subsystem_t s; char *argstr; int ret; + /* highest prio have configs from command line */ cfg = merge_config(c, cfg); + + /* apply configuration from config file (JSON) */ + s = nvme_lookup_subsystem(h, NULL, nvme_ctrl_get_subsysnqn(c)); + if (s) { + nvme_ctrl_t fc; + + fc = __nvme_lookup_ctrl(s, nvme_ctrl_get_transport(c), + nvme_ctrl_get_traddr(c), + nvme_ctrl_get_host_traddr(c), + nvme_ctrl_get_host_iface(c), + nvme_ctrl_get_trsvcid(c), + NULL); + if (fc) + cfg = merge_config(c, nvme_ctrl_get_config(fc)); + } + nvme_ctrl_set_discovered(c, true); if (traddr_is_hostname(h->r, c)) { char *traddr = c->traddr; -- 2.50.1