Skip to contentSkip to conversation

Workaround (possible) QEMU migration bug

RFC PATCH New Nicholas Piggin 1 participant 1 message Feb 17, 2024 KVM

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Workaround (possible) QEMU migration bug

Recent updates to machine memory can seemingly be lost across QEMU TCG migration. This patch stops the machine on the source before migrating, after which the problem can no longer be reproduced.

This isn't arm64 specific, powerpc could also see corruption using the reproducer. It must be just that it's getchar implementation was different enough that it didn't show up there.

arm64 runs the migration selftest okay with this and the uart patch.

I'll try to work out a simpler reproducer patch to report the QEMU issue with, but in the meantime a sanity check and any suggestions about this would be appreciated.

Thanks,
Nick

---
 common/selftest-migration.c | 5 -----
 scripts/arch-run.bash       | 5 +++++
 2 files changed, 5 insertions(+), 5 deletions(-)
common/selftest-migration.c +0 -5
index 02b102cc5..dd36696fd 100644
@@ -10,12 +10,7 @@
 #include <libcflat.h>
 #include <migrate.h>
 
-#if defined(__arm__) || defined(__aarch64__)
-/* arm can only call getchar 15 times */
-#define NR_MIGRATIONS 15
-#else
 #define NR_MIGRATIONS 100
-#endif
 
 int main(int argc, char **argv)
 {
scripts/arch-run.bash +5 -0
index 2214d940c..0d6950c26 100644
@@ -209,6 +209,9 @@ do_migration ()
 	while ! [ -S ${dst_incoming} ] ; do sleep 0.1 ; done
 	while ! [ -S ${dst_qmp} ] ; do sleep 0.1 ; done
 
+	# Stop the machine before migration. This works around a QEMU
+	# problem with memory updates being lost.
+	qmp ${src_qmp} '"stop"' > ${src_qmpout}
 	qmp ${src_qmp} '"migrate", "arguments": { "uri": "unix:'${dst_incoming}'" }' > ${src_qmpout}
 
 	# Wait for the migration to complete
@@ -232,6 +235,8 @@ do_migration ()
 	done
 
 	qmp ${src_qmp} '"quit"'> ${src_qmpout} 2>/dev/null
+	# Resume the machine after migrate.
+	qmp ${dst_qmp} '"cont"' > ${dst_qmpout}
 
 	# keypress to dst so getchar completes and test continues
 	echo > ${dst_infifo}
Signature · 1 line
2.42.0