Skip to content

Commit 2e5d70c

Browse files
committed
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 <[email protected]>
1 parent c6611bb commit 2e5d70c

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/nvme/fabrics.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,28 @@ static int __nvmf_add_ctrl(nvme_root_t r, const char *argstr)
559559
int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,
560560
const struct nvme_fabrics_config *cfg)
561561
{
562+
nvme_subsystem_t s;
562563
char *argstr;
563564
int ret;
564565

566+
/* highest prio have configs from command line */
565567
cfg = merge_config(c, cfg);
568+
569+
/* apply configuration from config file (JSON) */
570+
s = nvme_lookup_subsystem(h, NULL, nvme_ctrl_get_subsysnqn(c));
571+
if (s) {
572+
nvme_ctrl_t fc;
573+
574+
fc = __nvme_lookup_ctrl(s, nvme_ctrl_get_transport(c),
575+
nvme_ctrl_get_traddr(c),
576+
nvme_ctrl_get_host_traddr(c),
577+
nvme_ctrl_get_host_iface(c),
578+
nvme_ctrl_get_trsvcid(c),
579+
NULL);
580+
if (fc)
581+
cfg = merge_config(c, nvme_ctrl_get_config(fc));
582+
}
583+
566584
nvme_ctrl_set_discovered(c, true);
567585
if (traddr_is_hostname(h->r, c)) {
568586
char *traddr = c->traddr;

0 commit comments

Comments
 (0)