From patchwork Thu Feb 13 15:30:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 320109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 27FA22C0098 for ; Fri, 14 Feb 2014 02:41:56 +1100 (EST) Received: from localhost ([::1]:47205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDyQE-0007Vq-1y for incoming@patchwork.ozlabs.org; Thu, 13 Feb 2014 10:41:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDyGN-0002CF-BZ for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:31:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDyGI-0000Bd-Ju for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:31:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37838) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDyGI-0000BX-Cf for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:31:38 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1DFVYxC027681 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 13 Feb 2014 10:31:34 -0500 Received: from localhost (ovpn-113-138.phx2.redhat.com [10.3.113.138]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s1DFVYJO000541; Thu, 13 Feb 2014 10:31:34 -0500 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Thu, 13 Feb 2014 10:30:36 -0500 Message-Id: <1392305440-30465-19-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1392305440-30465-1-git-send-email-lcapitulino@redhat.com> References: <1392305440-30465-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws Subject: [Qemu-devel] [PULL 18/22] dump: add 'query-dump-guest-memory-capability' command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: qiaonuohan 'query-dump-guest-memory-capability' is used to query the available formats for '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 Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- dump.c | 33 +++++++++++++++++++++++++++++++++ qapi-schema.json | 24 ++++++++++++++++++++++++ qmp-commands.hx | 20 ++++++++++++++++++++ 3 files changed, 77 insertions(+) diff --git a/dump.c b/dump.c index 78d226f..c7cd30b 100644 --- a/dump.c +++ b/dump.c @@ -1791,3 +1791,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 6ff6d49..47d412b 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2805,6 +2805,30 @@ '*length': 'int', '*format': 'DumpGuestMemoryFormat' } } ## +# @DumpGuestMemoryCapability: +# +# A list of the available formats for dump-guest-memory +# +# Since: 2.0 +## +{ 'type': 'DumpGuestMemoryCapability', + 'data': { + 'formats': ['DumpGuestMemoryFormat'] } } + +## +# @query-dump-guest-memory-capability: +# +# Returns the available formats for dump-guest-memory +# +# Returns: A @DumpGuestMemoryCapability object listing available formats for +# dump-guest-memory +# +# Since: 2.0 +## +{ '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 8da11ac..d53c33c 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -829,6 +829,26 @@ 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 formats for 'dump-guest-memory' + +Example: + +-> { "execute": "query-dump-guest-memory-capability" } +<- { "return": { "formats": + ["elf", "kdump-zlib", "kdump-lzo", "kdump-snappy"] } + +EQMP + + { .name = "netdev_add", .args_type = "netdev:O", .mhandler.cmd_new = qmp_netdev_add,