Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP4:Update
nvme-cli.27116
0017-fabrics-Honor-JSON-config-file-in-connect-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0017-fabrics-Honor-JSON-config-file-in-connect-all-comman.patch of Package nvme-cli.27116
From: Daniel Wagner <dwagner@suse.de> Date: Thu, 29 Sep 2022 15:44:23 +0200 Subject: fabrics: Honor JSON config file in connect-all command Git-commit: 952aa044b331ebf20a949726fcf4cb3948f59403 References: bsc#1203204 bsc#1203163 When we there is a JSON config file use it when doing a connect-all. Signed-off-by: Daniel Wagner <dwagner@suse.de> --- fabrics.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 85 insertions(+), 7 deletions(-) --- a/fabrics.c +++ b/fabrics.c @@ -103,12 +103,12 @@ static const char *nvmf_config_file = "U OPT_FLAG("data-digest", 'G', &c.data_digest, nvmf_data_digest) \ struct tr_config { - char *subsysnqn; - char *transport; - char *traddr; - char *host_traddr; - char *host_iface; - char *trsvcid; + const char *subsysnqn; + const char *transport; + const char *traddr; + const char *host_traddr; + const char *host_iface; + const char *trsvcid; }; static void space_strip_len(int max, char *str) @@ -606,6 +606,75 @@ static int discover_from_conf_file(nvme_ return ret; } +static int discover_from_json_config_file(nvme_root_t r, nvme_host_t h, + const char *desc, bool connect, + const struct nvme_fabrics_config *defcfg, + enum nvme_print_flags flags, + bool force) +{ + const char *transport, *traddr, *trsvcid, *subsysnqn; + nvme_subsystem_t s; + nvme_ctrl_t c, cn; + struct nvme_fabrics_config cfg; + int ret = 0; + + nvme_for_each_subsystem(h, s) { + nvme_subsystem_for_each_ctrl(s, c) { + transport = nvme_ctrl_get_transport(c); + traddr = nvme_ctrl_get_traddr(c); + + if (!transport && !traddr) + continue; + + /* ignore none fabric transports */ + if (strcmp(transport, "tcp") && + strcmp(transport, "rdma") && + strcmp(transport, "fc")) + continue; + + trsvcid = nvme_ctrl_get_trsvcid(c); + if (!trsvcid || !strcmp(trsvcid, "")) + trsvcid = get_default_trsvcid(transport, true); + + if (force) + subsysnqn = nvme_ctrl_get_subsysnqn(c); + else + subsysnqn = NVME_DISC_SUBSYS_NAME; + + memcpy(&cfg, defcfg, sizeof(cfg)); + + struct tr_config trcfg = { + .subsysnqn = subsysnqn, + .transport = transport, + .traddr = traddr, + .host_traddr = cfg.host_traddr, + .host_iface = cfg.host_iface, + .trsvcid = trsvcid, + }; + + if (!force) { + cn = lookup_discover_ctrl(r, &trcfg); + if (cn) { + __discover(c, &cfg, raw, connect, + true, flags); + continue; + } + } + + cn = create_discover_ctrl(r, h, &cfg, &trcfg); + if (!cn) + continue; + + __discover(cn, &cfg, raw, connect, persistent, flags); + if (!persistent) + ret = nvme_disconnect_ctrl(cn); + nvme_free_ctrl(cn); + } + } + + return ret; +} + int nvmf_discover(const char *desc, int argc, char **argv, bool connect) { char *subsysnqn = NVME_DISC_SUBSYS_NAME; @@ -623,6 +692,7 @@ int nvmf_discover(const char *desc, int struct nvme_fabrics_config cfg; char *device = NULL; bool force = false; + bool json_config = false; OPT_ARGS(opts) = { OPT_STRING("device", 'd', "DEV", &device, "use existing discovery controller device"), @@ -664,7 +734,8 @@ int nvmf_discover(const char *desc, int nvme_free_tree(r); return ret; } - nvme_read_config(r, config_file); + if (!nvme_read_config(r, config_file)) + json_config = true; if (!hostnqn) hostnqn = hnqn = nvmf_hostnqn_from_file(); @@ -687,6 +758,13 @@ int nvmf_discover(const char *desc, int nvme_host_set_dhchap_key(h, hostkey); if (!device && !transport && !traddr) { + if (json_config) + ret = discover_from_json_config_file(r, h, desc, + connect, &cfg, + flags, force); + if (ret || access(PATH_NVMF_DISC, F_OK)) + goto out_free; + ret = discover_from_conf_file(r, h, desc, connect, &cfg); goto out_free; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor