yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-dump-add-query-dump-guest-memory-capability-command.patch

958e1b
From 1b2628fe2375d602a6f123a0aa4a5cd190e72d3e Mon Sep 17 00:00:00 2001
958e1b
From: Laszlo Ersek <lersek@redhat.com>
958e1b
Date: Fri, 7 Nov 2014 17:18:05 +0100
958e1b
Subject: [PATCH 18/41] dump: add 'query-dump-guest-memory-capability' command
958e1b
958e1b
Message-id: <1415380693-16593-19-git-send-email-lersek@redhat.com>
958e1b
Patchwork-id: 62204
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH 18/26] dump: add 'query-dump-guest-memory-capability' command
958e1b
Bugzilla: 1157798
958e1b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
958e1b
RH-Acked-by: dgibson <dgibson@redhat.com>
958e1b
958e1b
From: qiaonuohan <qiaonuohan@cn.fujitsu.com>
958e1b
958e1b
'query-dump-guest-memory-capability' is used to query the available formats for
958e1b
'dump-guest-memory'. The output of the command will be like:
958e1b
958e1b
-> { "execute": "query-dump-guest-memory-capability" }
958e1b
<- { "return": { "formats":
958e1b
                    ["elf", "kdump-zlib", "kdump-lzo", "kdump-snappy"] }
958e1b
958e1b
Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
958e1b
Reviewed-by: Eric Blake <eblake@redhat.com>
958e1b
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
958e1b
(cherry picked from commit 7d6dc7f30c4781857ce230333da6ddd21fe0dcde)
958e1b
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 dump.c           | 33 +++++++++++++++++++++++++++++++++
958e1b
 qapi-schema.json | 24 ++++++++++++++++++++++++
958e1b
 qmp-commands.hx  | 20 ++++++++++++++++++++
958e1b
 3 files changed, 77 insertions(+)
958e1b
958e1b
diff --git a/dump.c b/dump.c
958e1b
index 507a250..25bf8e6 100644
958e1b
--- a/dump.c
958e1b
+++ b/dump.c
958e1b
@@ -1797,3 +1797,36 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
958e1b
 
958e1b
     g_free(s);
958e1b
 }
958e1b
+
958e1b
+DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **errp)
958e1b
+{
958e1b
+    DumpGuestMemoryFormatList *item;
958e1b
+    DumpGuestMemoryCapability *cap =
958e1b
+                                  g_malloc0(sizeof(DumpGuestMemoryCapability));
958e1b
+
958e1b
+    /* elf is always available */
958e1b
+    item = g_malloc0(sizeof(DumpGuestMemoryFormatList));
958e1b
+    cap->formats = item;
958e1b
+    item->value = DUMP_GUEST_MEMORY_FORMAT_ELF;
958e1b
+
958e1b
+    /* kdump-zlib is always available */
958e1b
+    item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList));
958e1b
+    item = item->next;
958e1b
+    item->value = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB;
958e1b
+
958e1b
+    /* add new item if kdump-lzo is available */
958e1b
+#ifdef CONFIG_LZO
958e1b
+    item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList));
958e1b
+    item = item->next;
958e1b
+    item->value = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO;
958e1b
+#endif
958e1b
+
958e1b
+    /* add new item if kdump-snappy is available */
958e1b
+#ifdef CONFIG_SNAPPY
958e1b
+    item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList));
958e1b
+    item = item->next;
958e1b
+    item->value = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY;
958e1b
+#endif
958e1b
+
958e1b
+    return cap;
958e1b
+}
958e1b
diff --git a/qapi-schema.json b/qapi-schema.json
958e1b
index 8f81c76..31ac5c5 100644
958e1b
--- a/qapi-schema.json
958e1b
+++ b/qapi-schema.json
958e1b
@@ -2645,6 +2645,30 @@
958e1b
             '*length': 'int', '*format': 'DumpGuestMemoryFormat' } }
958e1b
 
958e1b
 ##
958e1b
+# @DumpGuestMemoryCapability:
958e1b
+#
958e1b
+# A list of the available formats for dump-guest-memory
958e1b
+#
958e1b
+# Since: 2.0
958e1b
+##
958e1b
+{ 'type': 'DumpGuestMemoryCapability',
958e1b
+  'data': {
958e1b
+      'formats': ['DumpGuestMemoryFormat'] } }
958e1b
+
958e1b
+##
958e1b
+# @query-dump-guest-memory-capability:
958e1b
+#
958e1b
+# Returns the available formats for dump-guest-memory
958e1b
+#
958e1b
+# Returns:  A @DumpGuestMemoryCapability object listing available formats for
958e1b
+#           dump-guest-memory
958e1b
+#
958e1b
+# Since: 2.0
958e1b
+##
958e1b
+{ 'command': 'query-dump-guest-memory-capability',
958e1b
+  'returns': 'DumpGuestMemoryCapability' }
958e1b
+
958e1b
+##
958e1b
 # @netdev_add:
958e1b
 #
958e1b
 # Add a network backend.
958e1b
diff --git a/qmp-commands.hx b/qmp-commands.hx
958e1b
index 61aa3bf..9c11213 100644
958e1b
--- a/qmp-commands.hx
958e1b
+++ b/qmp-commands.hx
958e1b
@@ -923,6 +923,26 @@ Notes:
958e1b
 EQMP
958e1b
 
958e1b
     {
958e1b
+        .name       = "query-dump-guest-memory-capability",
958e1b
+        .args_type  = "",
958e1b
+    .mhandler.cmd_new = qmp_marshal_input_query_dump_guest_memory_capability,
958e1b
+    },
958e1b
+
958e1b
+SQMP
958e1b
+query-dump-guest-memory-capability
958e1b
+----------
958e1b
+
958e1b
+Show available formats for 'dump-guest-memory'
958e1b
+
958e1b
+Example:
958e1b
+
958e1b
+-> { "execute": "query-dump-guest-memory-capability" }
958e1b
+<- { "return": { "formats":
958e1b
+                    ["elf", "kdump-zlib", "kdump-lzo", "kdump-snappy"] }
958e1b
+
958e1b
+EQMP
958e1b
+
958e1b
+    {
958e1b
         .name       = "netdev_add",
958e1b
         .args_type  = "netdev:O",
958e1b
         .mhandler.cmd_new = qmp_netdev_add,
958e1b
-- 
958e1b
1.8.3.1
958e1b