@@ -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 = {