]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
mi: Allow probe suppression via an environment variable
authorJeremy Kerr <jk@codeconstruct.com.au>
Mon, 31 Oct 2022 05:39:09 +0000 (13:39 +0800)
committerJeremy Kerr <jk@codeconstruct.com.au>
Thu, 3 Nov 2022 05:53:50 +0000 (13:53 +0800)
This change introduces a new environment variable to disable quirk
probing: LIBNVME_MI_PROBE_ENABLED. Values of 0, "off" or "disable{d}"
will prevent the probe.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
src/nvme/mi.c

index 8ffbaccc94122b6650e2010c5e6bfd89706f82ce..c483874485b2101da6236f4ef22bb188142a6d68 100644 (file)
 static const int default_timeout = 1000; /* milliseconds; endpoints may
                                            override */
 
+static bool nvme_mi_probe_enabled_default(void)
+{
+       char *val;
+
+       val = getenv("LIBNVME_MI_PROBE_ENABLED");
+       if (!val)
+               return true;
+
+       return strcmp(val, "0") &&
+               strcasecmp(val, "false") &&
+               strncasecmp(val, "disable", 7);
+
+}
+
 /* MI-equivalent of nvme_create_root, but avoids clashing symbol names
  * when linking against both libnvme and libnvme-mi.
  */
@@ -33,7 +47,7 @@ nvme_root_t nvme_mi_create_root(FILE *fp, int log_level)
        }
        r->log_level = log_level;
        r->fp = stderr;
-       r->mi_probe_enabled = true;
+       r->mi_probe_enabled = nvme_mi_probe_enabled_default();
        if (fp)
                r->fp = fp;
        list_head_init(&r->hosts);