]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
nvme-print: list also hostnqn and hostid for verbose
authorSagi Grimberg <sagi@grimberg.me>
Tue, 24 Mar 2020 08:53:27 +0000 (01:53 -0700)
committerKeith Busch <kbusch@kernel.org>
Wed, 1 Apr 2020 19:40:47 +0000 (12:40 -0700)
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 <sagi@grimberg.me>
Signed-off-by: Keith Busch <kbusch@kernel.org>
nvme-print.c
nvme-topology.c
nvme.h

index c63de13c99429d62fe2148c1efcd0c37892a09ed..51f884917c52fa0ce2e27428ba999bd568638c41 100644 (file)
@@ -4543,6 +4543,10 @@ static void json_detail_list(struct nvme_topology *t)
                        json_object_add_value_string(ctrl_attrs, "Transport", c->transport);
                        json_object_add_value_string(ctrl_attrs, "Address", c->address);
                        json_object_add_value_string(ctrl_attrs, "State", c->state);
+                       if (c->hostnqn)
+                               json_object_add_value_string(ctrl_attrs, "HostNQN", c->hostnqn);
+                       if (c->hostid)
+                               json_object_add_value_string(ctrl_attrs, "HostID", c->hostid);
 
                        format(formatter, sizeof(formatter), c->id.fr, sizeof(c->id.fr));
                        json_object_add_value_string(ctrl_attrs, "Firmware", formatter);
index 40b8a75145fd66b0d3992e800a496254a960d13b..431793905d8aa57165f1ba9fd197e42dfb48c543 100644 (file)
@@ -192,6 +192,8 @@ static int scan_ctrl(struct nvme_ctrl *c, char *p, __u32 ns_instance)
        c->address = nvme_get_ctrl_attr(path, "address");
        c->transport = nvme_get_ctrl_attr(path, "transport");
        c->state = nvme_get_ctrl_attr(path, "state");
+       c->hostnqn = nvme_get_ctrl_attr(path, "hostnqn");
+       c->hostid = nvme_get_ctrl_attr(path, "hostid");
 
        if (ns_instance)
                c->ana_state = get_nvme_ctrl_path_ana_state(path, ns_instance);
@@ -403,6 +405,8 @@ static void free_ctrl(struct nvme_ctrl *c)
        free(c->transport);
        free(c->address);
        free(c->state);
+       free(c->hostnqn);
+       free(c->hostid);
        free(c->ana_state);
        free(c->namespaces);
 }
diff --git a/nvme.h b/nvme.h
index f6a94e9757c69a489c9e0814c87466528f54cae6..017148ae5fb0322bb3b00566fa8e43721d8910e5 100644 (file)
--- a/nvme.h
+++ b/nvme.h
@@ -55,6 +55,8 @@ struct nvme_ctrl {
        char *traddr;
        char *trsvcid;
        char *host_traddr;
+       char *hostnqn;
+       char *hostid;
 
        struct nvme_id_ctrl id;