diff mbox

[v9,13/13] dump: add 'query-dump-guest-memory-capability' command

Message ID 52FAE6E2.8050703@cn.fujitsu.com
State New
Headers show

Commit Message

Qiao Nuohan Feb. 12, 2014, 3:13 a.m. UTC
'query-dump-guest-memory-capability' is used to query the available formats of
'dump-guest-memory'. The output of the command will be like:

-> { "execute": "query-dump-guest-memory-capability" }
<- { "return": { "formats":
                     ["elf", "kdump-zlib", "kdump-lzo", "kdump-snappy"] }

Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
---
  dump.c           |   33 +++++++++++++++++++++++++++++++++
  qapi-schema.json |    9 +++++++++
  qmp-commands.hx  |   23 +++++++++++++++++++++++
  3 files changed, 65 insertions(+), 0 deletions(-)

Comments

Eric Blake Feb. 12, 2014, 3:29 a.m. UTC | #1
On 02/11/2014 08:13 PM, Qiao Nuohan wrote:
> 'query-dump-guest-memory-capability' is used to query the available
> formats of
> 'dump-guest-memory'. The output of the command will be like:
> 
> -> { "execute": "query-dump-guest-memory-capability" }
> <- { "return": { "formats":
>                     ["elf", "kdump-zlib", "kdump-lzo", "kdump-snappy"] }
> 
> Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
> ---
>  dump.c           |   33 +++++++++++++++++++++++++++++++++
>  qapi-schema.json |    9 +++++++++
>  qmp-commands.hx  |   23 +++++++++++++++++++++++
>  3 files changed, 65 insertions(+), 0 deletions(-)


> +++ b/qapi-schema.json
> @@ -2783,6 +2783,15 @@
>              '*length': 'int', '*format': 'DumpGuestMemoryFormat' } }
> 
>  ##
> +# Since: 2.0

A bit sparse on the documentation; at a minimum, you want a line:

# @query-dump-guest-memory-capability:

prior to the Since designation (look at @query-name for an example).


> +
> +SQMP
> +query-dump-guest-memory-capability
> +----------
> +
> +Show available format of 'dump-guest-memory'

s/format of/formats for/

> +
> +Example:
> +
> +-> { "execute": "query-dump-guest-memory-capability" }
> +<- { "return": { "formats":
> +                    ["elf", "kdump-zlib", "kdump-lzo", "kdump-snappy"] }
> +
> +Note: This is a light-weight introspection to let management know the
> available
> +      formats of dump-guest-memory.

This note feels a bit redundant with the earlier summary; I'm okay if
you leave it in, but I also don't mind if you drop it.
diff mbox

Patch

diff --git a/dump.c b/dump.c
index 2ebbb23..3a8d55e 100644
--- a/dump.c
+++ b/dump.c
@@ -1788,3 +1788,36 @@  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)
+{
+    DumpGuestMemoryFormatList *item;
+    DumpGuestMemoryCapability *cap =
+                                  g_malloc0(sizeof(DumpGuestMemoryCapability));
+
+    /* elf is always available */
+    item = g_malloc0(sizeof(DumpGuestMemoryFormatList));
+    cap->formats = item;
+    item->value = DUMP_GUEST_MEMORY_FORMAT_ELF;
+
+    /* kdump-zlib is always available */
+    item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList));
+    item = item->next;
+    item->value = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB;
+
+    /* add new item if kdump-lzo is available */
+#ifdef CONFIG_LZO
+    item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList));
+    item = item->next;
+    item->value = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO;
+#endif
+
+    /* add new item if kdump-snappy is available */
+#ifdef CONFIG_SNAPPY
+    item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList));
+    item = item->next;
+    item->value = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY;
+#endif
+
+    return cap;
+}
diff --git a/qapi-schema.json b/qapi-schema.json
index 7f62007..5d13bb3 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2783,6 +2783,15 @@ 
              '*length': 'int', '*format': 'DumpGuestMemoryFormat' } }

  ##
+# Since: 2.0
+##
+{ 'type': 'DumpGuestMemoryCapability',
+  'data': {
+      'formats': ['DumpGuestMemoryFormat'] } }
+
+{ '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 019dde6..1f9ff69 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -829,6 +829,29 @@  Notes:
  EQMP

      {
+        .name       = "query-dump-guest-memory-capability",
+        .args_type  = "",
+        .mhandler.cmd_new = qmp_marshal_input_query_dump_guest_memory_capability,
+    },
+
+SQMP
+query-dump-guest-memory-capability
+----------
+
+Show available format of 'dump-guest-memory'
+
+Example:
+
+-> { "execute": "query-dump-guest-memory-capability" }
+<- { "return": { "formats":
+                    ["elf", "kdump-zlib", "kdump-lzo", "kdump-snappy"] }
+
+Note: This is a light-weight introspection to let management know the available
+      formats of dump-guest-memory.
+
+EQMP
+
+    {
          .name       = "netdev_add",
          .args_type  = "netdev:O",
          .mhandler.cmd_new = qmp_netdev_add,