linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hare@suse.de (Hannes Reinecke)
Subject: [PATCH nvme-cli 2/3] nvme: print out controller state for 'list-subsys'
Date: Fri, 16 Nov 2018 08:35:00 +0100	[thread overview]
Message-ID: <20181116073501.7867-3-hare@suse.de> (raw)
In-Reply-To: <20181116073501.7867-1-hare@suse.de>

Signed-off-by: Hannes Reinecke <hare at suse.com>
---
 nvme-print.c | 7 +++++--
 nvme.c       | 9 +++++++++
 nvme.h       | 1 +
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/nvme-print.c b/nvme-print.c
index b728975..5cdfabe 100644
--- a/nvme-print.c
+++ b/nvme-print.c
@@ -2772,9 +2772,10 @@ static void show_nvme_subsystem(struct subsys_list_item *item)
 	printf("\\\n");
 
 	for (i = 0; i < item->nctrls; i++) {
-		printf(" +- %s %s %s\n", item->ctrls[i].name,
+		printf(" +- %s %s %s %s\n", item->ctrls[i].name,
 				item->ctrls[i].transport,
-				item->ctrls[i].address);
+				item->ctrls[i].address,
+				item->ctrls[i].state);
 	}
 
 }
@@ -2820,6 +2821,8 @@ void json_print_nvme_subsystem_list(struct subsys_list_item *slist, int n)
 					slist[i].ctrls[j].transport);
 			json_object_add_value_string(path_attrs, "Address",
 					slist[i].ctrls[j].address);
+			json_object_add_value_string(path_attrs, "State",
+					slist[i].ctrls[j].state);
 			json_array_add_value_object(paths, path_attrs);
 		}
 		if (j) {
diff --git a/nvme.c b/nvme.c
index f15d372..c3295c5 100644
--- a/nvme.c
+++ b/nvme.c
@@ -1363,6 +1363,7 @@ static void free_ctrl_list_item(struct ctrl_list_item *ctrls)
 	free(ctrls->name);
 	free(ctrls->transport);
 	free(ctrls->address);
+	free(ctrls->state);
 }
 
 static int get_nvme_subsystem_info(char *name, char *path,
@@ -1416,6 +1417,14 @@ static int get_nvme_subsystem_info(char *name, char *path,
 			continue;
 		}
 
+		item->ctrls[ccnt].state =
+				get_nvme_ctrl_attr(ctrl_path, "state");
+		if (!item->ctrls[ccnt].state) {
+			fprintf(stderr, "failed to get controller[%d] state.\n", i);
+			free_ctrl_list_item(&item->ctrls[ccnt]);
+			continue;
+		}
+
 		ccnt++;
 	}
 
diff --git a/nvme.h b/nvme.h
index 32ac96d..668c6fd 100644
--- a/nvme.h
+++ b/nvme.h
@@ -129,6 +129,7 @@ struct ctrl_list_item {
 	char *name;
 	char *address;
 	char *transport;
+	char *state;
 };
 
 struct subsys_list_item {
-- 
2.13.7

  parent reply	other threads:[~2018-11-16  7:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-16  7:34 [PATCH nvme-cli 0/3] Print out controller and ANA state for list-subsys Hannes Reinecke
2018-11-16  7:34 ` [PATCH nvme-cli 1/3] nvme: introduce get_nvme_ctrl_attr() Hannes Reinecke
2018-11-16 16:59   ` Keith Busch
2018-11-16  7:35 ` Hannes Reinecke [this message]
2018-11-16  7:35 ` [PATCH nvme-cli 3/3] nvme-list-subsys: Add device name argument and print out ANA state Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181116073501.7867-3-hare@suse.de \
    --to=hare@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).