]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
fabrics: fix connect error if hostid file does not exist
authorMartin George <marting@netapp.com>
Sat, 16 Dec 2023 19:31:50 +0000 (01:01 +0530)
committerDaniel Wagner <wagi@monom.org>
Tue, 19 Dec 2023 09:05:41 +0000 (10:05 +0100)
Currently one sees a connect error during a nvme discover/connect
if the hostnqn file exists, but not the hostid file. Fix this
by ensuring the hostid is taken from the corresponding hostnqn for
such scenarios.

Signed-off-by: Martin George <marting@netapp.com>
fabrics.c

index e37c393582726349400e388313c8f18da8842ab3..2a0ad7089f75aeae006ffdb170606a8ee002e4bc 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -739,6 +739,8 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect)
        }
        if (!hostid)
                hostid = hid = nvmf_hostid_from_file();
+       if (!hostid && hostnqn)
+               hostid = hid = nvmf_hostid_from_hostnqn(hostnqn);
        nvmf_check_hostid_and_hostnqn(hostid, hostnqn);
        h = nvme_lookup_host(r, hostnqn, hostid);
        if (!h) {
@@ -960,6 +962,8 @@ int nvmf_connect(const char *desc, int argc, char **argv)
        }
        if (!hostid)
                hostid = hid = nvmf_hostid_from_file();
+       if (!hostid && hostnqn)
+               hostid = hid = nvmf_hostid_from_hostnqn(hostnqn);
        nvmf_check_hostid_and_hostnqn(hostid, hostnqn);
        h = nvme_lookup_host(r, hostnqn, hostid);
        if (!h) {