Skip to content

Commit 1255a97

Browse files
committed
libnvme: drop support for hostid config
The NVMe subsystem of Linux expects a 1:1 mapping of the hostnqn to hostid. There is no point in exposing the hostid argument through all public APIs. To ensure backward compatibility, always set the hostid extracted from the hostnqn when building the connect string. This matches the default behavior prior to removing hostid from the API. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 27af156 commit 1255a97

26 files changed

Lines changed: 121 additions & 354 deletions

fabrics.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static const char *nvmf_trsvcid = "transport service id (e.g. IP port)";
7070
static const char *nvmf_htraddr = "host traddr (e.g. FC WWN's)";
7171
static const char *nvmf_hiface = "host interface (for tcp transport)";
7272
static const char *nvmf_hostnqn = "user-defined hostnqn";
73-
static const char *nvmf_hostid = "user-defined hostid (if default not used)";
73+
static const char *nvmf_hostid = "(deprecated and ignored)";
7474
static const char *nvmf_hostkey = "user-defined dhchap key (if default not used)";
7575
static const char *nvmf_ctrlkey = "user-defined dhchap controller key (for bi-directional authentication)";
7676
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,
334334
return err;
335335

336336
err = nvmf_context_set_hostnqn(fctx,
337-
fa->hostnqn, fa->hostid);
337+
fa->hostnqn);
338338
if (err)
339339
return err;
340340

@@ -367,7 +367,7 @@ static int create_common_context(struct nvme_global_ctx *ctx,
367367
if (err)
368368
goto err;
369369

370-
err = nvmf_context_set_hostnqn(fctx, fa->hostnqn, fa->hostid);
370+
err = nvmf_context_set_hostnqn(fctx, fa->hostnqn);
371371
if (err)
372372
goto err;
373373

libnvme/doc/config-schema.json.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
"type": "string",
2222
"maxLength": 223
2323
},
24-
"hostid": {
25-
"description": "NVMe host ID",
26-
"type": "string"
27-
},
2824
"dhchap_key": {
2925
"description": "Host DH-HMAC-CHAP key",
3026
"type": "string"

libnvme/examples/discover-loop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int main()
6969
nvme_free_global_ctx(ctx);
7070
return 1;
7171
}
72-
ret = nvme_get_host(ctx, NULL, NULL, &h);
72+
ret = nvme_get_host(ctx, NULL, &h);
7373
if (ret) {
7474
fprintf(stderr, "Failed to allocated memory\n");
7575
return 1;

libnvme/libnvme/nvme.i

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,8 @@
4444
free(val);
4545
return obj;
4646
}
47-
PyObject *read_hostid() {
48-
char * val = nvme_read_hostid();
49-
PyObject * obj = val ? PyUnicode_FromString(val) : Py_NewRef(Py_None);
50-
free(val);
51-
return obj;
52-
}
5347
%}
5448
PyObject *read_hostnqn();
55-
PyObject *read_hostid();
5649

