qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Klaus Jensen <its@irrelevant.dk>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	qemu-block@nongnu.org, "Klaus Jensen" <k.jensen@samsung.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Klaus Jensen" <its@irrelevant.dk>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Keith Busch" <kbusch@kernel.org>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH RFC 13/13] hw/nvme: add attached-namespaces prop
Date: Tue, 14 Sep 2021 22:37:37 +0200	[thread overview]
Message-ID: <20210914203737.182571-14-its@irrelevant.dk> (raw)
In-Reply-To: <20210914203737.182571-1-its@irrelevant.dk>

From: Klaus Jensen <k.jensen@samsung.com>

Add a runtime property to get a list of attached namespaces per
controller.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
 hw/nvme/ctrl.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 04e564ad6be6..ed867384e40a 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -6746,6 +6746,27 @@ static void nvme_set_smart_warning(Object *obj, Visitor *v, const char *name,
     }
 }
 
+static void get_attached_namespaces(Object *obj, Visitor *v, const char *name,
+                                    void *opaque, Error **errp)
+{
+    NvmeState *n = NVME_STATE(obj);
+    strList *paths = NULL;
+    strList **tail = &paths;
+    int nsid;
+
+    for (nsid = 1; nsid <= NVME_MAX_NAMESPACES; nsid++) {
+        NvmeNamespace *ns = nvme_ns(n, nsid);
+        if (!ns) {
+            continue;
+        }
+
+        QAPI_LIST_APPEND(tail, object_get_canonical_path(OBJECT(ns)));
+    }
+
+    visit_type_strList(v, name, &paths, errp);
+    qapi_free_strList(paths);
+}
+
 static const VMStateDescription nvme_vmstate = {
     .name = "nvme",
     .unmigratable = 1,
@@ -6771,6 +6792,9 @@ static void nvme_state_instance_init(Object *obj)
     object_property_add(obj, "smart_critical_warning", "uint8",
                         nvme_get_smart_warning,
                         nvme_set_smart_warning, NULL, NULL);
+
+    object_property_add(obj, "attached-namespaces", "str",
+                        get_attached_namespaces, NULL, NULL, NULL);
 }
 
 static const TypeInfo nvme_state_info = {
-- 
2.33.0



  parent reply	other threads:[~2021-09-14 21:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14 20:37 [PATCH RFC 00/13] hw/nvme: experimental user-creatable objects Klaus Jensen
2021-09-14 20:37 ` [PATCH RFC 01/13] hw/nvme: move dif/pi prototypes into dif.h Klaus Jensen
2021-09-14 20:37 ` [PATCH RFC 02/13] hw/nvme: move zns helpers and types into zoned.h Klaus Jensen
2021-09-16 16:06   ` Keith Busch
2021-09-16 16:31     ` Klaus Jensen
2021-09-14 20:37 ` [PATCH RFC 03/13] hw/nvme: move zoned namespace members to separate struct Klaus Jensen
2021-09-14 20:37 ` [PATCH RFC 04/13] hw/nvme: move nvm " Klaus Jensen
2021-09-14 20:37 ` [PATCH RFC 05/13] hw/nvme: move BlockBackend to NvmeNamespaceNvm Klaus Jensen
2021-09-14 20:37 ` [PATCH RFC 06/13] nvme: add structured type for nguid Klaus Jensen
2021-09-14 20:37 ` [PATCH RFC 07/13] hw/nvme: hoist qdev state from namespace Klaus Jensen
2021-09-14 20:37 ` [PATCH RFC 08/13] hw/nvme: hoist qdev state from controller Klaus Jensen
2021-09-14 20:37 ` [PATCH RFC 09/13] hw/nvme: add experimental device x-nvme-ctrl Klaus Jensen
2021-09-14 20:37 ` [PATCH RFC 10/13] hw/nvme: add experimental object x-nvme-subsystem Klaus Jensen
2021-09-14 20:37 ` [PATCH RFC 11/13] hw/nvme: add experimental abstract object x-nvme-ns Klaus Jensen
2021-09-14 20:37 ` [PATCH RFC 12/13] hw/nvme: add experimental objects x-nvme-ns-{nvm, zoned} Klaus Jensen
2021-09-14 20:37 ` Klaus Jensen [this message]
2021-09-16 12:41 ` [PATCH RFC 00/13] hw/nvme: experimental user-creatable objects Kevin Wolf
2021-09-16 16:30   ` Klaus Jensen
2021-09-17  6:21     ` Klaus Jensen
2021-09-17  7:38       ` Kevin Wolf
2021-09-17  8:02         ` Klaus Jensen

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=20210914203737.182571-14-its@irrelevant.dk \
    --to=its@irrelevant.dk \
    --cc=armbru@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=k.jensen@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).