From patchwork Thu Feb 18 05:16:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 584512 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 C0475140328 for ; Thu, 18 Feb 2016 16:20:28 +1100 (AEDT) Received: from localhost ([::1]:37086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWH0s-0004Ex-Oh for incoming@patchwork.ozlabs.org; Thu, 18 Feb 2016 00:20:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWGyZ-0008D9-CC for qemu-devel@nongnu.org; Thu, 18 Feb 2016 00:18:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWGyX-0002z0-SU for qemu-devel@nongnu.org; Thu, 18 Feb 2016 00:18:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35569) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWGyX-0002yv-NM for qemu-devel@nongnu.org; Thu, 18 Feb 2016 00:18:01 -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 (Postfix) with ESMTPS id 6EB5BAAA for ; Thu, 18 Feb 2016 05:18:01 +0000 (UTC) Received: from pxdev.xzpeter.org.com (vpn1-7-225.pek2.redhat.com [10.72.7.225]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1I5H3gG012945; Thu, 18 Feb 2016 00:17:54 -0500 From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 18 Feb 2016 13:16:50 +0800 Message-Id: <1455772616-8668-6-git-send-email-peterx@redhat.com> In-Reply-To: <1455772616-8668-1-git-send-email-peterx@redhat.com> References: <1455772616-8668-1-git-send-email-peterx@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: drjones@redhat.com, famz@redhat.com, armbru@redhat.com, peterx@redhat.com, lcapitulino@redhat.com, pbonzini@redhat.com, lersek@redhat.com Subject: [Qemu-devel] [PATCH v8 05/11] dump-guest-memory: introduce dump_process() helper function. 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 No functional change. Cleanup only. Signed-off-by: Peter Xu Reviewed-by: Fam Zheng --- dump.c | 31 +++++++++++++++++++++---------- include/sysemu/dump.h | 3 +++ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/dump.c b/dump.c index 158d6ea..fed84a6 100644 --- a/dump.c +++ b/dump.c @@ -1465,6 +1465,9 @@ static void dump_init(DumpState *s, int fd, bool has_format, Error *err = NULL; int ret; + s->has_format = has_format; + s->format = format; + /* kdump-compressed is conflict with paging and filter */ if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) { assert(!paging && !has_filter); @@ -1623,6 +1626,23 @@ cleanup: dump_cleanup(s); } +/* this operation might be time consuming. */ +static void dump_process(DumpState *s, Error **errp) +{ + Error *local_err = NULL; + + if (s->has_format && s->format != DUMP_GUEST_MEMORY_FORMAT_ELF) { + create_kdump_vmcore(s, &local_err); + } else { + create_vmcore(s, &local_err); + } + + s->status = (local_err ? DUMP_STATUS_FAILED : DUMP_STATUS_COMPLETED); + error_propagate(errp, local_err); + + dump_cleanup(s); +} + void qmp_dump_guest_memory(bool paging, const char *file, bool has_detach, bool detach, bool has_begin, int64_t begin, bool has_length, @@ -1708,16 +1728,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, return; } - if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) { - create_kdump_vmcore(s, &local_err); - } else { - create_vmcore(s, &local_err); - } - - s->status = (local_err ? DUMP_STATUS_FAILED : DUMP_STATUS_COMPLETED); - error_propagate(errp, local_err); - - dump_cleanup(s); + dump_process(s, errp); } DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **errp) diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index 21fc02d..1da3ddb 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -178,6 +178,9 @@ typedef struct DumpState { size_t num_dumpable; /* number of page that can be dumped */ uint32_t flag_compress; /* indicate the compression format */ DumpStatus status; /* current dump status */ + + bool has_format; /* whether format is provided */ + DumpGuestMemoryFormat format; /* valid only if has_format == true */ } DumpState; uint16_t cpu_to_dump16(DumpState *s, uint16_t val);