summaryrefslogtreecommitdiff
path: root/numa.c
diff options
context:
space:
mode:
Diffstat (limited to 'numa.c')
-rw-r--r--numa.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/numa.c b/numa.c
index 711f6825cb..eef0717785 100644
--- a/numa.c
+++ b/numa.c
@@ -34,6 +34,7 @@
#include "qapi/qmp/qerror.h"
#include "hw/boards.h"
#include "sysemu/hostmem.h"
+#include "qmp-commands.h"
QemuOptsList qemu_numa_opts = {
.name = "numa",
@@ -283,3 +284,86 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
addr += size;
}
}
+
+static int query_memdev(Object *obj, void *opaque)
+{
+ MemdevList **list = opaque;
+ Error *err = NULL;
+
+ if (object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)) {
+ MemdevList *m = g_malloc0(sizeof(*m));
+
+ m->value = g_malloc0(sizeof(*m->value));
+
+ m->value->size = object_property_get_int(obj, "size",
+ &err);
+ if (err) {
+ goto error;
+ }
+
+ m->value->merge = object_property_get_bool(obj, "merge",
+ &err);
+ if (err) {
+ goto error;
+ }
+
+ m->value->dump = object_property_get_bool(obj, "dump",
+ &err);
+ if (err) {
+ goto error;
+ }
+
+ m->value->prealloc = object_property_get_bool(obj,
+ "prealloc", &err);
+ if (err) {
+ goto error;
+ }
+
+ m->value->policy = object_property_get_enum(obj,
+ "policy",
+ HostMemPolicy_lookup,
+ &err);
+ if (err) {
+ goto error;
+ }
+
+ object_property_get_uint16List(obj, "host-nodes",
+ &m->value->host_nodes, &err);
+ if (err) {
+ goto error;
+ }
+
+ m->next = *list;
+ *list = m;
+ }
+
+ return 0;
+error:
+ return -1;
+}
+
+MemdevList *qmp_query_memdev(Error **errp)
+{
+ Object *obj;
+ MemdevList *list = NULL, *m;
+
+ obj = object_resolve_path("/objects", NULL);
+ if (obj == NULL) {
+ return NULL;
+ }
+
+ if (object_child_foreach(obj, query_memdev, &list) != 0) {
+ goto error;
+ }
+
+ return list;
+
+error:
+ while (list) {
+ m = list;
+ list = list->next;
+ g_free(m->value);
+ g_free(m);
+ }
+ return NULL;
+}