]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
nvme-cli: ignore arguments that pass in "none"
authorJames Smart <jsmart2021@gmail.com>
Thu, 1 Aug 2019 23:13:39 +0000 (16:13 -0700)
committerKeith Busch <kbusch@kernel.org>
Fri, 2 Aug 2019 15:37:47 +0000 (09:37 -0600)
As we want to support discovery uevents over different
transports, we want to allow the kernel to provide missing
information in the form of none and have nvme-cli properly
ignore it.

One example is the host_traddr. If it is not set (which means
that the default route determined the host address) we will
want to do the same for newly discovered controllers.

So allow users to pass 'none' arguments as well.

Example:
  nvme connect-all ... --hostnqn=none --hostid=none --host_traddr=none

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com>
fabrics.c

index 5cbc84c7f4bf7cc3732b3133a42a535e455b86e4..5ff6edc615dce71f16a4d478b3ab8f9b07a2235e 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -578,7 +578,7 @@ add_argument(char **argstr, int *max_len, char *arg_str, char *arg)
 {
        int len;
 
-       if (arg) {
+       if (arg && strcmp(arg, "none")) {
                len = snprintf(*argstr, *max_len, ",%s=%s", arg_str, arg);
                if (len < 0)
                        return -EINVAL;
@@ -675,14 +675,14 @@ retry:
                return -EINVAL;
        p += len;
 
-       if (cfg.hostnqn) {
+       if (cfg.hostnqn && strcmp(cfg.hostnqn, "none")) {
                len = sprintf(p, ",hostnqn=%s", cfg.hostnqn);
                if (len < 0)
                        return -EINVAL;
                p += len;
        }
 
-       if (cfg.hostid) {
+       if (cfg.hostid && strcmp(cfg.hostid, "none")) {
                len = sprintf(p, ",hostid=%s", cfg.hostid);
                if (len < 0)
                        return -EINVAL;
@@ -717,7 +717,7 @@ retry:
                p += len;
        }
 
-       if (cfg.host_traddr) {
+       if (cfg.host_traddr && strcmp(cfg.host_traddr, "none")) {
                len = sprintf(p, ",host_traddr=%s", cfg.host_traddr);
                if (len < 0)
                        return -EINVAL;