|
|
77609c |
From d1c6d059f8936adf7b8c3e2b29b2eb290b0792ac Mon Sep 17 00:00:00 2001
|
|
|
77609c |
From: Peter Xu <peterx@redhat.com>
|
|
|
77609c |
Date: Wed, 22 Sep 2021 12:20:09 -0400
|
|
|
77609c |
Subject: [PATCH 3/6] dump-guest-memory: Block live migration
|
|
|
77609c |
MIME-Version: 1.0
|
|
|
77609c |
Content-Type: text/plain; charset=UTF-8
|
|
|
77609c |
Content-Transfer-Encoding: 8bit
|
|
|
77609c |
|
|
|
77609c |
RH-Author: Peter Xu <peterx@redhat.com>
|
|
|
77609c |
RH-MergeRequest: 51: dump-guest-memory: Add blocker for migration
|
|
|
77609c |
RH-Commit: [3/3] 711dcc0018f70bcb87496c5aa235633a6daf5c2d (peterx/qemu-kvm)
|
|
|
77609c |
RH-Bugzilla: 1996609
|
|
|
77609c |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
77609c |
RH-Acked-by: quintela1 <quintela@redhat.com>
|
|
|
77609c |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
77609c |
|
|
|
77609c |
Both dump-guest-memory and live migration caches vm state at the beginning.
|
|
|
77609c |
Either of them entering the other one will cause race on the vm state, and even
|
|
|
77609c |
more severe on that (please refer to the crash report in the bug link).
|
|
|
77609c |
|
|
|
77609c |
Let's block live migration in dump-guest-memory, and that'll also block
|
|
|
77609c |
dump-guest-memory if it detected that we're during a live migration.
|
|
|
77609c |
|
|
|
77609c |
Side note: migrate_del_blocker() can be called even if the blocker is not
|
|
|
77609c |
inserted yet, so it's safe to unconditionally delete that blocker in
|
|
|
77609c |
dump_cleanup (g_slist_remove allows no-entry-found case).
|
|
|
77609c |
|
|
|
77609c |
Suggested-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
77609c |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1996609
|
|
|
77609c |
Signed-off-by: Peter Xu <peterx@redhat.com>
|
|
|
77609c |
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
77609c |
Reviewed-by: Juan Quintela <quintela@redhat.com>
|
|
|
77609c |
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
|
77609c |
(cherry picked from commit b7bc6b182883bb3097dde2a25d041f28bde2b89c)
|
|
|
77609c |
Signed-off-by: Peter Xu <peterx@redhat.com>
|
|
|
77609c |
---
|
|
|
77609c |
dump/dump.c | 19 +++++++++++++++++++
|
|
|
77609c |
1 file changed, 19 insertions(+)
|
|
|
77609c |
|
|
|
77609c |
diff --git a/dump/dump.c b/dump/dump.c
|
|
|
77609c |
index ab625909f3..662d0a62cd 100644
|
|
|
77609c |
--- a/dump/dump.c
|
|
|
77609c |
+++ b/dump/dump.c
|
|
|
77609c |
@@ -29,6 +29,7 @@
|
|
|
77609c |
#include "qemu/error-report.h"
|
|
|
77609c |
#include "qemu/main-loop.h"
|
|
|
77609c |
#include "hw/misc/vmcoreinfo.h"
|
|
|
77609c |
+#include "migration/blocker.h"
|
|
|
77609c |
|
|
|
77609c |
#ifdef TARGET_X86_64
|
|
|
77609c |
#include "win_dump.h"
|
|
|
77609c |
@@ -47,6 +48,8 @@
|
|
|
77609c |
|
|
|
77609c |
#define MAX_GUEST_NOTE_SIZE (1 << 20) /* 1MB should be enough */
|
|
|
77609c |
|
|
|
77609c |
+static Error *dump_migration_blocker;
|
|
|
77609c |
+
|
|
|
77609c |
#define ELF_NOTE_SIZE(hdr_size, name_size, desc_size) \
|
|
|
77609c |
((DIV_ROUND_UP((hdr_size), 4) + \
|
|
|
77609c |
DIV_ROUND_UP((name_size), 4) + \
|
|
|
77609c |
@@ -101,6 +104,7 @@ static int dump_cleanup(DumpState *s)
|
|
|
77609c |
qemu_mutex_unlock_iothread();
|
|
|
77609c |
}
|
|
|
77609c |
}
|
|
|
77609c |
+ migrate_del_blocker(dump_migration_blocker);
|
|
|
77609c |
|
|
|
77609c |
return 0;
|
|
|
77609c |
}
|
|
|
77609c |
@@ -2005,6 +2009,21 @@ void qmp_dump_guest_memory(bool paging, const char *file,
|
|
|
77609c |
return;
|
|
|
77609c |
}
|
|
|
77609c |
|
|
|
77609c |
+ if (!dump_migration_blocker) {
|
|
|
77609c |
+ error_setg(&dump_migration_blocker,
|
|
|
77609c |
+ "Live migration disabled: dump-guest-memory in progress");
|
|
|
77609c |
+ }
|
|
|
77609c |
+
|
|
|
77609c |
+ /*
|
|
|
77609c |
+ * Allows even for -only-migratable, but forbid migration during the
|
|
|
77609c |
+ * process of dump guest memory.
|
|
|
77609c |
+ */
|
|
|
77609c |
+ if (migrate_add_blocker_internal(dump_migration_blocker, errp)) {
|
|
|
77609c |
+ /* Remember to release the fd before passing it over to dump state */
|
|
|
77609c |
+ close(fd);
|
|
|
77609c |
+ return;
|
|
|
77609c |
+ }
|
|
|
77609c |
+
|
|
|
77609c |
s = &dump_state_global;
|
|
|
77609c |
dump_state_prepare(s);
|
|
|
77609c |
|
|
|
77609c |
--
|
|
|
77609c |
2.27.0
|
|
|
77609c |
|