From patchwork Wed Dec 9 02:42:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 554206 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 8113C14030D for ; Wed, 9 Dec 2015 13:47:14 +1100 (AEDT) Received: from localhost ([::1]:34322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6Umd-0003az-Rj for incoming@patchwork.ozlabs.org; Tue, 08 Dec 2015 21:47:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6Uir-0005UT-Py for qemu-devel@nongnu.org; Tue, 08 Dec 2015 21:43:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6Uiq-0005GX-Rm for qemu-devel@nongnu.org; Tue, 08 Dec 2015 21:43:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39706) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6Uiq-0005GT-NE for qemu-devel@nongnu.org; Tue, 08 Dec 2015 21:43:16 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 5B8468C1A5 for ; Wed, 9 Dec 2015 02:43:16 +0000 (UTC) Received: from pxdev.xzpeter.org.com (vpn1-5-205.pek2.redhat.com [10.72.5.205]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tB92gTJP026279; Tue, 8 Dec 2015 21:43:08 -0500 From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 9 Dec 2015 10:42:16 +0800 Message-Id: <1449628943-10197-5-git-send-email-peterx@redhat.com> In-Reply-To: <1449628943-10197-1-git-send-email-peterx@redhat.com> References: <1449628943-10197-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: drjones@redhat.com, lersek@redhat.com, armbru@redhat.com, peterx@redhat.com, lcapitulino@redhat.com, famz@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v6 04/11] dump-guest-memory: add dump_in_progress() 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 For now, it has no effect. It will be used in dump detach support. Signed-off-by: Peter Xu Reviewed-by: Fam Zheng --- dump.c | 13 +++++++++++++ include/qemu-common.h | 4 ++++ qmp.c | 14 ++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/dump.c b/dump.c index b48cec2..ccd56c8 100644 --- a/dump.c +++ b/dump.c @@ -1426,6 +1426,12 @@ static void dump_state_prepare(DumpState *s) *s = (DumpState) { .status = DUMP_STATUS_ACTIVE }; } +bool dump_in_progress(void) +{ + DumpState *state = &dump_state_global; + return (state->status == DUMP_STATUS_ACTIVE); +} + static void dump_init(DumpState *s, int fd, bool has_format, DumpGuestMemoryFormat format, bool paging, bool has_filter, int64_t begin, int64_t length, Error **errp) @@ -1599,6 +1605,13 @@ void qmp_dump_guest_memory(bool paging, const char *file, DumpState *s; Error *local_err = NULL; + /* if there is a dump in background, we should wait until the dump + * finished */ + if (dump_in_progress()) { + error_setg(errp, "There is a dump in process, please wait."); + return; + } + /* * kdump-compressed format need the whole memory dumped, so paging or * filter is not supported here. diff --git a/include/qemu-common.h b/include/qemu-common.h index 405364f..7b74961 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -501,4 +501,8 @@ int parse_debug_env(const char *name, int max, int initial); const char *qemu_ether_ntoa(const MACAddr *mac); void page_size_init(void); +/* returns non-zero if dump is in progress, otherwise zero is + * returned. */ +bool dump_in_progress(void); + #endif diff --git a/qmp.c b/qmp.c index 0a1fa19..055586d 100644 --- a/qmp.c +++ b/qmp.c @@ -102,6 +102,13 @@ void qmp_quit(Error **errp) void qmp_stop(Error **errp) { + /* if there is a dump in background, we should wait until the dump + * finished */ + if (dump_in_progress()) { + error_setg(errp, "There is a dump in process, please wait."); + return; + } + if (runstate_check(RUN_STATE_INMIGRATE)) { autostart = 0; } else { @@ -174,6 +181,13 @@ void qmp_cont(Error **errp) BlockBackend *blk; BlockDriverState *bs; + /* if there is a dump in background, we should wait until the dump + * finished */ + if (dump_in_progress()) { + error_setg(errp, "There is a dump in process, please wait."); + return; + } + if (runstate_needs_reset()) { error_setg(errp, "Resetting the Virtual Machine is required"); return;