]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
fabrics: restore discover_from_conf_file to actually work
authorSagi Grimberg <sagi@grimberg.me>
Sun, 26 Sep 2021 18:27:49 +0000 (21:27 +0300)
committerKeith Busch <kbusch@kernel.org>
Mon, 27 Sep 2021 20:13:11 +0000 (13:13 -0700)
With all the rework, discover_from_conf_file was completely
broken. Have both discover and connect-all working with
params passed from /etc/nvme/discovery.conf

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
fabrics.c

index b13254683e1495c4b5f4daffac3a6226c251abf3..012bcb8819e0d7fa57726415751d13d21682bd0b 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -299,7 +299,10 @@ static int discover_from_conf_file(nvme_host_t h, const char *desc,
        char *hostnqn = NULL, *hostid = NULL;
        char *ptr, **argv, *p, line[4096];
        int argc, ret = 0;
+       unsigned int verbose = 0;
        FILE *f;
+       enum nvme_print_flags flags;
+       char *format = "normal";
 
        struct nvme_fabrics_config cfg = {
                .tos = -1,
@@ -308,8 +311,18 @@ static int discover_from_conf_file(nvme_host_t h, const char *desc,
 
        OPT_ARGS(opts) = {
                NVMF_OPTS(cfg),
+               OPT_FMT("output-format", 'o', &format,        output_format),
+               OPT_FILE("raw",          'r', &raw,           "save raw output to file"),
+               OPT_FLAG("persistent",   'p', &persistent,    "persistent discovery connection"),
+               OPT_FLAG("quiet",        'S', &quiet,         "suppress already connected errors"),
+               OPT_INCR("verbose",      'v', &verbose,       "Increase logging verbosity"),
+               OPT_END()
        };
 
+       ret = flags = validate_output_format(format);
+       if (ret < 0)
+               return ret;
+
        f = fopen(PATH_NVMF_DISC, "r");
        if (f == NULL) {
                errno = ENOENT;
@@ -340,7 +353,8 @@ static int discover_from_conf_file(nvme_host_t h, const char *desc,
                ret = argconfig_parse(argc, argv, desc, opts);
                if (ret)
                        goto next;
-
+               if (persistent && !cfg.keep_alive_tmo)
+                       cfg.keep_alive_tmo = 30;
                if (!transport && !traddr)
                        goto next;
 
@@ -351,8 +365,8 @@ static int discover_from_conf_file(nvme_host_t h, const char *desc,
                errno = 0;
                ret = nvmf_add_ctrl(h, c, &cfg, false);
                if (!ret) {
-                       __discover(c, defcfg, NULL, persistent,
-                                  connect, 0);
+                       __discover(c, &cfg, raw, connect,
+                                  persistent, flags);
                        if (!persistent)
                                ret = nvme_disconnect_ctrl(c);
                        nvme_free_ctrl(c);