diff --git a/Documentation/nvme-config.txt b/Documentation/nvme-config.txt index f5df34c2c1..914c4bb0df 100644 --- a/Documentation/nvme-config.txt +++ b/Documentation/nvme-config.txt @@ -115,8 +115,8 @@ OPTIONS -I :: --hostid=:: - UUID(Universally Unique Identifier) to be discovered which should be - formatted. + Deprecated and ignored. This option is kept around for backwards + compatibility. Use --hostnqn instead. -S :: --dhchap-secret=:: diff --git a/Documentation/nvme-connect-all.txt b/Documentation/nvme-connect-all.txt index a08aaa27aa..0c616151a3 100644 --- a/Documentation/nvme-connect-all.txt +++ b/Documentation/nvme-connect-all.txt @@ -105,8 +105,8 @@ OPTIONS -I :: --hostid=:: - UUID(Universally Unique Identifier) to be discovered which should be - formatted. + Deprecated and ignored. This option is kept around for backwards + compatibility. Use --hostnqn instead. -r :: --raw=:: diff --git a/Documentation/nvme-connect.txt b/Documentation/nvme-connect.txt index 65d5cfbf23..6a8a7263cd 100644 --- a/Documentation/nvme-connect.txt +++ b/Documentation/nvme-connect.txt @@ -93,8 +93,8 @@ OPTIONS -I :: --hostid=:: - UUID(Universally Unique Identifier) to be discovered which should be - formatted. + Deprecated and ignored. This option is kept around for backwards + compatibility. Use --hostnqn instead. -J :: --config=:: diff --git a/Documentation/nvme-discover.txt b/Documentation/nvme-discover.txt index 49259e045f..2f1f30648b 100644 --- a/Documentation/nvme-discover.txt +++ b/Documentation/nvme-discover.txt @@ -124,8 +124,8 @@ OPTIONS -I :: --hostid=:: - UUID(Universally Unique Identifier) to be discovered which should be - formatted. + Deprecated and ignored. This option is kept around for backwards + compatibility. Use --hostnqn instead. -r :: --raw=:: diff --git a/fabrics.c b/fabrics.c index 9016fb81d0..04d74e3e63 100644 --- a/fabrics.c +++ b/fabrics.c @@ -70,7 +70,7 @@ static const char *nvmf_trsvcid = "transport service id (e.g. IP port)"; static const char *nvmf_htraddr = "host traddr (e.g. FC WWN's)"; static const char *nvmf_hiface = "host interface (for tcp transport)"; static const char *nvmf_hostnqn = "user-defined hostnqn"; -static const char *nvmf_hostid = "user-defined hostid (if default not used)"; +static const char *nvmf_hostid = "(deprecated and ignored)"; static const char *nvmf_hostkey = "user-defined dhchap key (if default not used)"; static const char *nvmf_ctrlkey = "user-defined dhchap controller key (for bi-directional authentication)"; static const char *nvmf_nr_io_queues = "number of io queues to use (default is core count)"; @@ -334,7 +334,7 @@ static int setup_common_context(struct nvmf_context *fctx, return err; err = nvmf_context_set_hostnqn(fctx, - fa->hostnqn, fa->hostid); + fa->hostnqn); if (err) return err; @@ -367,7 +367,7 @@ static int create_common_context(struct nvme_global_ctx *ctx, if (err) goto err; - err = nvmf_context_set_hostnqn(fctx, fa->hostnqn, fa->hostid); + err = nvmf_context_set_hostnqn(fctx, fa->hostnqn); if (err) goto err; diff --git a/libnvme/doc/config-schema.json.in b/libnvme/doc/config-schema.json.in index 47d883723e..200442c5b6 100644 --- a/libnvme/doc/config-schema.json.in +++ b/libnvme/doc/config-schema.json.in @@ -21,10 +21,6 @@ "type": "string", "maxLength": 223 }, - "hostid": { - "description": "NVMe host ID", - "type": "string" - }, "dhchap_key": { "description": "Host DH-HMAC-CHAP key", "type": "string" diff --git a/libnvme/examples/discover-loop.c b/libnvme/examples/discover-loop.c index f1369e8a0d..d63445b501 100644 --- a/libnvme/examples/discover-loop.c +++ b/libnvme/examples/discover-loop.c @@ -69,7 +69,7 @@ int main() nvme_free_global_ctx(ctx); return 1; } - ret = nvme_get_host(ctx, NULL, NULL, &h); + ret = nvme_get_host(ctx, NULL, &h); if (ret) { fprintf(stderr, "Failed to allocated memory\n"); return 1; diff --git a/libnvme/libnvme/nvme.i b/libnvme/libnvme/nvme.i index 3669936f7e..ea012287c0 100644 --- a/libnvme/libnvme/nvme.i +++ b/libnvme/libnvme/nvme.i @@ -44,15 +44,8 @@ free(val); return obj; } - PyObject *read_hostid() { - char * val = nvme_read_hostid(); - PyObject * obj = val ? PyUnicode_FromString(val) : Py_NewRef(Py_None); - free(val); - return obj; - } %} PyObject *read_hostnqn(); -PyObject *read_hostid(); %exception nvme_ctrl::connect { connect_err = 0; @@ -363,10 +356,8 @@ struct nvme_global_ctx { struct nvme_host { %immutable hostnqn; - %immutable hostid; %immutable hostsymname; char *hostnqn; - char *hostid; char *hostsymname; %extend { char *dhchap_host_key; @@ -546,18 +537,16 @@ struct nvme_ns { %pythonappend nvme_host::nvme_host(struct nvme_global_ctx *ctx, const char *hostnqn, - const char *hostid, const char *hostkey, const char *hostsymname) { self.__parent = ctx # Keep a reference to parent to ensure garbage collection happens in the right order} %extend nvme_host { nvme_host(struct nvme_global_ctx *ctx, const char *hostnqn = NULL, - const char *hostid = NULL, const char *hostkey = NULL, const char *hostsymname = NULL) { nvme_host_t h; - if (nvme_get_host(ctx, hostnqn, hostid, &h)) + if (nvme_get_host(ctx, hostnqn, &h)) return NULL; if (hostsymname) nvme_host_set_hostsymname(h, hostsymname); @@ -580,7 +569,7 @@ struct nvme_ns { } PyObject* __str__() { - return PyUnicode_FromFormat("nvme.host(%s,%s)", STR_OR_NONE($self->hostnqn), STR_OR_NONE($self->hostid)); + return PyUnicode_FromFormat("nvme.host(%s)", STR_OR_NONE($self->hostnqn)); } %pythoncode %{ def subsystems(self): diff --git a/libnvme/libnvme/tests/test-objects.py b/libnvme/libnvme/tests/test-objects.py index e13814cfb4..bfc1efeefc 100644 --- a/libnvme/libnvme/tests/test-objects.py +++ b/libnvme/libnvme/tests/test-objects.py @@ -69,13 +69,6 @@ def test_creation_with_explicit_hostnqn(self): self.assertIsNotNone(host) self.assertEqual(host.hostnqn, hostnqn) - def test_creation_with_hostnqn_and_hostid(self): - hostnqn = 'nqn.2014-08.com.example:test-host-props' - hostid = '11111111-2222-3333-4444-555555555555' - host = nvme.host(self.ctx, hostnqn=hostnqn, hostid=hostid) - self.assertEqual(host.hostnqn, hostnqn) - self.assertEqual(host.hostid, hostid) - def test_creation_with_hostsymname(self): hostnqn = 'nqn.2014-08.com.example:test-host-symname' symname = 'my-storage-host' @@ -248,10 +241,6 @@ def test_read_hostnqn_returns_string_or_none(self): hostnqn = nvme.read_hostnqn() self.assertIsInstance(hostnqn, (str, type(None))) - def test_read_hostid_returns_string_or_none(self): - hostid = nvme.read_hostid() - self.assertIsInstance(hostid, (str, type(None))) - if __name__ == '__main__': unittest.main() diff --git a/libnvme/src/accessors.ld b/libnvme/src/accessors.ld index 3cd26f8f7d..f47d50f3ef 100644 --- a/libnvme/src/accessors.ld +++ b/libnvme/src/accessors.ld @@ -84,7 +84,6 @@ LIBNVME_ACCESSORS_3 { nvme_subsystem_get_iopolicy; nvme_subsystem_set_iopolicy; nvme_host_get_hostnqn; - nvme_host_get_hostid; nvme_host_get_dhchap_host_key; nvme_host_set_dhchap_host_key; nvme_host_get_hostsymname; @@ -117,8 +116,6 @@ LIBNVME_ACCESSORS_3 { nvme_fabric_options_set_host_iface; nvme_fabric_options_get_host_traddr; nvme_fabric_options_set_host_traddr; - nvme_fabric_options_get_hostid; - nvme_fabric_options_set_hostid; nvme_fabric_options_get_hostnqn; nvme_fabric_options_set_hostnqn; nvme_fabric_options_get_instance; diff --git a/libnvme/src/libnvme.ld b/libnvme/src/libnvme.ld index 2a34886af2..25688a5d57 100644 --- a/libnvme/src/libnvme.ld +++ b/libnvme/src/libnvme.ld @@ -42,9 +42,7 @@ LIBNVME_3 { nvme_free_ns; nvme_free_subsystem; nvme_gen_dhchap_key; - nvme_generate_hostid; nvme_generate_hostnqn; - nvme_generate_hostnqn_from_hostid; nvme_generate_tls_key_identity; nvme_generate_tls_key_identity_compat; nvme_get_ana_log_atomic; @@ -72,9 +70,9 @@ LIBNVME_3 { nvme_get_uuid_list; nvme_get_version; nvme_host_get_global_ctx; - nvme_host_get_ids; nvme_host_is_pdc_enabled; nvme_host_release_fds; + nvme_host_resolve_hostnqn; nvme_host_set_pdc_enabled; nvme_import_tls_key; nvme_import_tls_key_versioned; @@ -144,7 +142,6 @@ LIBNVME_3 { nvme_path_get_queue_depth; nvme_random_uuid; nvme_read_config; - nvme_read_hostid; nvme_read_hostnqn; nvme_read_key; nvme_read_nbft; diff --git a/libnvme/src/nvme/accessors.c b/libnvme/src/nvme/accessors.c index d3c507d7ed..fdefb09ffa 100644 --- a/libnvme/src/nvme/accessors.c +++ b/libnvme/src/nvme/accessors.c @@ -452,11 +452,6 @@ __public const char *nvme_host_get_hostnqn(const struct nvme_host *p) return p->hostnqn; } -__public const char *nvme_host_get_hostid(const struct nvme_host *p) -{ - return p->hostid; -} - __public void nvme_host_set_dhchap_host_key( struct nvme_host *p, const char *dhchap_host_key) @@ -668,19 +663,6 @@ __public bool nvme_fabric_options_get_host_traddr( return p->host_traddr; } -__public void nvme_fabric_options_set_hostid( - struct nvme_fabric_options *p, - bool hostid) -{ - p->hostid = hostid; -} - -__public bool nvme_fabric_options_get_hostid( - const struct nvme_fabric_options *p) -{ - return p->hostid; -} - __public void nvme_fabric_options_set_hostnqn( struct nvme_fabric_options *p, bool hostnqn) diff --git a/libnvme/src/nvme/accessors.h b/libnvme/src/nvme/accessors.h index 5c594dd127..44bb47dcf3 100644 --- a/libnvme/src/nvme/accessors.h +++ b/libnvme/src/nvme/accessors.h @@ -634,14 +634,6 @@ const char *nvme_subsystem_get_iopolicy(const struct nvme_subsystem *p); */ const char *nvme_host_get_hostnqn(const struct nvme_host *p); -/** - * nvme_host_get_hostid() - Get hostid. - * @p: The &struct nvme_host instance to query. - * - * Return: The value of the hostid field, or NULL if not set. - */ -const char *nvme_host_get_hostid(const struct nvme_host *p); - /** * nvme_host_set_dhchap_host_key() - Set dhchap_host_key. * @p: The &struct nvme_host instance to update. @@ -916,21 +908,6 @@ void nvme_fabric_options_set_host_traddr( */ bool nvme_fabric_options_get_host_traddr(const struct nvme_fabric_options *p); -/** - * nvme_fabric_options_set_hostid() - Set hostid. - * @p: The &struct nvme_fabric_options instance to update. - * @hostid: Value to assign to the hostid field. - */ -void nvme_fabric_options_set_hostid(struct nvme_fabric_options *p, bool hostid); - -/** - * nvme_fabric_options_get_hostid() - Get hostid. - * @p: The &struct nvme_fabric_options instance to query. - * - * Return: The value of the hostid field. - */ -bool nvme_fabric_options_get_hostid(const struct nvme_fabric_options *p); - /** * nvme_fabric_options_set_hostnqn() - Set hostnqn. * @p: The &struct nvme_fabric_options instance to update. diff --git a/libnvme/src/nvme/fabrics.c b/libnvme/src/nvme/fabrics.c index eb04eeba5f..f73a30ed28 100644 --- a/libnvme/src/nvme/fabrics.c +++ b/libnvme/src/nvme/fabrics.c @@ -275,10 +275,9 @@ __public int nvmf_context_set_connection(struct nvmf_context *fctx, } __public int nvmf_context_set_hostnqn(struct nvmf_context *fctx, - const char *hostnqn, const char *hostid) + const char *hostnqn) { fctx->hostnqn = hostnqn; - fctx->hostid = hostid; return 0; } @@ -706,9 +705,10 @@ static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr) { struct nvme_fabrics_config *cfg = nvme_ctrl_get_config(c); const char *transport = nvme_ctrl_get_transport(c); - const char *hostnqn, *hostid, *hostkey, *ctrlkey = NULL; + const char *hostnqn, *hostkey, *ctrlkey = NULL; bool discover = false, discovery_nqn = false; struct nvme_global_ctx *ctx = h->ctx; + _cleanup_free_ char *hostid = NULL; long keyring_id = 0; long key_id = 0; int ret; @@ -741,7 +741,7 @@ static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr) discover = true; hostnqn = nvme_host_get_hostnqn(h); - hostid = nvme_host_get_hostid(h); + hostid = nvme_hostid_from_hostnqn(hostnqn); hostkey = nvme_host_get_dhchap_host_key(h); if (!hostkey) hostkey = nvme_ctrl_get_dhchap_host_key(c); @@ -1453,9 +1453,10 @@ static void nvmf_fill_die(struct nvmf_ext_die *die, struct nvme_host *h, __u32 tel, __u8 trtype, __u8 adrfam, const char *reg_addr, union nvmf_tsas *tsas) { + _cleanup_free_ char *hostid = NULL; + struct nvmf_ext_attr *exat; __u16 numexat = 0; size_t symname_len; - struct nvmf_ext_attr *exat; die->tel = cpu_to_le32(tel); die->trtype = trtype; @@ -1472,7 +1473,9 @@ static void nvmf_fill_die(struct nvmf_ext_die *die, struct nvme_host *h, exat = die->exat; exat->exattype = cpu_to_le16(NVMF_EXATTYPE_HOSTID); exat->exatlen = cpu_to_le16(nvmf_exat_len(NVME_UUID_LEN)); - nvme_uuid_from_string(h->hostid, exat->exatval); + hostid = nvme_hostid_from_hostnqn(h->hostnqn); + if (hostid) + nvme_uuid_from_string(hostid, exat->exatval); /* Extended Attribute for the Symbolic Name (optional) */ symname_len = h->hostsymname ? strlen(h->hostsymname) : 0; @@ -1540,13 +1543,6 @@ static int nvmf_dim(nvme_ctrl_t c, enum nvmf_dim_tas tas, __u8 trtype, return -EINVAL; } - if (!c->s->h->hostid) { - nvme_msg(ctx, LOG_ERR, - "%s: failed to perform DIM. hostid undefined.\n", - c->name); - return -EINVAL; - } - if (!c->s->h->hostnqn) { nvme_msg(ctx, LOG_ERR, "%s: failed to perform DIM. hostnqn undefined.\n", @@ -1859,15 +1855,14 @@ static int lookup_host(struct nvme_global_ctx *ctx, struct nvmf_context *fctx, struct nvme_host **host) { _cleanup_free_ char *hnqn = NULL; - _cleanup_free_ char *hid = NULL; struct nvme_host *h; int err; - err = nvme_host_get_ids(ctx, fctx->hostnqn, fctx->hostid, &hnqn, &hid); + err = nvme_host_resolve_hostnqn(ctx, fctx->hostnqn, &hnqn); if (err < 0) return err; - h = nvme_lookup_host(ctx, hnqn, hid); + h = nvme_lookup_host(ctx, hnqn); if (!h) return -ENOMEM; @@ -2269,7 +2264,7 @@ int _discovery_config_json(struct nvme_global_ctx *ctx, __public int nvmf_discovery_config_json(struct nvme_global_ctx *ctx, struct nvmf_context *fctx, bool connect, bool force) { - const char *hnqn, *hid; + const char *hnqn; struct nvme_subsystem *s; struct nvme_host *h; struct nvme_ctrl *c; @@ -2289,10 +2284,6 @@ __public int nvmf_discovery_config_json(struct nvme_global_ctx *ctx, if (fctx->hostnqn && hnqn && strcmp(fctx->hostnqn, hnqn)) continue; - hid = nvme_host_get_hostid(h); - if (fctx->hostid && hid && - strcmp(fctx->hostid, hid)) - continue; nvme_subsystem_for_each_ctrl(s, c) { err = _discovery_config_json(ctx, fctx, h, c, @@ -2317,7 +2308,7 @@ __public int nvmf_discovery_config_json(struct nvme_global_ctx *ctx, __public int nvmf_connect_config_json(struct nvme_global_ctx *ctx, struct nvmf_context *fctx) { - const char *hnqn, *hid; + const char *hnqn; const char *transport; nvme_host_t h; nvme_subsystem_t s; @@ -2338,10 +2329,6 @@ __public int nvmf_connect_config_json(struct nvme_global_ctx *ctx, if (fctx->hostnqn && hnqn && strcmp(fctx->hostnqn, hnqn)) continue; - hid = nvme_host_get_hostid(h); - if (fctx->hostid && hid && - strcmp(fctx->hostid, hid)) - continue; nvme_subsystem_for_each_ctrl_safe(s, c, _c) { transport = nvme_ctrl_get_transport(c); @@ -2431,17 +2418,14 @@ __public int nvmf_config_modify(struct nvme_global_ctx *ctx, struct nvmf_context *fctx) { _cleanup_free_ char *hnqn = NULL; - _cleanup_free_ char *hid = NULL; struct nvme_host *h; struct nvme_subsystem *s; struct nvme_ctrl *c; if (!fctx->hostnqn) fctx->hostnqn = hnqn = nvme_read_hostnqn(); - if (!fctx->hostid && hnqn) - fctx->hostid = hid = nvme_read_hostid(); - h = nvme_lookup_host(ctx, fctx->hostnqn, fctx->hostid); + h = nvme_lookup_host(ctx, fctx->hostnqn); if (!h) { nvme_msg(ctx, LOG_ERR, "Failed to lookup host '%s'\n", fctx->hostnqn); @@ -2724,8 +2708,7 @@ static int nbft_discovery(struct nvme_global_ctx *ctx, __public int nvmf_discovery_nbft(struct nvme_global_ctx *ctx, struct nvmf_context *fctx, bool connect, char *nbft_path) { - const char *hostnqn = NULL, *hostid = NULL, *host_traddr = NULL; - char uuid[NVME_UUID_LEN_STRING]; + const char *host_traddr = NULL; struct nbft_file_entry *entry = NULL; struct nbft_info_subsystem_ns **ss; struct nbft_info_hfi *hfi; @@ -2756,25 +2739,23 @@ __public int nvmf_discovery_nbft(struct nvme_global_ctx *ctx, } for (; entry; entry = entry->next) { - if (fctx->hostnqn) - hostnqn = fctx->hostnqn; - else { - hostnqn = entry->nbft->host.nqn; - if (!hostnqn) - hostnqn = fctx->hostnqn; - } + _cleanup_free_ char *hostnqn = NULL; - if (fctx->hostid) - hostid = fctx->hostid; + if (fctx->hostnqn) + hostnqn = strdup(fctx->hostnqn); + else if (*entry->nbft->host.nqn) + hostnqn = strdup(entry->nbft->host.nqn); else if (*entry->nbft->host.id) { - ret = nvme_uuid_to_string(entry->nbft->host.id, uuid); - if (!ret) - hostid = uuid; - else - hostid = fctx->hostid; + char hostid_str[NVME_UUID_LEN_STRING]; + + ret = nvme_uuid_to_string(entry->nbft->host.id, + hostid_str); + if (ret < 0) + return -EINVAL; + hostnqn = nvme_hostnqn_from_hostid(hostid_str); } - h = nvme_lookup_host(ctx, hostnqn, hostid); + h = nvme_lookup_host(ctx, hostnqn); if (!h) { ret = -ENOENT; goto out_free; diff --git a/libnvme/src/nvme/fabrics.h b/libnvme/src/nvme/fabrics.h index bba27ab036..0329d336f9 100644 --- a/libnvme/src/nvme/fabrics.h +++ b/libnvme/src/nvme/fabrics.h @@ -460,17 +460,16 @@ int nvmf_context_set_connection(struct nvmf_context *fctx, const char *host_traddr, const char *host_iface); /** - * nvmf_context_set_hostnqn() - Set host NQN and host ID for context + * nvmf_context_set_hostnqn() - Set host NQN for context * @fctx: Fabrics context * @hostnqn: Host NQN - * @hostid: Host identifier * - * Sets the host NQN and host ID for the context. + * Sets the host NQN for the context. * * Return: 0 on success, or a negative error code on failure. */ int nvmf_context_set_hostnqn(struct nvmf_context *fctx, - const char *hostnqn, const char *hostid); + const char *hostnqn); /** * nvmf_context_set_crypto() - Set cryptographic parameters for context diff --git a/libnvme/src/nvme/json.c b/libnvme/src/nvme/json.c index f42f3a26e2..490a09e71d 100644 --- a/libnvme/src/nvme/json.c +++ b/libnvme/src/nvme/json.c @@ -160,17 +160,14 @@ static void json_parse_host(struct nvme_global_ctx *ctx, struct json_object *hos { struct json_object *attr_obj, *subsys_array, *subsys_obj; nvme_host_t h; - const char *hostnqn, *hostid = NULL; + const char *hostnqn; int s; attr_obj = json_object_object_get(host_obj, "hostnqn"); if (!attr_obj) return; hostnqn = json_object_get_string(attr_obj); - attr_obj = json_object_object_get(host_obj, "hostid"); - if (attr_obj) - hostid = json_object_get_string(attr_obj); - h = nvme_lookup_host(ctx, hostnqn, hostid); + h = nvme_lookup_host(ctx, hostnqn); attr_obj = json_object_object_get(host_obj, "dhchap_key"); if (attr_obj) nvme_host_set_dhchap_host_key(h, json_object_get_string(attr_obj)); @@ -391,7 +388,7 @@ int json_update_config(struct nvme_global_ctx *ctx, int fd) json_root = json_object_new_array(); nvme_for_each_host(ctx, h) { nvme_subsystem_t s; - const char *hostnqn, *hostid, *dhchap_key, *hostsymname; + const char *hostnqn, *dhchap_key, *hostsymname; host_obj = json_object_new_object(); if (!host_obj) @@ -399,10 +396,6 @@ int json_update_config(struct nvme_global_ctx *ctx, int fd) hostnqn = nvme_host_get_hostnqn(h); json_object_object_add(host_obj, "hostnqn", json_object_new_string(hostnqn)); - hostid = nvme_host_get_hostid(h); - if (hostid) - json_object_object_add(host_obj, "hostid", - json_object_new_string(hostid)); dhchap_key = nvme_host_get_dhchap_host_key(h); if (dhchap_key) json_object_object_add(host_obj, "dhchap_key", @@ -624,15 +617,11 @@ int json_dump_tree(struct nvme_global_ctx *ctx) host_array = json_object_new_array(); nvme_for_each_host(ctx, h) { nvme_subsystem_t s; - const char *hostid, *dhchap_key; + const char *dhchap_key; host_obj = json_object_new_object(); json_object_object_add(host_obj, "hostnqn", json_object_new_string(nvme_host_get_hostnqn(h))); - hostid = nvme_host_get_hostid(h); - if (hostid) - json_object_object_add(host_obj, "hostid", - json_object_new_string(hostid)); dhchap_key = nvme_host_get_dhchap_host_key(h); if (dhchap_key) json_object_object_add(host_obj, "dhchap_key", diff --git a/libnvme/src/nvme/linux.c b/libnvme/src/nvme/linux.c index 8189ce814a..c3383e6f69 100644 --- a/libnvme/src/nvme/linux.c +++ b/libnvme/src/nvme/linux.c @@ -1860,11 +1860,27 @@ static int uuid_from_dmi(char *system_uuid) return ret; } -__public char *nvme_generate_hostid(void) + +char *nvme_hostid_from_hostnqn(const char *hostnqn) +{ + const char *uuid; + + uuid = strstr(hostnqn, "uuid:"); + if (!uuid) + return NULL; + + return strdup(uuid + strlen("uuid:")); +} + +char *nvme_hostnqn_from_hostid(const char *hostid) { - int ret; char uuid_str[NVME_UUID_LEN_STRING]; unsigned char uuid[NVME_UUID_LEN]; + char *hostnqn; + int ret; + + if (hostid) + goto create_hostnqn; ret = uuid_from_dmi(uuid_str); if (ret < 0) @@ -1874,28 +1890,19 @@ __public char *nvme_generate_hostid(void) memset(uuid, 0, NVME_UUID_LEN); nvme_uuid_to_string(uuid, uuid_str); } + hostid = uuid_str; - return strdup(uuid_str); -} - -__public char *nvme_generate_hostnqn_from_hostid(char *hostid) -{ - char *hid = NULL; - char *hostnqn; - int ret; - - if (!hostid) - hostid = hid = nvme_generate_hostid(); - +create_hostnqn: ret = asprintf(&hostnqn, "nqn.2014-08.org.nvmexpress:uuid:%s", hostid); - free(hid); + if (ret < 0) + return NULL; - return (ret < 0) ? NULL : hostnqn; + return hostnqn; } __public char *nvme_generate_hostnqn(void) { - return nvme_generate_hostnqn_from_hostid(NULL); + return nvme_hostnqn_from_hostid(NULL); } static char *nvmf_read_file(const char *f, int len) @@ -1928,16 +1935,3 @@ __public char *nvme_read_hostnqn(void) return nvmf_read_file(NVMF_HOSTNQN_FILE, NVMF_NQN_SIZE); } - -__public char *nvme_read_hostid(void) -{ - char *hostid = getenv("LIBNVME_HOSTID"); - - if (hostid) { - if (!strcmp(hostid, "")) - return NULL; - return strdup(hostid); - } - - return nvmf_read_file(NVMF_HOSTID_FILE, NVMF_HOSTID_SIZE); -} diff --git a/libnvme/src/nvme/linux.h b/libnvme/src/nvme/linux.h index 91320352dc..e82d52bfaa 100644 --- a/libnvme/src/nvme/linux.h +++ b/libnvme/src/nvme/linux.h @@ -419,27 +419,6 @@ int nvme_import_tls_key_versioned(struct nvme_global_ctx *ctx, */ char *nvme_generate_hostnqn(void); -/** - * nvme_generate_hostnqn_from_hostid() - Generate a host nqn from - * host identifier - * @hostid: Host identifier - * - * If @hostid is NULL, the function generates it based on the machine - * identifier. - * - * Return: On success, an NVMe Qualified Name for host identification. This - * name is based on the given host identifier. On failure, NULL. - */ -char *nvme_generate_hostnqn_from_hostid(char *hostid); - -/** - * nvme_generate_hostid() - Generate a machine specific host identifier - * - * Return: On success, an identifier string based on the machine identifier to - * be used as NVMe Host Identifier, or NULL on failure. - */ -char *nvme_generate_hostid(void); - /** * nvme_read_hostnqn() - Reads the host nvm qualified name from the config * default location @@ -451,15 +430,3 @@ char *nvme_generate_hostid(void); * is responsible to free the string. */ char *nvme_read_hostnqn(void); - -/** - * nvme_read_hostid() - Reads the host identifier from the config default - * location - * - * Retrieve the host idenditifer from the config file located in - * $SYSCONFDIR/nvme/. $SYSCONFDIR is usually /etc. - * - * Return: The host identifier, or NULL if unsuccessful. If found, the caller - * is responsible to free the string. - */ -char *nvme_read_hostid(void); diff --git a/libnvme/src/nvme/private.h b/libnvme/src/nvme/private.h index c3651fb958..2470ea86e9 100644 --- a/libnvme/src/nvme/private.h +++ b/libnvme/src/nvme/private.h @@ -239,7 +239,6 @@ struct nvme_host { /*!generate-accessors*/ struct nvme_global_ctx *ctx; char *hostnqn; /*!accessors:readonly*/ - char *hostid; /*!accessors:readonly*/ char *dhchap_host_key; char *hostsymname; bool pdc_enabled; //!accessors:none @@ -261,8 +260,8 @@ struct nvme_fabric_options { /*!generate-accessors*/ bool hdr_digest; bool host_iface; bool host_traddr; - bool hostid; bool hostnqn; + bool hostid; /*!accessors:none*/ bool instance; bool keep_alive_tmo; bool keyring; @@ -350,7 +349,6 @@ struct nvmf_context { /* host configuration */ const char *hostnqn; - const char *hostid; /* authentication and transport encryption configuration */ const char *hostkey; @@ -392,8 +390,10 @@ void *__nvme_alloc(size_t len); void *__nvme_realloc(void *p, size_t len); -nvme_host_t nvme_lookup_host(struct nvme_global_ctx *ctx, const char *hostnqn, - const char *hostid); +char *nvme_hostnqn_from_hostid(const char *hostid); +char *nvme_hostid_from_hostnqn(const char *hostnqn); + +nvme_host_t nvme_lookup_host(struct nvme_global_ctx *ctx, const char *hostnqn); nvme_subsystem_t nvme_lookup_subsystem(struct nvme_host *h, const char *name, const char *subsysnqn); diff --git a/libnvme/src/nvme/tree.c b/libnvme/src/nvme/tree.c index 010dd3ce93..0f25389643 100644 --- a/libnvme/src/nvme/tree.c +++ b/libnvme/src/nvme/tree.c @@ -108,100 +108,50 @@ static void cleanup_dirents(struct dirents *ents) #define _cleanup_dirents_ __cleanup__(cleanup_dirents) -static char *nvme_hostid_from_hostnqn(const char *hostnqn) +__public int nvme_host_resolve_hostnqn(struct nvme_global_ctx *ctx, + const char *hostnqn_arg, char **hostnqn) { - const char *uuid; - - uuid = strstr(hostnqn, "uuid:"); - if (!uuid) - return NULL; - - return strdup(uuid + strlen("uuid:")); -} - -__public int nvme_host_get_ids(struct nvme_global_ctx *ctx, - const char *hostnqn_arg, const char *hostid_arg, - char **hostnqn, char **hostid) -{ - _cleanup_free_ char *nqn = NULL; - _cleanup_free_ char *hid = NULL; _cleanup_free_ char *hnqn = NULL; nvme_host_t h; /* command line argumments */ - if (hostid_arg) - hid = strdup(hostid_arg); if (hostnqn_arg) hnqn = strdup(hostnqn_arg); /* JSON config: assume the first entry is the default host */ h = nvme_first_host(ctx); - if (h) { - if (!hid) - hid = xstrdup(nvme_host_get_hostid(h)); - if (!hnqn) - hnqn = xstrdup(nvme_host_get_hostnqn(h)); - } + if (h && !hnqn) + hnqn = xstrdup(nvme_host_get_hostnqn(h)); - /* /etc/nvme/hostid and/or /etc/nvme/hostnqn */ - if (!hid) - hid = nvme_read_hostid(); + /* /etc/nvme/hostnqn */ if (!hnqn) hnqn = nvme_read_hostnqn(); - /* incomplete configuration, thus derive hostid from hostnqn */ - if (!hid && hnqn) - hid = nvme_hostid_from_hostnqn(hnqn); - - /* - * fallback to use either DMI information or device-tree. If all - * fails generate one - */ - if (!hid) { - hid = nvme_generate_hostid(); - if (!hid) - return -ENOMEM; - - nvme_msg(ctx, LOG_DEBUG, - "warning: using auto generated hostid and hostnqn\n"); - } - - /* incomplete configuration, thus derive hostnqn from hostid */ + /* no source has the hostnqn, generate one */ if (!hnqn) { - hnqn = nvme_generate_hostnqn_from_hostid(hid); + hnqn = nvme_generate_hostnqn(); if (!hnqn) return -ENOMEM; } - /* sanity checks */ - nqn = nvme_hostid_from_hostnqn(hnqn); - if (nqn && strcmp(nqn, hid)) { - nvme_msg(ctx, LOG_DEBUG, - "warning: use hostid '%s' which does not match uuid in hostnqn '%s'\n", - hid, hnqn); - } - - *hostid = hid; *hostnqn = hnqn; - hid = NULL; hnqn = NULL; return 0; } __public int nvme_get_host(struct nvme_global_ctx *ctx, const char *hostnqn, - const char *hostid, nvme_host_t *host) + nvme_host_t *host) { _cleanup_free_ char *hnqn = NULL; - _cleanup_free_ char *hid = NULL; struct nvme_host *h; int err; - err = nvme_host_get_ids(ctx, hostnqn, hostid, &hnqn, &hid); + err = nvme_host_resolve_hostnqn(ctx, hostnqn, &hnqn); if (err) return err; - h = nvme_lookup_host(ctx, hnqn, hid); + h = nvme_lookup_host(ctx, hnqn); if (!h) return -ENOMEM; @@ -601,7 +551,6 @@ void __nvme_free_host(struct nvme_host *h) nvme_for_each_subsystem_safe(h, s, _s) __nvme_free_subsystem(s); free(h->hostnqn); - free(h->hostid); free(h->dhchap_host_key); nvme_host_set_hostsymname(h, NULL); free(h); @@ -622,7 +571,7 @@ __public void nvme_free_host(struct nvme_host *h) } static int nvme_create_host(struct nvme_global_ctx *ctx, const char *hostnqn, - const char *hostid, struct nvme_host **host) + struct nvme_host **host) { struct nvme_host *h; @@ -631,8 +580,6 @@ static int nvme_create_host(struct nvme_global_ctx *ctx, const char *hostnqn, return -ENOMEM; h->hostnqn = strdup(hostnqn); - if (hostid) - h->hostid = strdup(hostid); list_head_init(&h->subsystems); list_node_init(&h->entry); h->ctx = ctx; @@ -645,7 +592,7 @@ static int nvme_create_host(struct nvme_global_ctx *ctx, const char *hostnqn, } struct nvme_host *nvme_lookup_host(struct nvme_global_ctx *ctx, - const char *hostnqn, const char *hostid) + const char *hostnqn) { struct nvme_host *h; @@ -655,13 +602,10 @@ struct nvme_host *nvme_lookup_host(struct nvme_global_ctx *ctx, nvme_for_each_host(ctx, h) { if (strcmp(h->hostnqn, hostnqn)) continue; - if (hostid && (!h->hostid || - strcmp(h->hostid, hostid))) - continue; return h; } - if (nvme_create_host(ctx, hostnqn, hostid, &h)) + if (nvme_create_host(ctx, hostnqn, &h)) return NULL; return h; @@ -765,7 +709,7 @@ static int nvme_scan_subsystem(struct nvme_global_ctx *ctx, const char *name) */ nvme_msg(ctx, LOG_DEBUG, "creating detached subsystem '%s'\n", name); - ret = nvme_get_host(ctx, NULL, NULL, &h); + ret = nvme_get_host(ctx, NULL, &h); if (ret) return ret; s = nvme_alloc_subsystem(h, name, subsysnqn); @@ -1933,7 +1877,7 @@ __public int nvme_scan_ctrl(struct nvme_global_ctx *ctx, const char *name, nvme_ctrl_t *cp) { _cleanup_free_ char *subsysnqn = NULL, *subsysname = NULL; - _cleanup_free_ char *hostnqn = NULL, *hostid = NULL; + _cleanup_free_ char *hostnqn = NULL; _cleanup_free_ char *path = NULL; char *host_key; nvme_host_t h; @@ -1947,8 +1891,7 @@ __public int nvme_scan_ctrl(struct nvme_global_ctx *ctx, const char *name, return -ENOMEM; hostnqn = nvme_get_attr(path, "hostnqn"); - hostid = nvme_get_attr(path, "hostid"); - ret = nvme_get_host(ctx, hostnqn, hostid, &h); + ret = nvme_get_host(ctx, hostnqn, &h); if (ret) return ret; diff --git a/libnvme/src/nvme/tree.h b/libnvme/src/nvme/tree.h index 07b75677cd..9b1c0dff45 100644 --- a/libnvme/src/nvme/tree.h +++ b/libnvme/src/nvme/tree.h @@ -117,51 +117,42 @@ bool nvme_host_is_pdc_enabled(nvme_host_t h, bool fallback); * nvme_get_host() - Returns a host object * @ctx: struct nvme_global_ctx object * @hostnqn: Host NQN (optional) - * @hostid: Host ID (optional) * @h: &nvme_host_t object to return * - * Returns a host object based on the hostnqn/hostid values or the default if - * hostnqn/hostid are NULL. + * Returns a host object based on the hostnqn value or the default if + * hostnqn is NULL. * * Return: 0 on success or negative error code otherwise */ int nvme_get_host(struct nvme_global_ctx *ctx, const char *hostnqn, - const char *hostid, nvme_host_t *h); + nvme_host_t *h); /** - * nvme_host_get_ids - Retrieve host ids from various sources + * nvme_host_resolve_hostnqn - Resolve hostnqn from various sources * * @ctx: struct nvme_global_ctx object * @hostnqn_arg: Input hostnqn (command line) argument - * @hostid_arg: Input hostid (command line) argument * @hostnqn: Output hostnqn - * @hostid: Output hostid * - * nvme_host_get_ids figures out which hostnqn/hostid is to be used. - * There are several sources where this information can be retrieved. + * nvme_host_resolve_hostnqn figures out which hostnqn is to be used. + * There are several sources where this information can be resolved. * * The order is: * * - Start with informartion from DMI or device-tree - * - Override hostnqn and hostid from /etc/nvme files - * - Override hostnqn or hostid with values from JSON - * configuration file. The first host entry in the file is - * considered the default host. - * - Override hostnqn or hostid with values from the command line - * (@hostnqn_arg, @hostid_arg). + * - Override hostnqn from the /etc/nvme/hostnqn file + * - Override hostnqn value from JSON configuration file. + * The first host entry in the file is considered the default host. + * - Override hostnqn value from the command line @hostnqn_arg. * - * If the IDs are still NULL after the lookup algorithm, the function - * will generate random IDs. + * If the hostnqn is still NULL after the lookup algorithm, the function + * will generate a random hostnqn. * - * The function also verifies that hostnqn and hostid matches. The Linux - * NVMe implementation expects a 1:1 matching between the IDs. - * - * Return: 0 on success (@hostnqn and @hostid contain valid strings + * Return: 0 on success (@hostnqn will contain a valid string * which the caller needs to free), or negative error code otherwise. */ -int nvme_host_get_ids(struct nvme_global_ctx *ctx, - const char *hostnqn_arg, const char *hostid_arg, - char **hostnqn, char **hostid); +int nvme_host_resolve_hostnqn(struct nvme_global_ctx *ctx, + const char *hostnqn_arg, char **hostnqn); /** * nvme_first_subsystem() - Start subsystem iterator diff --git a/libnvme/test/config/data/config-pcie-with-tcp-config.out b/libnvme/test/config/data/config-pcie-with-tcp-config.out index 6810f75462..92f734c8f2 100644 --- a/libnvme/test/config/data/config-pcie-with-tcp-config.out +++ b/libnvme/test/config/data/config-pcie-with-tcp-config.out @@ -1,7 +1,6 @@ [ { "hostnqn":"nqn.2014-08.org.nvmexpress:uuid:2cd2c43b-a90a-45c1-a8cd-86b33ab273b5", - "hostid":"2cd2c43b-a90a-45c1-a8cd-86b33ab273b5", "subsystems":[ { "nqn":"nqn.io-1", @@ -24,7 +23,6 @@ }, { "hostnqn":"nqn.2014-08.org.nvmexpress:uuid:befdec4c-2234-11b2-a85c-ca77c773af36", - "hostid":"befdec4c-2234-11b2-a85c-ca77c773af36", "subsystems":[ { "nqn":"nqn.io-1", diff --git a/libnvme/test/config/data/hostnqn-order.json b/libnvme/test/config/data/hostnqn-order.json index 6810f75462..92f734c8f2 100644 --- a/libnvme/test/config/data/hostnqn-order.json +++ b/libnvme/test/config/data/hostnqn-order.json @@ -1,7 +1,6 @@ [ { "hostnqn":"nqn.2014-08.org.nvmexpress:uuid:2cd2c43b-a90a-45c1-a8cd-86b33ab273b5", - "hostid":"2cd2c43b-a90a-45c1-a8cd-86b33ab273b5", "subsystems":[ { "nqn":"nqn.io-1", @@ -24,7 +23,6 @@ }, { "hostnqn":"nqn.2014-08.org.nvmexpress:uuid:befdec4c-2234-11b2-a85c-ca77c773af36", - "hostid":"befdec4c-2234-11b2-a85c-ca77c773af36", "subsystems":[ { "nqn":"nqn.io-1", diff --git a/libnvme/test/config/data/tls_key-1.out b/libnvme/test/config/data/tls_key-1.out index 5bba948d97..379ad64f58 100644 --- a/libnvme/test/config/data/tls_key-1.out +++ b/libnvme/test/config/data/tls_key-1.out @@ -1,7 +1,6 @@ [ { "hostnqn":"nqn.2014-08.org.nvmexpress:uuid:befdec4c-2234-11b2-a85c-ca77c773af36", - "hostid":"2cd2c43b-a90a-45c1-a8cd-86b33ab273b6", "subsystems":[ { "nqn":"nqn.io-1", diff --git a/libnvme/test/config/data/tls_key-2.out b/libnvme/test/config/data/tls_key-2.out index 5bba948d97..379ad64f58 100644 --- a/libnvme/test/config/data/tls_key-2.out +++ b/libnvme/test/config/data/tls_key-2.out @@ -1,7 +1,6 @@ [ { "hostnqn":"nqn.2014-08.org.nvmexpress:uuid:befdec4c-2234-11b2-a85c-ca77c773af36", - "hostid":"2cd2c43b-a90a-45c1-a8cd-86b33ab273b6", "subsystems":[ { "nqn":"nqn.io-1", diff --git a/libnvme/test/config/hostnqn-order.c b/libnvme/test/config/hostnqn-order.c index 7500b96675..e890f23791 100644 --- a/libnvme/test/config/hostnqn-order.c +++ b/libnvme/test/config/hostnqn-order.c @@ -16,7 +16,7 @@ static bool command_line(void) struct nvme_global_ctx *ctx; bool pass = false; int err; - char *hostnqn, *hostid, *hnqn, *hid; + char *hostnqn, *hnqn; ctx = nvme_create_global_ctx(stderr, LOG_ERR); if (!ctx) @@ -27,9 +27,8 @@ static bool command_line(void) goto out; hostnqn = "nqn.2014-08.org.nvmexpress:uuid:ce4fee3e-c02c-11ee-8442-830d068a36c6"; - hostid = "ce4fee3e-c02c-11ee-8442-830d068a36c6"; - err = nvme_host_get_ids(ctx, hostnqn, hostid, &hnqn, &hid); + err = nvme_host_resolve_hostnqn(ctx, hostnqn, &hnqn); if (err) goto out; @@ -37,13 +36,8 @@ static bool command_line(void) printf("json config hostnqn '%s' does not match '%s'\n", hostnqn, hnqn); goto out; } - if (strcmp(hostid, hid)) { - printf("json config hostid '%s' does not match '%s'\n", hostid, hid); - goto out; - } free(hnqn); - free(hid); pass = true; @@ -57,10 +51,9 @@ static bool json_config(char *file) struct nvme_global_ctx *ctx; bool pass = false; int err; - char *hostnqn, *hostid, *hnqn, *hid; + char *hostnqn, *hnqn; setenv("LIBNVME_HOSTNQN", "", 1); - setenv("LIBNVME_HOSTID", "", 1); ctx = nvme_create_global_ctx(stderr, LOG_ERR); if (!ctx) @@ -76,9 +69,8 @@ static bool json_config(char *file) goto out; hostnqn = "nqn.2014-08.org.nvmexpress:uuid:2cd2c43b-a90a-45c1-a8cd-86b33ab273b5"; - hostid = "2cd2c43b-a90a-45c1-a8cd-86b33ab273b5"; - err = nvme_host_get_ids(ctx, NULL, NULL, &hnqn, &hid); + err = nvme_host_resolve_hostnqn(ctx, NULL, &hnqn); if (err) goto out; @@ -86,13 +78,8 @@ static bool json_config(char *file) printf("json config hostnqn '%s' does not match '%s'\n", hostnqn, hnqn); goto out; } - if (strcmp(hostid, hid)) { - printf("json config hostid '%s' does not match '%s'\n", hostid, hid); - goto out; - } free(hnqn); - free(hid); pass = true; @@ -106,13 +93,11 @@ static bool from_file(void) struct nvme_global_ctx *ctx; bool pass = false; int err; - char *hostnqn, *hostid, *hnqn, *hid; + char *hostnqn, *hnqn; hostnqn = "nqn.2014-08.org.nvmexpress:uuid:ce4fee3e-c02c-11ee-8442-830d068a36c6"; - hostid = "ce4fee3e-c02c-11ee-8442-830d068a36c6"; setenv("LIBNVME_HOSTNQN", hostnqn, 1); - setenv("LIBNVME_HOSTID", hostid, 1); ctx = nvme_create_global_ctx(stderr, LOG_ERR); if (!ctx) @@ -122,7 +107,7 @@ static bool from_file(void) if (err && err != ENOENT) goto out; - err = nvme_host_get_ids(ctx, NULL, NULL, &hnqn, &hid); + err = nvme_host_resolve_hostnqn(ctx, NULL, &hnqn); if (err) goto out; @@ -130,13 +115,8 @@ static bool from_file(void) printf("json config hostnqn '%s' does not match '%s'\n", hostnqn, hnqn); goto out; } - if (strcmp(hostid, hid)) { - printf("json config hostid '%s' does not match '%s'\n", hostid, hid); - goto out; - } free(hnqn); - free(hid); pass = true; diff --git a/libnvme/test/sysfs/data/tree-apple-nvme.out b/libnvme/test/sysfs/data/tree-apple-nvme.out index 9207575ad7..74b21c983f 100644 --- a/libnvme/test/sysfs/data/tree-apple-nvme.out +++ b/libnvme/test/sysfs/data/tree-apple-nvme.out @@ -2,7 +2,6 @@ "hosts":[ { "hostnqn":"nqn.2014-08.org.nvmexpress:uuid:ce4fee3e-c02c-11ee-8442-830d068a36c6", - "hostid":"ce4fee3e-c02c-11ee-8442-830d068a36c6", "subsystems":[ { "name":"nvme-subsys0", diff --git a/libnvme/test/sysfs/data/tree-pcie.out b/libnvme/test/sysfs/data/tree-pcie.out index 8ea175a6d3..8826f13c89 100644 --- a/libnvme/test/sysfs/data/tree-pcie.out +++ b/libnvme/test/sysfs/data/tree-pcie.out @@ -2,7 +2,6 @@ "hosts":[ { "hostnqn":"nqn.2014-08.org.nvmexpress:uuid:ce4fee3e-c02c-11ee-8442-830d068a36c6", - "hostid":"ce4fee3e-c02c-11ee-8442-830d068a36c6", "subsystems":[ { "name":"nvme-subsys0", diff --git a/libnvme/test/tree.c b/libnvme/test/tree.c index 6bb23a2b7b..316df76e11 100644 --- a/libnvme/test/tree.c +++ b/libnvme/test/tree.c @@ -26,7 +26,6 @@ struct test_data { int ctrl_id; }; -#define DEFAULT_HOSTID "9ba1651a-ed36-11f0-9858-6c1ff71ba506" #define DEFAULT_HOSTNQN "nqn.2014-08.org.nvmexpress:uuid:9ba1651a-ed36-11f0-9858-6c1ff71ba506" #define DEFAULT_SUBSYSNAME "subsysname" #define DEFAULT_SUBSYSNQN "subsysnqn" @@ -130,7 +129,7 @@ static struct nvme_global_ctx *create_tree() ctx = nvme_create_global_ctx(stdout, LOG_DEBUG); assert(ctx); - nvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); + nvme_get_host(ctx, DEFAULT_HOSTNQN, &h); assert(h); printf(" ctrls created:\n"); @@ -299,7 +298,7 @@ static bool test_src_addr() ctx = nvme_create_global_ctx(stdout, LOG_DEBUG); assert(ctx); - nvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); + nvme_get_host(ctx, DEFAULT_HOSTNQN, &h); assert(h); nvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, DEFAULT_SUBSYSNQN, &s); @@ -470,7 +469,7 @@ static bool ctrl_match(const char *tag, ctx = nvme_create_global_ctx(stdout, LOG_INFO); assert(ctx); - nvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); + nvme_get_host(ctx, DEFAULT_HOSTNQN, &h); assert(h); assert(!nvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, @@ -1092,7 +1091,7 @@ static bool ctrl_config_match(const char *tag, ctx = nvme_create_global_ctx(stdout, LOG_INFO); assert(ctx); - nvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); + nvme_get_host(ctx, DEFAULT_HOSTNQN, &h); assert(h); assert(!nvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, diff --git a/nvme-print-json.c b/nvme-print-json.c index 17b1c37183..90f517b00e 100644 --- a/nvme-print-json.c +++ b/nvme-print-json.c @@ -2717,13 +2717,9 @@ static void json_print_nvme_subsystem_list(struct nvme_global_ctx *ctx, nvme_for_each_host(ctx, h) { nvme_subsystem_t s; - const char *hostid; host_attrs = json_create_object(); obj_add_str(host_attrs, "HostNQN", nvme_host_get_hostnqn(h)); - hostid = nvme_host_get_hostid(h); - if (hostid) - obj_add_str(host_attrs, "HostID", hostid); subsystems = json_create_array(); nvme_for_each_subsystem(h, s) { nvme_ctrl_t c; @@ -4717,12 +4713,8 @@ static void json_detail_list_v2(struct nvme_global_ctx *ctx) nvme_for_each_host(ctx, h) { struct json_object *hss = json_create_object(); struct json_object *jsslist = json_create_array(); - const char *hostid; obj_add_str(hss, "HostNQN", nvme_host_get_hostnqn(h)); - hostid = nvme_host_get_hostid(h); - if (hostid) - obj_add_str(hss, "HostID", hostid); nvme_for_each_subsystem(h, s) { struct json_object *jss = json_create_object(); @@ -4761,12 +4753,8 @@ static void json_detail_list(struct nvme_global_ctx *ctx) nvme_for_each_host(ctx, h) { struct json_object *hss = json_create_object(); struct json_object *jsslist = json_create_array(); - const char *hostid; obj_add_str(hss, "HostNQN", nvme_host_get_hostnqn(h)); - hostid = nvme_host_get_hostid(h); - if (hostid) - obj_add_str(hss, "HostID", hostid); nvme_for_each_subsystem(h, s) { struct json_object *jss = json_create_object(); @@ -5025,13 +5013,9 @@ static void json_simple_topology(struct nvme_global_ctx *ctx) nvme_for_each_host(ctx, h) { nvme_subsystem_t s; - const char *hostid; host_attrs = json_create_object(); obj_add_str(host_attrs, "HostNQN", nvme_host_get_hostnqn(h)); - hostid = nvme_host_get_hostid(h); - if (hostid) - obj_add_str(host_attrs, "HostID", hostid); subsystems = json_create_array(); nvme_for_each_subsystem(h, s) { subsystem_attrs = json_create_object();