[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 11/11] Add 'query-dump-guest-memory-capabilit
From: |
Laszlo Ersek |
Subject: |
Re: [Qemu-devel] [PATCH v6 11/11] Add 'query-dump-guest-memory-capability' command |
Date: |
Thu, 09 Jan 2014 17:34:53 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131118 Thunderbird/17.0.11 |
comments below
On 01/05/14 08:27, Qiao Nuohan wrote:
> '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"}
> ]
> }
The order of "available" and "format" in the commit message is reverse
in relation to the json. Not too important.
>
> 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
> + }
> + }
You could move the preprocessor directives outside.
Also, since the "available" field is false by nature of g_malloc0(),
maybe the code could be reorganized
- from "false to true to maybe false"
- to "false to maybe true".
Not overly important.
> +
> + 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
2.0
> +##
> +{ '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,
>
I think some more documentation is usual in the qmp-commands.hx file for
new commands; an SQMP/EQMP section should be likely added. However I'm
not giving my R-b only because of the 1.8 vs. 2.0 comment.
I'll let Eric decide if this query command serves libvirt sufficiently.
Thanks!
Laszlo
- Re: [Qemu-devel] [PATCH v6 06/11] dump: add API to write dump header, (continued)
[Qemu-devel] [PATCH v6 05/11] dump: add support for lzo/snappy, Qiao Nuohan, 2014/01/05
[Qemu-devel] [PATCH v6 03/11] dump: Add API to write vmcore, Qiao Nuohan, 2014/01/05
[Qemu-devel] [PATCH v6 11/11] Add 'query-dump-guest-memory-capability' command, Qiao Nuohan, 2014/01/05
- Re: [Qemu-devel] [PATCH v6 11/11] Add 'query-dump-guest-memory-capability' command,
Laszlo Ersek <=
[Qemu-devel] [PATCH v6 02/11] dump: Add API to write header of flatten format, Qiao Nuohan, 2014/01/05
[Qemu-devel] [PATCH v6 04/11] dump: Add API to write elf notes to buffer, Qiao Nuohan, 2014/01/05
[Qemu-devel] [PATCH v6 10/11] dump: Make kdump-compressed format available for 'dump-guest-memory', Qiao Nuohan, 2014/01/05
[Qemu-devel] [PATCH v6 08/11] dump: Add APIs to operate DataCache, Qiao Nuohan, 2014/01/05
[Qemu-devel] [PATCH v6 09/11] dump: Add API to write dump pages, Qiao Nuohan, 2014/01/05