qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v6 11/11] Add 'query-dump-guest-memory-capability' c


From: Qiao Nuohan
Subject: [Qemu-devel] [PATCH v6 11/11] Add 'query-dump-guest-memory-capability' command
Date: Sun, 5 Jan 2014 15:27:44 +0800

'query-dump-guest-memory-capability' is used to query whether option 'format'
is available for 'dump-guest-memory' and the available format. The output
of the command will be like:

-> { "execute": "query-dump-guest-memory-capability" }
<- { "return": {
        "format-option": "optional",
        "capabilities": [
            {"available": true, "format": "elf"},
            {"available": true, "format": "kdump-zlib"},
            {"available": true, "format": "kdump-lzo"},
            {"available": true, "format": "kdump-snappy"}
        ]
    }

Signed-off-by: Qiao Nuohan <address@hidden>
---
 dump.c           |   38 ++++++++++++++++++++++++++++++++++++++
 qapi-schema.json |   13 +++++++++++++
 qmp-commands.hx  |    7 +++++++
 3 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/dump.c b/dump.c
index b4e79ff..51fe23a 100644
--- a/dump.c
+++ b/dump.c
@@ -1757,3 +1757,41 @@ void qmp_dump_guest_memory(bool paging, const char 
*file, bool has_begin,
 
     g_free(s);
 }
+
+DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **errp)
+{
+    int i;
+    DumpGuestMemoryCapabilityStatusList *item;
+    DumpGuestMemoryCapability *cap =
+                                  g_malloc0(sizeof(DumpGuestMemoryCapability));
+
+    cap->format_option = g_strdup_printf("optional");
+
+    for (i = 0; i < DUMP_GUEST_MEMORY_FORMAT_MAX; i++) {
+        if (cap->capabilities == NULL) {
+            item = g_malloc0(sizeof(DumpGuestMemoryCapabilityStatusList));
+            cap->capabilities = item;
+        } else {
+            item->next = 
g_malloc0(sizeof(DumpGuestMemoryCapabilityStatusList));
+            item = item->next;
+        }
+
+        item->value = g_malloc0(sizeof(struct 
DumpGuestMemoryCapabilityStatus));
+        item->value->format = i;
+        item->value->available = true;
+
+        if (i == DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO) {
+#ifndef CONFIG_LZO
+            item->value->available = false;
+#endif
+        }
+
+        if (i == DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY) {
+#ifndef CONFIG_SNAPPY
+            item->value->available = false;
+#endif
+        }
+    }
+
+    return cap;
+}
diff --git a/qapi-schema.json b/qapi-schema.json
index 19b2b23..e545e0f 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2740,6 +2740,19 @@
             '*length': 'int', '*format': 'DumpGuestMemoryFormat' } }
 
 ##
+# Since: 1.8
+##
+{ 'type':  'DumpGuestMemoryCapabilityStatus',
+  'data': { 'format': 'DumpGuestMemoryFormat', 'available': 'bool' } }
+
+{ 'type': 'DumpGuestMemoryCapability',
+  'data': {
+      'format-option': 'str',
+      'capabilities': ['DumpGuestMemoryCapabilityStatus'] } }
+
+{ 'command': 'query-dump-guest-memory-capability', 'returns': 
'DumpGuestMemoryCapability' }
+
+##
 # @netdev_add:
 #
 # Add a network backend.
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 3de9e7d..3379c75 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -828,6 +828,13 @@ Notes:
 EQMP
 
     {
+        .name       = "query-dump-guest-memory-capability",
+        .args_type  = "",
+        .mhandler.cmd_new = 
qmp_marshal_input_query_dump_guest_memory_capability,
+    },
+
+
+    {
         .name       = "netdev_add",
         .args_type  = "netdev:O",
         .mhandler.cmd_new = qmp_netdev_add,
-- 
1.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]