yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-dump-guest-memory-add-dump_in_progress-helper-functi.patch

5d360b
From 68ed14180549185ab27c37baacd47843ae45511c Mon Sep 17 00:00:00 2001
5d360b
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
5d360b
Date: Wed, 13 Dec 2017 13:38:56 +0100
5d360b
Subject: [PATCH 25/41] dump-guest-memory: add dump_in_progress() helper
5d360b
 function
5d360b
MIME-Version: 1.0
5d360b
Content-Type: text/plain; charset=UTF-8
5d360b
Content-Transfer-Encoding: 8bit
5d360b
5d360b
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
5d360b
Message-id: <20171213133912.26176-26-marcandre.lureau@redhat.com>
5d360b
Patchwork-id: 78376
5d360b
O-Subject: [RHEL-7.5 qemu-kvm PATCH v3 25/41] dump-guest-memory: add dump_in_progress() helper function
5d360b
Bugzilla: 1411490
5d360b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
5d360b
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
5d360b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
5d360b
From: Peter Xu <peterx@redhat.com>
5d360b
5d360b
For now, it has no effect. It will be used in dump detach support.
5d360b
5d360b
Signed-off-by: Peter Xu <peterx@redhat.com>
5d360b
Reviewed-by: Fam Zheng <famz@redhat.com>
5d360b
Message-Id: <1455772616-8668-5-git-send-email-peterx@redhat.com>
5d360b
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5d360b
5d360b
(cherry picked from commit 65d64f362326a57b590b8b76e3422030a2aa5c44)
5d360b
5d360b
RHEL: minor conflict in function declaration area.
5d360b
5d360b
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5d360b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
---
5d360b
 dump.c                | 13 +++++++++++++
5d360b
 include/qemu-common.h |  4 ++++
5d360b
 qmp.c                 | 14 ++++++++++++++
5d360b
 3 files changed, 31 insertions(+)
5d360b
5d360b
diff --git a/dump.c b/dump.c
5d360b
index 254c0ba..639d52a 100644
5d360b
--- a/dump.c
5d360b
+++ b/dump.c
5d360b
@@ -1455,6 +1455,12 @@ static void dump_state_prepare(DumpState *s)
5d360b
     *s = (DumpState) { .status = DUMP_STATUS_ACTIVE };
5d360b
 }
5d360b
 
5d360b
+bool dump_in_progress(void)
5d360b
+{
5d360b
+    DumpState *state = &dump_state_global;
5d360b
+    return (state->status == DUMP_STATUS_ACTIVE);
5d360b
+}
5d360b
+
5d360b
 static void dump_init(DumpState *s, int fd, bool has_format,
5d360b
                       DumpGuestMemoryFormat format, bool paging, bool has_filter,
5d360b
                       int64_t begin, int64_t length, Error **errp)
5d360b
@@ -1632,6 +1638,13 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
5d360b
     DumpState *s;
5d360b
     Error *local_err = NULL;
5d360b
 
5d360b
+    /* if there is a dump in background, we should wait until the dump
5d360b
+     * finished */
5d360b
+    if (dump_in_progress()) {
5d360b
+        error_setg(errp, "There is a dump in process, please wait.");
5d360b
+        return;
5d360b
+    }
5d360b
+
5d360b
     /*
5d360b
      * kdump-compressed format need the whole memory dumped, so paging or
5d360b
      * filter is not supported here.
5d360b
diff --git a/include/qemu-common.h b/include/qemu-common.h
5d360b
index 8c1132c..4569d52 100644
5d360b
--- a/include/qemu-common.h
5d360b
+++ b/include/qemu-common.h
5d360b
@@ -481,4 +481,8 @@ size_t buffer_find_nonzero_offset(const void *buf, size_t len);
5d360b
  */
5d360b
 int parse_debug_env(const char *name, int max, int initial);
5d360b
 
5d360b
+/* returns non-zero if dump is in progress, otherwise zero is
5d360b
+ * returned. */
5d360b
+bool dump_in_progress(void);
5d360b
+
5d360b
 #endif
5d360b
diff --git a/qmp.c b/qmp.c
5d360b
index 4c149b3..5996056 100644
5d360b
--- a/qmp.c
5d360b
+++ b/qmp.c
5d360b
@@ -87,6 +87,13 @@ void qmp_quit(Error **err)
5d360b
 
5d360b
 void qmp_stop(Error **errp)
5d360b
 {
5d360b
+    /* if there is a dump in background, we should wait until the dump
5d360b
+     * finished */
5d360b
+    if (dump_in_progress()) {
5d360b
+        error_setg(errp, "There is a dump in process, please wait.");
5d360b
+        return;
5d360b
+    }
5d360b
+
5d360b
     if (runstate_check(RUN_STATE_INMIGRATE)) {
5d360b
         autostart = 0;
5d360b
     } else {
5d360b
@@ -159,6 +166,13 @@ void qmp_cont(Error **errp)
5d360b
 {
5d360b
     Error *local_err = NULL;
5d360b
 
5d360b
+    /* if there is a dump in background, we should wait until the dump
5d360b
+     * finished */
5d360b
+    if (dump_in_progress()) {
5d360b
+        error_setg(errp, "There is a dump in process, please wait.");
5d360b
+        return;
5d360b
+    }
5d360b
+
5d360b
     if (runstate_needs_reset()) {
5d360b
         error_set(errp, QERR_RESET_REQUIRED);
5d360b
         return;
5d360b
-- 
5d360b
1.8.3.1
5d360b