From dfb421ab2fc2b2074b28d3545769e3c21aaf5e87 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Wed, 31 Jan 2024 12:37:10 +0100 Subject: [PATCH] nvme: allow to overwrite hostnqn and hostid In order to be able to test the topology scan code, allow hostnqn and hostid to be controlled via an environment variable. This is just for testing purposes, thus don't mention it. Signed-off-by: Daniel Wagner --- src/nvme/fabrics.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c index 981fc442..1f50229f 100644 --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -1416,11 +1416,21 @@ static char *nvmf_read_file(const char *f, int len) char *nvmf_hostnqn_from_file() { + char *hostnqn = getenv("LIBNVME_HOSTNQN"); + + if (hostnqn) + return strdup(hostnqn); + return nvmf_read_file(NVMF_HOSTNQN_FILE, NVMF_NQN_SIZE); } char *nvmf_hostid_from_file() { + char *hostid = getenv("LIBNVME_HOSTID"); + + if (hostid) + return strdup(hostid); + return nvmf_read_file(NVMF_HOSTID_FILE, NVMF_HOSTID_SIZE); }