[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 33/34] qmp: add query-memdev
From: |
address@hidden |
Subject: |
[Qemu-devel] [PATCH v3 33/34] qmp: add query-memdev |
Date: |
Wed, 26 Mar 2014 10:37:03 +0000 |
Add qmp command query-memdev to query for information
of memory devices
Signed-off-by: Hu Tao <address@hidden>
---
numa.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
qapi-schema.json | 34 ++++++++++++++++++++++++++
qmp-commands.hx | 32 +++++++++++++++++++++++++
3 files changed, 138 insertions(+)
diff --git a/numa.c b/numa.c
index fa117f0..77b6ca1 100644
--- a/numa.c
+++ b/numa.c
@@ -32,9 +32,14 @@
#include "qapi-visit.h"
#include "qapi/opts-visitor.h"
#include "qapi/dealloc-visitor.h"
+#include "qapi/qmp-output-visitor.h"
+#include "qapi/qmp-input-visitor.h"
+#include "qapi/string-output-visitor.h"
+#include "qapi/string-input-visitor.h"
#include "qapi/qmp/qerror.h"
#include "hw/boards.h"
#include "sysemu/hostmem.h"
+#include "qmp-commands.h"
QemuOptsList qemu_numa_opts = {
.name = "numa",
@@ -281,3 +286,70 @@ void memory_region_allocate_system_memory(MemoryRegion
*mr, Object *owner,
addr += size;
}
}
+
+MemdevList *qmp_query_memdev(Error **errp)
+{
+ MemdevList *list = NULL, *m;
+ HostMemoryBackend *backend;
+ Error *err = NULL;
+ int i;
+
+ for (i = 0; i < nb_numa_nodes; i++) {
+ backend = numa_info[i].node_memdev;
+
+ m = g_malloc0(sizeof(*m));
+ m->value = g_malloc0(sizeof(*m->value));
+ m->value->size = object_property_get_int(OBJECT(backend), "size",
+ &err);
+ if (err) {
+ goto error;
+ }
+
+ m->value->merge = object_property_get_bool(OBJECT(backend), "merge",
+ &err);
+ if (err) {
+ goto error;
+ }
+
+ m->value->dump = object_property_get_bool(OBJECT(backend), "dump",
+ &err);
+ if (err) {
+ goto error;
+ }
+
+ m->value->prealloc = object_property_get_bool(OBJECT(backend),
+ "prealloc", &err);
+ if (err) {
+ goto error;
+ }
+
+ m->value->policy = object_property_get_enum(OBJECT(backend),
+ "policy",
+ HostMemPolicy_lookup,
+ &err);
+ if (err) {
+ goto error;
+ }
+
+ object_property_get_uint16List(OBJECT(backend), "host-nodes",
+ &m->value->host_nodes, &err);
+ if (err) {
+ goto error;
+ }
+
+ m->next = list;
+ list = m;
+ }
+
+ return list;
+
+error:
+ while (list) {
+ m = list;
+ list = list->next;
+ g_free(m->value);
+ g_free(m);
+ }
+ qerror_report_err(err);
+ return NULL;
+}
diff --git a/qapi-schema.json b/qapi-schema.json
index 5aea3ed..ee89d29 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4743,3 +4743,37 @@
##
{ 'enum': 'HostMemPolicy',
'data': [ 'default', 'preferred', 'bind', 'interleave' ] }
+
+##
+# @Memdev:
+#
+# Information of memory device
+#
+# @size: memory device size
+#
+# @host-nodes: host nodes for its memory policy
+#
+# @policy: memory policy of memory device
+#
+# Since: 2.1
+##
+
+{ 'type': 'Memdev',
+ 'data': {
+ 'size': 'size',
+ 'merge': 'bool',
+ 'dump': 'bool',
+ 'prealloc': 'bool',
+ 'host-nodes': ['uint16'],
+ 'policy': 'HostMemPolicy' }}
+
+##
+# @query-memdev:
+#
+# Returns information for all memory devices.
+#
+# Returns: a list of @Memdev.
+#
+# Since: 2.1
+##
+{ 'command': 'query-memdev', 'returns': ['Memdev'] }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index a22621f..a513b40 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -3560,3 +3560,35 @@ Example:
} } ] }
EQMP
+
+ {
+ .name = "query-memdev",
+ .args_type = "",
+ .mhandler.cmd_new = qmp_marshal_input_query_memdev,
+ },
+
+SQMP
+query-memdev
+------------
+
+Show memory devices information.
+
+
+Example (1):
+
+-> { "execute": "query-memdev" }
+<- { "return": [
+ {
+ "size": 536870912,
+ "host-nodes": [0, 1],
+ "policy": "bind"
+ },
+ {
+ "size": 536870912,
+ "host-nodes": [2, 3],
+ "policy": "preferred"
+ }
+ ]
+ }
+
+EQMP
--
1.8.5.2.229.g4448466
- [Qemu-devel] [PATCH v3 27/34] hostmem: add properties for NUMA memory policy, (continued)
- [Qemu-devel] [PATCH v3 27/34] hostmem: add properties for NUMA memory policy, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 11/34] qmp: improve error reporting for -object and object-add, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 32/34] qom: introduce object_property_get_enum and object_property_get_uint16List, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 20/34] memory: move RAM_PREALLOC_MASK to exec.c, rename, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 25/34] hostmem: add property to map memory with MAP_SHARED, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 23/34] hostmem: add merge and dump properties, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 34/34] hmp: add info memdev, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 28/34] hw: switch all boards to use memory_region_allocate_system_memory, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 31/34] qapi: make string output visitor parse int list, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 33/34] qmp: add query-memdev,
address@hidden <=
- [Qemu-devel] [PATCH v3 06/34] man: improve -numa doc, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 19/34] memory: move preallocation code out of exec.c, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 29/34] Introduce signed range., address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 13/34] numa: introduce memory_region_allocate_system_memory, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 04/34] NUMA: convert -numa option to use OptsVisitor, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 30/34] qapi: make string input visitor parse int list, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 07/34] qemu-option: introduce qemu_find_opts_singleton, address@hidden, 2014/03/26
- [Qemu-devel] [PATCH v3 17/34] memory: move mem_path handling to memory_region_allocate_system_memory, address@hidden, 2014/03/26