summaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2026-06-19 12:18:30 +0200
committerMarc-André Lureau <marcandre.lureau@redhat.com>2026-06-30 19:12:59 +0400
commit19e8b596263c2ee966a4e45f0ffbc9bb08b55409 (patch)
tree47985494f35b06febcf47e143f7e4006e7d04583 /system
parent9d9d449180f2f2589718a31292c8deaf9cf78ff3 (diff)
downloadqemu-19e8b596263c2ee966a4e45f0ffbc9bb08b55409.tar.gz
qemu-19e8b596263c2ee966a4e45f0ffbc9bb08b55409.zip
system/cpus: refuse memsave/pmemsave while guest RAM is being migrated
memsave and pmemsave read guest memory and write it to a file, with no guard at all. They run on the main thread with the BQL held, so on a postcopy destination touching a not-yet-received page deadlocks: the thread blocks on the userfault while the postcopy incoming path waits for the BQL to install that page. During precopy the read returns incomplete state instead. Refuse both while guest RAM is still being received, using the same migration_guest_ram_loading() check as dump-guest-memory. Signed-off-by: Denis V. Lunev <den@openvz.org> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20260619101834.228432-4-den@openvz.org>
Diffstat (limited to 'system')
-rw-r--r--system/cpus.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/system/cpus.c b/system/cpus.c
index 49f6daec3c..b31c825b46 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -43,6 +43,7 @@
#include "system/physmem.h"
#include "system/replay.h"
#include "system/runstate.h"
+#include "migration/misc.h"
#include "system/cpu-timers.h"
#include "system/whpx.h"
#include "hw/core/boards.h"
@@ -843,6 +844,11 @@ void qmp_memsave(uint64_t addr, uint64_t size, const char *filename,
uint8_t buf[1024];
uint64_t orig_addr = addr, orig_size = size;
+ if (migration_guest_ram_loading()) {
+ error_setg(errp, "Guest memory access not allowed during migration");
+ return;
+ }
+
if (!has_cpu) {
cpu_index = 0;
}
@@ -889,6 +895,11 @@ void qmp_pmemsave(uint64_t addr, uint64_t size, const char *filename,
uint64_t l;
uint8_t buf[1024];
+ if (migration_guest_ram_loading()) {
+ error_setg(errp, "Guest memory access not allowed during migration");
+ return;
+ }
+
f = fopen(filename, "wb");
if (!f) {
error_setg_file_open(errp, errno, filename);