[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC 13/13] hw/nvme: add attached-namespaces prop
From: |
Klaus Jensen |
Subject: |
[PATCH RFC 13/13] hw/nvme: add attached-namespaces prop |
Date: |
Tue, 14 Sep 2021 22:37:37 +0200 |
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
- [PATCH RFC 01/13] hw/nvme: move dif/pi prototypes into dif.h, (continued)
- [PATCH RFC 01/13] hw/nvme: move dif/pi prototypes into dif.h, Klaus Jensen, 2021/09/14
- [PATCH RFC 04/13] hw/nvme: move nvm namespace members to separate struct, Klaus Jensen, 2021/09/14
- [PATCH RFC 08/13] hw/nvme: hoist qdev state from controller, Klaus Jensen, 2021/09/14
- [PATCH RFC 06/13] nvme: add structured type for nguid, Klaus Jensen, 2021/09/14
- [PATCH RFC 05/13] hw/nvme: move BlockBackend to NvmeNamespaceNvm, Klaus Jensen, 2021/09/14
- [PATCH RFC 07/13] hw/nvme: hoist qdev state from namespace, Klaus Jensen, 2021/09/14
- [PATCH RFC 09/13] hw/nvme: add experimental device x-nvme-ctrl, Klaus Jensen, 2021/09/14
- [PATCH RFC 11/13] hw/nvme: add experimental abstract object x-nvme-ns, Klaus Jensen, 2021/09/14
- [PATCH RFC 10/13] hw/nvme: add experimental object x-nvme-subsystem, Klaus Jensen, 2021/09/14
- [PATCH RFC 12/13] hw/nvme: add experimental objects x-nvme-ns-{nvm, zoned}, Klaus Jensen, 2021/09/14
- [PATCH RFC 13/13] hw/nvme: add attached-namespaces prop,
Klaus Jensen <=
- Re: [PATCH RFC 00/13] hw/nvme: experimental user-creatable objects, Kevin Wolf, 2021/09/16