From patchwork Thu Apr 17 08:15:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiao Nuohan X-Patchwork-Id: 339809 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 22AB414007F for ; Thu, 17 Apr 2014 18:19:31 +1000 (EST) Received: from localhost ([::1]:58534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WahXc-0001BA-Tn for incoming@patchwork.ozlabs.org; Thu, 17 Apr 2014 04:19:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WahXD-0000RE-HW for qemu-devel@nongnu.org; Thu, 17 Apr 2014 04:19:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WahX8-00033X-Hv for qemu-devel@nongnu.org; Thu, 17 Apr 2014 04:19:03 -0400 Received: from [59.151.112.132] (port=24072 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WahX8-00033A-6a for qemu-devel@nongnu.org; Thu, 17 Apr 2014 04:18:58 -0400 X-IronPort-AV: E=Sophos;i="4.97,876,1389715200"; d="scan'208";a="29383473" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 17 Apr 2014 16:16:25 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s3H8IpmG004185; Thu, 17 Apr 2014 16:18:51 +0800 Received: from G08FNSTD100518.fnst.cn.fujitsu.com (10.167.226.68) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.146.2; Thu, 17 Apr 2014 16:18:50 +0800 From: Qiao Nuohan To: Date: Thu, 17 Apr 2014 16:15:07 +0800 Message-ID: <1397722507-21764-3-git-send-email-qiaonuohan@cn.fujitsu.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1397722507-21764-1-git-send-email-qiaonuohan@cn.fujitsu.com> References: <1397722507-21764-1-git-send-email-qiaonuohan@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.68] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: borntraeger@de.ibm.com, armbru@redhat.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH v2 2/2] HMP: support specifying dump format for dump-guest-memory 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 Dumping guest memory is available to specify the dump format now. This patch adds options '-z|-l|-s' to HMP command dump-guest-memory to specify dumping in kdump-compression format, with zlib/lzo/snappy compression. And without these options ELF format will be used. The discussion about this feature is here: http://lists.nongnu.org/archive/html/qemu-devel/2014-03/msg04235.html Signed-off-by: Qiao Nuohan Suggested-by: Christian Borntraeger Tested-by: Christian Borntraeger (on s390x/kvm) --- hmp-commands.hx | 13 ++++++++++--- hmp.c | 25 ++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index c242770..f52b55f 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -998,10 +998,13 @@ ETEXI { .name = "dump-guest-memory", - .args_type = "paging:-p,filename:F,begin:i?,length:i?", - .params = "[-p] filename [begin length]", + .args_type = "paging:-p,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?", + .params = "[-p] [-z|-l|-s] filename [begin length]", .help = "dump guest memory into file 'filename'.\n\t\t\t" "-p: do paging to get guest's memory mapping.\n\t\t\t" + "-z: dump in kdump-compressed format, with zlib compression.\n\t\t\t" + "-l: dump in kdump-compressed format, with lzo compression.\n\t\t\t" + "-s: dump in kdump-compressed format, with snappy compression.\n\t\t\t" "begin: the starting physical address.\n\t\t\t" "length: the memory size, in bytes.", .mhandler.cmd = hmp_dump_guest_memory, @@ -1010,10 +1013,14 @@ ETEXI STEXI @item dump-guest-memory [-p] @var{filename} @var{begin} @var{length} +@item dump-guest-memory [-z|-l|-s] @var{filename} @findex dump-guest-memory Dump guest memory to @var{protocol}. The file can be processed with crash or -gdb. +gdb. Without -z|-l|-s, the dump format is ELF. -p: do paging to get guest's memory mapping. + -z: dump in kdump-compressed format, with zlib compression. + -l: dump in kdump-compressed format, with lzo compression. + -s: dump in kdump-compressed format, with snappy compression. filename: dump file name. begin: the starting physical address. It's optional, and should be specified together with length. diff --git a/hmp.c b/hmp.c index 2f279c4..ca869ba 100644 --- a/hmp.c +++ b/hmp.c @@ -1308,16 +1308,35 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) { Error *errp = NULL; int paging = qdict_get_try_bool(qdict, "paging", 0); + int zlib = qdict_get_try_bool(qdict, "zlib", 0); + int lzo = qdict_get_try_bool(qdict, "lzo", 0); + int snappy = qdict_get_try_bool(qdict, "snappy", 0); const char *file = qdict_get_str(qdict, "filename"); bool has_begin = qdict_haskey(qdict, "begin"); bool has_length = qdict_haskey(qdict, "length"); - /* kdump-compressed format is not supported for HMP */ - bool has_format = false; int64_t begin = 0; int64_t length = 0; enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF; char *prot; + if (zlib + lzo + snappy > 1) { + error_setg(&errp, "only one of '-z|-l|-s' can be set"); + hmp_handle_error(mon, &errp); + return; + } + + if (zlib) { + dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB; + } + + if (lzo) { + dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO; + } + + if (snappy) { + dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY; + } + if (has_begin) { begin = qdict_get_int(qdict, "begin"); } @@ -1328,7 +1347,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) prot = g_strconcat("file:", file, NULL); qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length, - has_format, dump_format, &errp); + true, dump_format, &errp); hmp_handle_error(mon, &errp); g_free(prot); }