From: Martin George Date: Sat, 16 Dec 2023 19:31:50 +0000 (+0530) Subject: fabrics: fix connect error if hostid file does not exist X-Git-Tag: v2.7~7 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=8c78e15582ff1a47ba8f4c1953a374cb7555203e;p=users%2Fsagi%2Fnvme-cli.git fabrics: fix connect error if hostid file does not exist 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 --- diff --git a/fabrics.c b/fabrics.c index e37c3935..2a0ad708 100644 --- 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) {