From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVaQ6-0008Ps-Ie for qemu-devel@nongnu.org; Tue, 16 Feb 2016 02:51:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVaQ3-0000x7-9f for qemu-devel@nongnu.org; Tue, 16 Feb 2016 02:51:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVaQ3-0000wt-33 for qemu-devel@nongnu.org; Tue, 16 Feb 2016 02:51:35 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id B3AAEE1B94 for ; Tue, 16 Feb 2016 07:51:34 +0000 (UTC) From: Peter Xu Date: Tue, 16 Feb 2016 15:50:54 +0800 Message-Id: <1455609061-16279-5-git-send-email-peterx@redhat.com> In-Reply-To: <1455609061-16279-1-git-send-email-peterx@redhat.com> References: <1455609061-16279-1-git-send-email-peterx@redhat.com> Subject: [Qemu-devel] [PATCH v7 04/11] dump-guest-memory: add dump_in_progress() helper function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: drjones@redhat.com, famz@redhat.com, armbru@redhat.com, peterx@redhat.com, lcapitulino@redhat.com, pbonzini@redhat.com, lersek@redhat.com 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 434bc60..158d6ea 100644 --- a/dump.c +++ b/dump.c @@ -1450,6 +1450,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) @@ -1628,6 +1634,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 f557be7..59ab759 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -494,4 +494,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 6ae7230..f4caf5a 100644 --- a/qmp.c +++ b/qmp.c @@ -103,6 +103,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 { @@ -175,6 +182,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; -- 2.4.3