Skip to content

Commit 4527e14

Browse files
sagigrimbergkeithbusch
authored andcommitted
nvme-print: list also hostnqn and hostid for verbose
Add it to the json output as the normal display is crowded enough as it is. Note that we print them only if they exist in sysfs which gives us backward compatibility (as hostnqn and hostid are still new). Signed-off-by: Sagi Grimberg <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 6ad4308 commit 4527e14

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

nvme-print.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4543,6 +4543,10 @@ static void json_detail_list(struct nvme_topology *t)
45434543
json_object_add_value_string(ctrl_attrs, "Transport", c->transport);
45444544
json_object_add_value_string(ctrl_attrs, "Address", c->address);
45454545
json_object_add_value_string(ctrl_attrs, "State", c->state);
4546+
if (c->hostnqn)
4547+
json_object_add_value_string(ctrl_attrs, "HostNQN", c->hostnqn);
4548+
if (c->hostid)
4549+
json_object_add_value_string(ctrl_attrs, "HostID", c->hostid);
45464550

45474551
format(formatter, sizeof(formatter), c->id.fr, sizeof(c->id.fr));
45484552
json_object_add_value_string(ctrl_attrs, "Firmware", formatter);

nvme-topology.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ static int scan_ctrl(struct nvme_ctrl *c, char *p, __u32 ns_instance)
192192
c->address = nvme_get_ctrl_attr(path, "address");
193193
c->transport = nvme_get_ctrl_attr(path, "transport");
194194
c->state = nvme_get_ctrl_attr(path, "state");
195+
c->hostnqn = nvme_get_ctrl_attr(path, "hostnqn");
196+
c->hostid = nvme_get_ctrl_attr(path, "hostid");
195197

196198
if (ns_instance)
197199
c->ana_state = get_nvme_ctrl_path_ana_state(path, ns_instance);
@@ -403,6 +405,8 @@ static void free_ctrl(struct nvme_ctrl *c)
403405
free(c->transport);
404406
free(c->address);
405407
free(c->state);
408+
free(c->hostnqn);
409+
free(c->hostid);
406410
free(c->ana_state);
407411
free(c->namespaces);
408412
}

nvme.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ struct nvme_ctrl {
5555
char *traddr;
5656
char *trsvcid;
5757
char *host_traddr;
58+
char *hostnqn;
59+
char *hostid;
5860

5961
struct nvme_id_ctrl id;
6062

0 commit comments

Comments
 (0)