From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W824g-0004jf-1k for qemu-devel@nongnu.org; Tue, 28 Jan 2014 01:23:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W824X-0003wl-8S for qemu-devel@nongnu.org; Tue, 28 Jan 2014 01:23:05 -0500 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:53042) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W824W-0003wH-Pw for qemu-devel@nongnu.org; Tue, 28 Jan 2014 01:22:57 -0500 Received: from m2.gw.fujitsu.co.jp (unknown [10.0.50.72]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 108BB3EE0C1 for ; Tue, 28 Jan 2014 15:22:56 +0900 (JST) Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id E3BDD45DE52 for ; Tue, 28 Jan 2014 15:22:55 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.nic.fujitsu.com [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id CC33445DE4D for ; Tue, 28 Jan 2014 15:22:55 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id BDA761DB803A for ; Tue, 28 Jan 2014 15:22:55 +0900 (JST) Received: from s00.gw.fujitsu.co.jp (s00.gw.nic.fujitsu.com [133.161.11.15]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 692141DB803C for ; Tue, 28 Jan 2014 15:22:55 +0900 (JST) Received: from s00.gw.fujitsu.co.jp (kw-mxio2.gw.nic.fujitsu.com [10.0.237.142]) by s00.gw.fujitsu.co.jp (Postfix) with ESMTP id D0CF411812D for ; Tue, 28 Jan 2014 15:22:54 +0900 (JST) Received: from G08FNSTD100518.localdomain (unknown [10.167.226.68]) by s00.gw.fujitsu.co.jp (Postfix) with ESMTP id 60B7A8A010 for ; Tue, 28 Jan 2014 15:22:54 +0900 (JST) From: qiaonuohan Date: Tue, 28 Jan 2014 14:22:06 +0800 Message-Id: <1390890126-17377-14-git-send-email-qiaonuohan@cn.fujitsu.com> In-Reply-To: <1390890126-17377-1-git-send-email-qiaonuohan@cn.fujitsu.com> References: <1390890126-17377-1-git-send-email-qiaonuohan@cn.fujitsu.com> Subject: [Qemu-devel] [PATCH v8 13/13] dump: add 'query-dump-guest-memory-capability' command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: lersek@redhat.com, stefanha@gmail.com, lcapitulino@redhat.com, afaerber@suse.de, eblake@redhat.com Cc: kumagai-atsushi@mxc.nes.nec.co.jp, qiaonuohan , anderson@redhat.com, qemu-devel@nongnu.org '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 Reviewed-by: Laszlo Ersek --- dump.c | 42 ++++++++++++++++++++++++++++++++++++++++++ qapi-schema.json | 13 +++++++++++++ qmp-commands.hx | 31 +++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 0 deletions(-) diff --git a/dump.c b/dump.c index 2ebbb23..8f64aab 100644 --- a/dump.c +++ b/dump.c @@ -1788,3 +1788,45 @@ 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; + + if (i == DUMP_GUEST_MEMORY_FORMAT_ELF || + i == DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB) { + item->value->available = true; + } + +#ifdef CONFIG_LZO + if (i == DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO) { + item->value->available = true; + } +#endif + +#ifdef CONFIG_SNAPPY + if (i == DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY) { + item->value->available = true; + } +#endif + } + + return cap; +} diff --git a/qapi-schema.json b/qapi-schema.json index 7f62007..012c70c 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2783,6 +2783,19 @@ '*length': 'int', '*format': 'DumpGuestMemoryFormat' } } ## +# Since: 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 019dde6..e1b311a 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -829,6 +829,37 @@ 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 whether option 'format' is available for 'dump-guest-memory' and the +available formats. + +Example: + +-> { "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"} + ] + } + +Note: This is a light-weight introspection to let management know whether format + option is available and the supported compression formats. + +EQMP + + { .name = "netdev_add", .args_type = "netdev:O", .mhandler.cmd_new = qmp_netdev_add, -- 1.7.1