From patchwork Fri Nov 27 02:48:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 549275 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 3C1F11402D7 for ; Fri, 27 Nov 2015 13:50:44 +1100 (AEDT) Received: from localhost ([::1]:54367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a297R-00033B-Tj for incoming@patchwork.ozlabs.org; Thu, 26 Nov 2015 21:50:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a295M-00076X-Am for qemu-devel@nongnu.org; Thu, 26 Nov 2015 21:48:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a295L-0004jn-8R for qemu-devel@nongnu.org; Thu, 26 Nov 2015 21:48:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47910) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a295L-0004j5-0j for qemu-devel@nongnu.org; Thu, 26 Nov 2015 21:48:31 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 9BC81C1C7BAE for ; Fri, 27 Nov 2015 02:48:30 +0000 (UTC) Received: from pxdev.xzpeter.org.com (vpn1-4-139.pek2.redhat.com [10.72.4.139]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAR2mNmb018945; Thu, 26 Nov 2015 21:48:29 -0500 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 27 Nov 2015 10:48:11 +0800 Message-Id: <1448592497-2462-3-git-send-email-peterx@redhat.com> In-Reply-To: <1448592497-2462-1-git-send-email-peterx@redhat.com> References: <1448592497-2462-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Xu Subject: [Qemu-devel] [PATCH v2 2/8] dump-guest-memory: add "detach" flag for QMP/HMP interfaces. 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 This patch only adds the interfaces, but not implements them. "detach" parameter is made optional, to make sure that all the old dump-guest-memory requests will still be able to work. Signed-off-by: Peter Xu --- dump.c | 5 +++-- hmp-commands.hx | 5 +++-- hmp.c | 9 +++++++-- qapi-schema.json | 8 ++++++-- qmp-commands.hx | 6 ++++-- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/dump.c b/dump.c index 445e739..d79e0ed 100644 --- a/dump.c +++ b/dump.c @@ -1580,8 +1580,9 @@ cleanup: dump_cleanup(s); } -void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, - int64_t begin, bool has_length, +void qmp_dump_guest_memory(bool paging, const char *file, + bool has_detach, bool detach, + bool has_begin, int64_t begin, bool has_length, int64_t length, bool has_format, DumpGuestMemoryFormat format, Error **errp) { diff --git a/hmp-commands.hx b/hmp-commands.hx index bb52e4d..664d794 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1056,10 +1056,11 @@ ETEXI { .name = "dump-guest-memory", - .args_type = "paging:-p,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?", - .params = "[-p] [-z|-l|-s] filename [begin length]", + .args_type = "paging:-p,detach:-d,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?", + .params = "[-p] [-d] [-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" + "-d: return immediately (do not wait for completion).\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" diff --git a/hmp.c b/hmp.c index 2140605..dccb457 100644 --- a/hmp.c +++ b/hmp.c @@ -1586,8 +1586,10 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) const char *file = qdict_get_str(qdict, "filename"); bool has_begin = qdict_haskey(qdict, "begin"); bool has_length = qdict_haskey(qdict, "length"); + bool has_detach = qdict_haskey(qdict, "detach"); int64_t begin = 0; int64_t length = 0; + bool detach = false; enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF; char *prot; @@ -1615,11 +1617,14 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) if (has_length) { length = qdict_get_int(qdict, "length"); } + if (has_detach) { + detach = qdict_get_try_bool(qdict, "detach", false); + } prot = g_strconcat("file:", file, NULL); - qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length, - true, dump_format, &err); + qmp_dump_guest_memory(paging, prot, has_detach, detach, has_begin, begin, + has_length, length, true, dump_format, &err); hmp_handle_error(mon, &err); g_free(prot); } diff --git a/qapi-schema.json b/qapi-schema.json index 8b1a423..fd81ce2 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2115,6 +2115,9 @@ # 2. fd: the protocol starts with "fd:", and the following string # is the fd's name. # +# @detach: #optional if true, QMP will return immediately rather than +# waiting dump to be finished (since 2.6). +# # @begin: #optional if specified, the starting physical address. # # @length: #optional if specified, the memory size, in bytes. If you don't @@ -2131,8 +2134,9 @@ # Since: 1.2 ## { 'command': 'dump-guest-memory', - 'data': { 'paging': 'bool', 'protocol': 'str', '*begin': 'int', - '*length': 'int', '*format': 'DumpGuestMemoryFormat' } } + 'data': { 'paging': 'bool', 'protocol': 'str', '*detach': 'bool', + '*begin': 'int', '*length': 'int', + '*format': 'DumpGuestMemoryFormat'} } ## # @DumpGuestMemoryCapability: diff --git a/qmp-commands.hx b/qmp-commands.hx index 9d8b42f..bbb08e1 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -840,8 +840,8 @@ EQMP { .name = "dump-guest-memory", - .args_type = "paging:b,protocol:s,begin:i?,end:i?,format:s?", - .params = "-p protocol [begin] [length] [format]", + .args_type = "paging:b,protocol:s,detach:b?,begin:i?,end:i?,format:s?", + .params = "-p protocol [-d] [begin] [length] [format]", .help = "dump guest memory to file", .mhandler.cmd_new = qmp_marshal_dump_guest_memory, }, @@ -857,6 +857,8 @@ Arguments: - "paging": do paging to get guest's memory mapping (json-bool) - "protocol": destination file(started with "file:") or destination file descriptor (started with "fd:") (json-string) +- "detach": if specificed, command will return immediately, without waiting + for dump to be finished (json-bool) - "begin": the starting physical address. It's optional, and should be specified with length together (json-int) - "length": the memory size, in bytes. It's optional, and should be specified