From: Sagi Grimberg Date: Tue, 24 Mar 2020 08:53:27 +0000 (-0700) Subject: nvme-print: list also hostnqn and hostid for verbose X-Git-Tag: v1.11~16 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4527e14071180015b8292c39bb88fde8b8550637;p=users%2Fhch%2Fnvme-cli.git 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 Signed-off-by: Keith Busch --- diff --git a/nvme-print.c b/nvme-print.c index c63de13..51f8849 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -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); diff --git a/nvme-topology.c b/nvme-topology.c index 40b8a75..4317939 100644 --- a/nvme-topology.c +++ b/nvme-topology.c @@ -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 f6a94e9..017148a 100644 --- 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;