5750
%exception nvme_ctrl::connect {
5851
connect_err = 0;
@@ -363,10 +356,8 @@ struct nvme_global_ctx {
363356

364357
struct nvme_host {
365358
%immutable hostnqn;
366-
%immutable hostid;
367359
%immutable hostsymname;
368360
char *hostnqn;
369-
char *hostid;
370361
char *hostsymname;
371362
%extend {
372363
char *dhchap_host_key;
@@ -546,18 +537,16 @@ struct nvme_ns {
546537

547538
%pythonappend nvme_host::nvme_host(struct nvme_global_ctx *ctx,
548539
const char *hostnqn,
549-
const char *hostid,
550540
const char *hostkey,
551541
const char *hostsymname) {
552542
self.__parent = ctx # Keep a reference to parent to ensure garbage collection happens in the right order}
553543
%extend nvme_host {
554544
nvme_host(struct nvme_global_ctx *ctx,
555545
const char *hostnqn = NULL,
556-
const char *hostid = NULL,
557546
const char *hostkey = NULL,
558547
const char *hostsymname = NULL) {
559548
nvme_host_t h;
560-
if (nvme_get_host(ctx, hostnqn, hostid, &h))
549+
if (nvme_get_host(ctx, hostnqn, &h))
561550
return NULL;
562551
if (hostsymname)
563552
nvme_host_set_hostsymname(h, hostsymname);
@@ -580,7 +569,7 @@ struct nvme_ns {
580569
}
581570

582571
PyObject* __str__() {
583-
return PyUnicode_FromFormat("nvme.host(%s,%s)", STR_OR_NONE($self->hostnqn), STR_OR_NONE($self->hostid));
572+
return PyUnicode_FromFormat("nvme.host(%s)", STR_OR_NONE($self->hostnqn));
584573
}
585574
%pythoncode %{
586575
def subsystems(self):

libnvme/libnvme/tests/test-objects.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,6 @@ def test_creation_with_explicit_hostnqn(self):
6969
self.assertIsNotNone(host)
7070
self.assertEqual(host.hostnqn, hostnqn)
7171

72-
def test_creation_with_hostnqn_and_hostid(self):
73-
hostnqn = 'nqn.2014-08.com.example:test-host-props'
74-
hostid = '11111111-2222-3333-4444-555555555555'
75-
host = nvme.host(self.ctx, hostnqn=hostnqn, hostid=hostid)
76-
self.assertEqual(host.hostnqn, hostnqn)
77-
self.assertEqual(host.hostid, hostid)
78-
7972
def test_creation_with_hostsymname(self):
8073
hostnqn = 'nqn.2014-08.com.example:test-host-symname'
8174
symname = 'my-storage-host'
@@ -248,10 +241,6 @@ def test_read_hostnqn_returns_string_or_none(self):
248241
hostnqn = nvme.read_hostnqn()
249242
self.assertIsInstance(hostnqn, (str, type(None)))
250243

251-
def test_read_hostid_returns_string_or_none(self):
252-
hostid = nvme.read_hostid()
253-
self.assertIsInstance(hostid, (str, type(None)))
254-
255244

256245
if __name__ == '__main__':
257246
unittest.main()

libnvme/src/accessors.ld

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ LIBNVME_ACCESSORS_3 {
8484
nvme_subsystem_get_iopolicy;
8585
nvme_subsystem_set_iopolicy;
8686
nvme_host_get_hostnqn;
87-
nvme_host_get_hostid;
8887
nvme_host_get_dhchap_host_key;
8988
nvme_host_set_dhchap_host_key;
9089
nvme_host_get_hostsymname;

libnvme/src/libnvme.ld

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ LIBNVME_3 {
4242
nvme_free_ns;
4343
nvme_free_subsystem;
4444
nvme_gen_dhchap_key;
45-
nvme_generate_hostid;
4645
nvme_generate_hostnqn;
47-
nvme_generate_hostnqn_from_hostid;
4846
nvme_generate_tls_key_identity;
4947
nvme_generate_tls_key_identity_compat;
5048
nvme_get_ana_log_atomic;
@@ -72,9 +70,9 @@ LIBNVME_3 {
7270
nvme_get_uuid_list;
7371
nvme_get_version;
7472
nvme_host_get_global_ctx;
75-
nvme_host_get_ids;
7673
nvme_host_is_pdc_enabled;
7774
nvme_host_release_fds;
75+
nvme_host_resolve_hostnqn;
7876
nvme_host_set_pdc_enabled;
7977
nvme_import_tls_key;
8078
nvme_import_tls_key_versioned;
@@ -144,7 +142,6 @@ LIBNVME_3 {
144142
nvme_path_get_queue_depth;
145143
nvme_random_uuid;
146144
nvme_read_config;
147-
nvme_read_hostid;
148145
nvme_read_hostnqn;
149146
nvme_read_key;
150147
nvme_read_nbft;

libnvme/src/nvme/accessors.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,6 @@ __public const char *nvme_host_get_hostnqn(const struct nvme_host *p)
452452
return p->hostnqn;
453453
}
454454

455-
__public const char *nvme_host_get_hostid(const struct nvme_host *p)
456-
{
457-
return p->hostid;
458-
}
459-
460455
__public void nvme_host_set_dhchap_host_key(
461456
struct nvme_host *p,
462457
const char *dhchap_host_key)
@@ -668,30 +663,30 @@ __public bool nvme_fabric_options_get_host_traddr(
668663
return p->host_traddr;
669664
}
670665

671-
__public void nvme_fabric_options_set_hostid(
666+
__public void nvme_fabric_options_set_hostnqn(
672667
struct nvme_fabric_options *p,
673-
bool hostid)
668+
bool hostnqn)
674669
{
675-
p->hostid = hostid;
670+
p->hostnqn = hostnqn;
676671
}
677672

678-
__public bool nvme_fabric_options_get_hostid(
673+
__public bool nvme_fabric_options_get_hostnqn(
679674
const struct nvme_fabric_options *p)
680675
{
681-
return p->hostid;
676+
return p->hostnqn;
682677
}
683678

684-
__public void nvme_fabric_options_set_hostnqn(
679+
__public void nvme_fabric_options_set_hostid(
685680
struct nvme_fabric_options *p,
686-
bool hostnqn)
681+
bool hostid)
687682
{
688-
p->hostnqn = hostnqn;
683+
p->hostid = hostid;
689684
}
690685

691-
__public bool nvme_fabric_options_get_hostnqn(
686+
__public bool nvme_fabric_options_get_hostid(
692687
const struct nvme_fabric_options *p)
693688
{
694-
return p->hostnqn;
689+
return p->hostid;
695690
}
696691

697692
__public void nvme_fabric_options_set_instance(

libnvme/src/nvme/accessors.h

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -634,14 +634,6 @@ const char *nvme_subsystem_get_iopolicy(const struct nvme_subsystem *p);
634634
*/
635635
const char *nvme_host_get_hostnqn(const struct nvme_host *p);
636636

637-
/**
638-
* nvme_host_get_hostid() - Get hostid.
639-
* @p: The &struct nvme_host instance to query.
640-
*
641-
* Return: The value of the hostid field, or NULL if not set.
642-
*/
643-
const char *nvme_host_get_hostid(const struct nvme_host *p);
644-
645637
/**
646638
* nvme_host_set_dhchap_host_key() - Set dhchap_host_key.
647639
* @p: The &struct nvme_host instance to update.
@@ -917,36 +909,36 @@ void nvme_fabric_options_set_host_traddr(
917909
bool nvme_fabric_options_get_host_traddr(const struct nvme_fabric_options *p);
918910

919911
/**
920-
* nvme_fabric_options_set_hostid() - Set hostid.
912+
* nvme_fabric_options_set_hostnqn() - Set hostnqn.
921913
* @p: The &struct nvme_fabric_options instance to update.
922-
* @hostid: Value to assign to the hostid field.
914+
* @hostnqn: Value to assign to the hostnqn field.
923915
*/
924-
void nvme_fabric_options_set_hostid(struct nvme_fabric_options *p, bool hostid);
916+
void nvme_fabric_options_set_hostnqn(
917+
struct nvme_fabric_options *p,
918+
bool hostnqn);
925919

926920
/**
927-
* nvme_fabric_options_get_hostid() - Get hostid.
921+
* nvme_fabric_options_get_hostnqn() - Get hostnqn.
928922
* @p: The &struct nvme_fabric_options instance to query.
929923
*
930-
* Return: The value of the hostid field.
924+
* Return: The value of the hostnqn field.
931925
*/
932-
bool nvme_fabric_options_get_hostid(const struct nvme_fabric_options *p);
926+
bool nvme_fabric_options_get_hostnqn(const struct nvme_fabric_options *p);
933927

934928
/**
935-
* nvme_fabric_options_set_hostnqn() - Set hostnqn.
929+
* nvme_fabric_options_set_hostid() - Set hostid.
936930
* @p: The &struct nvme_fabric_options instance to update.
937-
* @hostnqn: Value to assign to the hostnqn field.
931+
* @hostid: Value to assign to the hostid field.
938932
*/
939-
void nvme_fabric_options_set_hostnqn(
940-
struct nvme_fabric_options *p,
941-
bool hostnqn);
933+
void nvme_fabric_options_set_hostid(struct nvme_fabric_options *p, bool hostid);
942934

943935
/**
944-
* nvme_fabric_options_get_hostnqn() - Get hostnqn.
936+
* nvme_fabric_options_get_hostid() - Get hostid.
945937
* @p: The &struct nvme_fabric_options instance to query.
946938
*
947-
* Return: The value of the hostnqn field.
939+
* Return: The value of the hostid field.
948940
*/
949-
bool nvme_fabric_options_get_hostnqn(const struct nvme_fabric_options *p);
941+
bool nvme_fabric_options_get_hostid(const struct nvme_fabric_options *p);
950942

951943
/**
952944
* nvme_fabric_options_set_instance() - Set instance.

0 commit comments

Comments
 (0)