Multi-migration support
Subsystems (6)
v5 cover Multi-migration support
Now that strange arm64 hang is found to be QEMU bug, I'll repost. Since arm64 requires Thomas's uart patch and it is worse affected by the QEMU bug, I will just not build it on arm. The QEMU bug still affects powerpc (and presumably s390x) but it's not causing so much trouble for this test case.
I have another test case that can hit it reliably and doesn't cause crashes but that takes some harness and common lib work so I'll send that another time.
Since v4:
- Don't build selftest-migration on arm.
- Reduce selftest-migration iterations from 100 to 30 to make the test run faster (it's ~0.5s per migration).
Since v3:
- Addressed Thomas's review comments:
- Patch 2 initrd cleanup unset the old variable in the correct place.
- Patch 4 multi migration removed the extra wait for "Now migrate the VM" message, and updated comments around it.
- Patch 6 fix typo and whitespace in quiet migration support.
- Patch 8 fix typo and whitespace in migration selftest.
Since v2:
- Rebase on riscv port and auxvinfo fix was merged.
- Clean up initrd cleanup moves more commands into the new cleanup function from the trap handler comands (suggested by Thomas).
- "arch-run: Clean up temporary files properly" patch is now renamed to "arch-run: Fix TRAP handler..."
- Fix TRAP handler patch has redone changelog to be more precise about the problem and including recipe to recreate it.
- Fix TRAP handler patch reworked slightly to remove the theoretical race rather than just adding a comment about it.
- Patch 3 was missing a couple of fixes that leaked into patch 4, those are moved into patch 3.
Thanks,
Nick
Nicholas Piggin (8):
arch-run: Fix TRAP handler recursion to remove temporary files
properly
arch-run: Clean up initrd cleanup
migration: use a more robust way to wait for background job
migration: Support multiple migrations
arch-run: rename migration variables
migration: Add quiet migration support
Add common/ directory for architecture-independent tests
migration: add a migration selftest
arm/sieve.c | 2 +- common/selftest-migration.c | 29 ++++++ common/sieve.c | 51 ++++++++++ lib/migrate.c | 19 +++- lib/migrate.h | 2 + powerpc/Makefile.common | 1 + powerpc/selftest-migration.c | 1 + powerpc/unittests.cfg | 4 + riscv/sieve.c | 2 +- s390x/Makefile | 1 + s390x/selftest-migration.c | 1 + s390x/sieve.c | 2 +- s390x/unittests.cfg | 4 + scripts/arch-run.bash | 177 +++++++++++++++++++++++++---------- x86/sieve.c | 52 +--------- 15 files changed, 240 insertions(+), 108 deletions(-) create mode 100644 common/selftest-migration.c create mode 100644 common/sieve.c create mode 120000 powerpc/selftest-migration.c create mode 120000 s390x/selftest-migration.c mode change 100644 => 120000 x86/sieve.c
Signature · 1 line
2.42.0
PATCH v5 1/8 arch-run: Fix TRAP handler recursion to remove temporary files properly
Migration files were not being removed when the QEMU process is interrupted (e.g., with ^C). This is becaus the SIGINT propagates to the bash TRAP handler, which recursively TRAPs due to the 'kill 0' in the handler. This eventually crashes bash.
This can be observed by interrupting a long-running test program that is run with MIGRATION=yes, /tmp/mig-helper-* files remain afterwards.
Removing TRAP recursion solves this problem and allows the EXIT handler to run and clean up the files.
This also moves the trap handler before temp file creation, which closes the small race between creation trap handler install.
--- scripts/arch-run.bash | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
scripts/arch-run.bash +6 -6
@@ -129,6 +129,9 @@ run_migration () return 77 fi + trap 'trap - TERM ; kill 0 ; exit 2' INT TERM + trap 'rm -f ${migout1} ${migsock} ${qmp1} ${qmp2} ${fifo}' RETURN EXIT + migsock=$(mktemp -u -t mig-helper-socket.XXXXXXXXXX) migout1=$(mktemp -t mig-helper-stdout1.XXXXXXXXXX) qmp1=$(mktemp -u -t mig-helper-qmp1.XXXXXXXXXX)
@@ -137,9 +140,6 @@ run_migration () qmpout1=/dev/null qmpout2=/dev/null - trap 'kill 0; exit 2' INT TERM - trap 'rm -f ${migout1} ${migsock} ${qmp1} ${qmp2} ${fifo}' RETURN EXIT - eval "$@" -chardev socket,id=mon1,path=${qmp1},server=on,wait=off \ -mon chardev=mon1,mode=control | tee ${migout1} & live_pid=`jobs -l %+ | grep "eval" | awk '{print$2}'`
@@ -209,11 +209,11 @@ run_panic () return 77 fi - qmp=$(mktemp -u -t panic-qmp.XXXXXXXXXX) - - trap 'kill 0; exit 2' INT TERM + trap 'trap - TERM ; kill 0 ; exit 2' INT TERM trap 'rm -f ${qmp}' RETURN EXIT + qmp=$(mktemp -u -t panic-qmp.XXXXXXXXXX) + # start VM stopped so we don't miss any events eval "$@" -chardev socket,id=mon1,path=${qmp},server=on,wait=off \ -mon chardev=mon1,mode=control -S &
Signature · 1 line
2.42.0
PATCH v5 2/8 arch-run: Clean up initrd cleanup
In reply to Nicholas PigginRather than put a big script into the trap handler, have it call a function.
--- scripts/arch-run.bash | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
scripts/arch-run.bash +12 -1
@@ -269,10 +269,21 @@ search_qemu_binary () export PATH=$save_path } +initrd_cleanup () +{ + rm -f $KVM_UNIT_TESTS_ENV + if [ "$KVM_UNIT_TESTS_ENV_OLD" ]; then + export KVM_UNIT_TESTS_ENV="$KVM_UNIT_TESTS_ENV_OLD" + else + unset KVM_UNIT_TESTS_ENV + fi + unset KVM_UNIT_TESTS_ENV_OLD +} + initrd_create () { if [ "$ENVIRON_DEFAULT" = "yes" ]; then - trap_exit_push 'rm -f $KVM_UNIT_TESTS_ENV; [ "$KVM_UNIT_TESTS_ENV_OLD" ] && export KVM_UNIT_TESTS_ENV="$KVM_UNIT_TESTS_ENV_OLD" || unset KVM_UNIT_TESTS_ENV; unset KVM_UNIT_TESTS_ENV_OLD' + trap_exit_push 'initrd_cleanup' [ -f "$KVM_UNIT_TESTS_ENV" ] && export KVM_UNIT_TESTS_ENV_OLD="$KVM_UNIT_TESTS_ENV" export KVM_UNIT_TESTS_ENV=$(mktemp) env_params
Signature · 1 line
2.42.0
PATCH v5 3/8 migration: use a more robust way to wait for background job
In reply to Nicholas PigginStarting a pipeline of jobs in the background does not seem to have a simple way to reliably find the pid of a particular process in the pipeline (because not all processes are started when the shell continues to execute).
The way PID of QEMU is derived can result in a failure waiting on a PID that is not running. This is easier to hit with subsequent multiple-migration support. Changing this to use $! by swapping the pipeline for a fifo is more robust.
--- scripts/arch-run.bash | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
scripts/arch-run.bash +11 -4
@@ -130,19 +130,22 @@ run_migration () fi trap 'trap - TERM ; kill 0 ; exit 2' INT TERM - trap 'rm -f ${migout1} ${migsock} ${qmp1} ${qmp2} ${fifo}' RETURN EXIT + trap 'rm -f ${migout1} ${migout_fifo1} ${migsock} ${qmp1} ${qmp2} ${fifo}' RETURN EXIT migsock=$(mktemp -u -t mig-helper-socket.XXXXXXXXXX) migout1=$(mktemp -t mig-helper-stdout1.XXXXXXXXXX) + migout_fifo1=$(mktemp -u -t mig-helper-fifo-stdout1.XXXXXXXXXX) qmp1=$(mktemp -u -t mig-helper-qmp1.XXXXXXXXXX) qmp2=$(mktemp -u -t mig-helper-qmp2.XXXXXXXXXX) fifo=$(mktemp -u -t mig-helper-fifo.XXXXXXXXXX) qmpout1=/dev/null qmpout2=/dev/null + mkfifo ${migout_fifo1} eval "$@" -chardev socket,id=mon1,path=${qmp1},server=on,wait=off \ - -mon chardev=mon1,mode=control | tee ${migout1} & - live_pid=`jobs -l %+ | grep "eval" | awk '{print$2}'` + -mon chardev=mon1,mode=control > ${migout_fifo1} & + live_pid=$! + cat ${migout_fifo1} | tee ${migout1} & # We have to use cat to open the named FIFO, because named FIFO's, unlike # pipes, will block on open() until the other end is also opened, and that
@@ -150,7 +153,7 @@ run_migration () mkfifo ${fifo} eval "$@" -chardev socket,id=mon2,path=${qmp2},server=on,wait=off \ -mon chardev=mon2,mode=control -incoming unix:${migsock} < <(cat ${fifo}) & - incoming_pid=`jobs -l %+ | awk '{print$2}'` + incoming_pid=$! # The test must prompt the user to migrate, so wait for the "migrate" keyword while ! grep -q -i "Now migrate the VM" < ${migout1} ; do
@@ -164,6 +167,10 @@ run_migration () sleep 1 done + # Wait until the destination has created the incoming and qmp sockets + while ! [ -S ${migsock} ] ; do sleep 0.1 ; done + while ! [ -S ${qmp2} ] ; do sleep 0.1 ; done + qmp ${qmp1} '"migrate", "arguments": { "uri": "unix:'${migsock}'" }' > ${qmpout1} # Wait for the migration to complete
Signature · 1 line
2.42.0
PATCH v5 4/8 migration: Support multiple migrations
In reply to Nicholas PigginSupport multiple migrations by flipping dest file/socket variables to source after the migration is complete, ready to start again. A new destination is created if the test outputs the migrate line again. Test cases may now switch to calling migrate() one or more times.
--- lib/migrate.c | 8 ++-- lib/migrate.h | 1 + scripts/arch-run.bash | 86 ++++++++++++++++++++++++++++++++++++------- 3 files changed, 77 insertions(+), 18 deletions(-)
lib/migrate.c +4 -4
@@ -8,8 +8,10 @@#include <libcflat.h> #include "migrate.h" -/* static for now since we only support migrating exactly once per test. */ -static void migrate (void ) +/* +* Initiate migration and wait for it to complete. +*/ +void migrate (void ) {puts ("Now migrate the VM, then press a key to continue...\n" ); (void )getchar ();
@@ -19,8 +21,6 @@ static void migrate(void)/* * Initiate migration and wait for it to complete. * If this function is called more than once, it is a no-op. -* Since migrate_cmd can only migrate exactly once this function can -* simplify the control flow, especially when skipping tests. */ void migrate_once (void ) {
lib/migrate.h +1 -0
@@ -6,4 +6,5 @@* Author: Nico Boehr <[email protected]> */ +void migrate (void );void migrate_once (void );
scripts/arch-run.bash +72 -14
132 lines not on this page · raw message
Signature · 1 line
2.42.0
PATCH v5 5/8 arch-run: rename migration variables
In reply to Nicholas PigginUsing 1 and 2 for source and destination is confusing, particularly now with multiple migrations that flip between them. Do a rename pass to 'src' and 'dst' to tidy things up.
--- scripts/arch-run.bash | 111 +++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 55 deletions(-)
scripts/arch-run.bash +56 -55
@@ -132,27 +132,27 @@ run_migration () migcmdline=$@ trap 'trap - TERM ; kill 0 ; exit 2' INT TERM - trap 'rm -f ${migout1} ${migout2} ${migout_fifo1} ${migout_fifo2} ${migsock} ${qmp1} ${qmp2} ${fifo}' RETURN EXIT - - migsock=$(mktemp -u -t mig-helper-socket.XXXXXXXXXX) - migout1=$(mktemp -t mig-helper-stdout1.XXXXXXXXXX) - migout_fifo1=$(mktemp -u -t mig-helper-fifo-stdout1.XXXXXXXXXX) - migout2=$(mktemp -t mig-helper-stdout2.XXXXXXXXXX) - migout_fifo2=$(mktemp -u -t mig-helper-fifo-stdout2.XXXXXXXXXX) - qmp1=$(mktemp -u -t mig-helper-qmp1.XXXXXXXXXX) - qmp2=$(mktemp -u -t mig-helper-qmp2.XXXXXXXXXX) - fifo=$(mktemp -u -t mig-helper-fifo.XXXXXXXXXX) - qmpout1=/dev/null - qmpout2=/dev/null - - mkfifo ${migout_fifo1} - mkfifo ${migout_fifo2} + trap 'rm -f ${src_out} ${dst_out} ${src_outfifo} ${dst_outfifo} ${dst_incoming} ${src_qmp} ${dst_qmp} ${dst_infifo}' RETURN EXIT + + dst_incoming=$(mktemp -u -t mig-helper-socket-incoming.XXXXXXXXXX) + src_out=$(mktemp -t mig-helper-stdout1.XXXXXXXXXX) + src_outfifo=$(mktemp -u -t mig-helper-fifo-stdout1.XXXXXXXXXX) + dst_out=$(mktemp -t mig-helper-stdout2.XXXXXXXXXX) + dst_outfifo=$(mktemp -u -t mig-helper-fifo-stdout2.XXXXXXXXXX) + src_qmp=$(mktemp -u -t mig-helper-qmp1.XXXXXXXXXX) + dst_qmp=$(mktemp -u -t mig-helper-qmp2.XXXXXXXXXX) + dst_infifo=$(mktemp -u -t mig-helper-fifo-stdin.XXXXXXXXXX) + src_qmpout=/dev/null + dst_qmpout=/dev/null + + mkfifo ${src_outfifo} + mkfifo ${dst_outfifo} eval "$migcmdline" \ - -chardev socket,id=mon1,path=${qmp1},server=on,wait=off \ - -mon chardev=mon1,mode=control > ${migout_fifo1} & + -chardev socket,id=mon,path=${src_qmp},server=on,wait=off \ + -mon chardev=mon,mode=control > ${src_outfifo} & live_pid=$! - cat ${migout_fifo1} | tee ${migout1} & + cat ${src_outfifo} | tee ${src_out} & # Start the first destination QEMU machine in advance of the test # reaching the migration point, since we expect at least one migration.
@@ -162,7 +162,7 @@ run_migration () while ps -p ${live_pid} > /dev/null ; do # Wait for test exit or further migration messages. - if ! grep -q -i "Now migrate the VM" < ${migout1} ; then + if ! grep -q -i "Now migrate the VM" < ${src_out} ; then sleep 0.1 else do_migration || return $?
@@ -184,80 +184,81 @@ do_migration () # We have to use cat to open the named FIFO, because named FIFO's, # unlike pipes, will block on open() until the other end is also # opened, and that totally breaks QEMU... - mkfifo ${fifo} + mkfifo ${dst_infifo} eval "$migcmdline" \ - -chardev socket,id=mon2,path=${qmp2},server=on,wait=off \ - -mon chardev=mon2,mode=control -incoming unix:${migsock} \ - < <(cat ${fifo}) > ${migout_fifo2} & + -chardev socket,id=mon,path=${dst_qmp},server=on,wait=off \ + -mon chardev=mon,mode=control -incoming unix:${dst_incoming} \ + < <(cat ${dst_infifo}) > ${dst_outfifo} & incoming_pid=$! - cat ${migout_fifo2} | tee ${migout2} & + cat ${dst_outfifo} | tee ${dst_out} & # The test must prompt the user to migrate, so wait for the # "Now migrate VM" console message. - while ! grep -q -i "Now migrate the VM" < ${migout1} ; do + while ! grep -q -i "Now migrate the VM" < ${src_out} ; do if ! ps -p ${live_pid} > /dev/null ; then echo "ERROR: Test exit before migration point." >&2 - echo > ${fifo} - qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null - qmp ${qmp2} '"quit"'> ${qmpout2} 2>/dev/null + echo > ${dst_infifo} + qmp ${src_qmp} '"quit"'> ${src_qmpout} 2>/dev/null + qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null return 3 fi sleep 0.1 done # Wait until the destination has created the incoming and qmp sockets - while ! [ -S ${migsock} ] ; do sleep 0.1 ; done - while ! [ -S ${qmp2} ] ; do sleep 0.1 ; done + while ! [ -S ${dst_incoming} ] ; do sleep 0.1 ; done + while ! [ -S ${dst_qmp} ] ; do sleep 0.1 ; done - qmp ${qmp1} '"migrate", "arguments": { "uri": "unix:'${migsock}'" }' > ${qmpout1} + qmp ${src_qmp} '"migrate", "arguments": { "uri": "unix:'${dst_incoming}'" }' > ${src_qmpout} # Wait for the migration to complete - migstatus=`qmp ${qmp1} '"query-migrate"' | grep return` + migstatus=`qmp ${src_qmp} '"query-migrate"' | grep return` while ! grep -q '"completed"' <<<"$migstatus" ; do sleep 0.1 - if ! migstatus=`qmp ${qmp1} '"query-migrate"'`; then + if ! migstatus=`qmp ${src_qmp} '"query-migrate"'`; then echo "ERROR: Querying migration state failed." >&2 - echo > ${fifo} - qmp ${qmp2} '"quit"'> ${qmpout2} 2>/dev/null + echo > ${dst_infifo} + qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null return 2 fi migstatus=`grep return <<<"$migstatus"` if grep -q '"failed"' <<<"$migstatus"; then echo "ERROR: Migration failed." >&2 - echo > ${fifo} - qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null - qmp ${qmp2} '"quit"'> ${qmpout2} 2>/dev/null + echo > ${dst_infifo} + qmp ${src_qmp} '"quit"'> ${src_qmpout} 2>/dev/null + qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null return 2 fi done - qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null + qmp ${src_qmp} '"quit"'> ${src_qmpout} 2>/dev/null # keypress to dst so getchar completes and test continues - echo > ${fifo} - rm ${fifo} + echo > ${dst_infifo} + rm ${dst_infifo} # Ensure the incoming socket is removed, ready for next destination - if [ -S ${migsock} ] ; then + if [ -S ${dst_incoming} ] ; then echo "ERROR: Incoming migration socket not removed after migration." >& 2 - qmp ${qmp2} '"quit"'> ${qmpout2} 2>/dev/null + qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null return 2 fi wait ${live_pid} ret=$? - # Now flip the variables because dest becomes source + # Now flip the variables because destination machine becomes source + # for the next migration. live_pid=${incoming_pid} - tmp=${migout1} - migout1=${migout2} - migout2=${tmp} - tmp=${migout_fifo1} - migout_fifo1=${migout_fifo2} - migout_fifo2=${tmp} - tmp=${qmp1} - qmp1=${qmp2} - qmp2=${tmp} + tmp=${src_out} + src_out=${dst_out} + dst_out=${tmp} + tmp=${src_outfifo} + src_outfifo=${dst_outfifo} + dst_outfifo=${tmp} + tmp=${src_qmp} + src_qmp=${dst_qmp} + dst_qmp=${tmp} return $ret }
@@ -280,8 +281,8 @@ run_panic () qmp=$(mktemp -u -t panic-qmp.XXXXXXXXXX) # start VM stopped so we don't miss any events - eval "$@" -chardev socket,id=mon1,path=${qmp},server=on,wait=off \ - -mon chardev=mon1,mode=control -S & + eval "$@" -chardev socket,id=mon,path=${qmp},server=on,wait=off \ + -mon chardev=mon,mode=control -S & panic_event_count=$(qmp_events ${qmp} | jq -c 'select(.event == "GUEST_PANICKED")' | wc -l) if [ "$panic_event_count" -lt 1 ]; then
Signature · 1 line
2.42.0
PATCH v5 6/8 migration: Add quiet migration support
In reply to Nicholas PigginConsole output required to support migration becomes quite noisy when doing lots of migrations. Provide a migrate_quiet() call that suppresses console output and doesn't log a message.
--- lib/migrate.c | 11 +++++++++++ lib/migrate.h | 1 + scripts/arch-run.bash | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-)
lib/migrate.c +11 -0
@@ -18,6 +18,17 @@ void migrate(void)report_info ("Migration complete" ); } +/* +* Like migrate() but suppress output and logs, useful for intensive +* migration stress testing without polluting logs. Test cases should +* provide relevant information about migration in failure reports. +*/ +void migrate_quiet (void ) +{ +puts ("Now migrate the VM (quiet)\n" ); + (void )getchar (); +} +/* * Initiate migration and wait for it to complete. * If this function is called more than once, it is a no-op.
lib/migrate.h +1 -0
@@ -7,4 +7,5 @@*/ void migrate (void ); +void migrate_quiet (void );void migrate_once (void );
scripts/arch-run.bash +2 -2
@@ -152,7 +152,7 @@ run_migration () -chardev socket,id=mon,path=${src_qmp},server=on,wait=off \ -mon chardev=mon,mode=control > ${src_outfifo} & live_pid=$! - cat ${src_outfifo} | tee ${src_out} & + cat ${src_outfifo} | tee ${src_out} | grep -v "Now migrate the VM (quiet)" & # Start the first destination QEMU machine in advance of the test # reaching the migration point, since we expect at least one migration.
@@ -190,7 +190,7 @@ do_migration () -mon chardev=mon,mode=control -incoming unix:${dst_incoming} \ < <(cat ${dst_infifo}) > ${dst_outfifo} & incoming_pid=$! - cat ${dst_outfifo} | tee ${dst_out} & + cat ${dst_outfifo} | tee ${dst_out} | grep -v "Now migrate the VM (quiet)" & # The test must prompt the user to migrate, so wait for the # "Now migrate VM" console message.
Signature · 1 line
2.42.0
PATCH v5 7/8 Add common/ directory for architecture-independent tests
In reply to Nicholas Pigginx86/sieve.c is used by s390x, arm, and riscv via symbolic link. Make a new directory common/ for architecture-independent tests and move sieve.c here.
--- arm/sieve.c | 2 +- common/sieve.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ riscv/sieve.c | 2 +- s390x/sieve.c | 2 +- x86/sieve.c | 52 +------------------------------------------------- 5 files changed, 55 insertions(+), 54 deletions(-) create mode 100644 common/sieve.c mode change 100644 => 120000 x86/sieve.c
arm/sieve.c +1 -1
@@ -1 +1 @@ -../x86/sieve.c +../common/sieve.c
common/sieve.c new file +51 -0
51 lines not on this page · raw message
riscv/sieve.c +1 -1
@@ -1 +1 @@ -../x86/sieve.c +../common/sieve.c
s390x/sieve.c +1 -1
@@ -1 +1 @@ -../x86/sieve.c +../common/sieve.c
x86/sieve.c deleted +0 -51
51 lines not on this page · raw message
x86/sieve.c new file +1 -0
@@ -0,0 +1 @@ +../common/sieve.c
Signature · 1 line
2.42.0
PATCH v5 8/8 migration: add a migration selftest
In reply to Nicholas PigginAdd a selftest for migration support in guest library and test harness code. It performs migrations in a tight loop to irritate races and bugs in the test harness code.
Include the test in s390, powerpc.
--- common/selftest-migration.c | 29 +++++++++++++++++++++++++++++ powerpc/Makefile.common | 1 + powerpc/selftest-migration.c | 1 + powerpc/unittests.cfg | 4 ++++ s390x/Makefile | 1 + s390x/selftest-migration.c | 1 + s390x/unittests.cfg | 4 ++++ 7 files changed, 41 insertions(+) create mode 100644 common/selftest-migration.c create mode 120000 powerpc/selftest-migration.c create mode 120000 s390x/selftest-migration.c
common/selftest-migration.c new file +29 -0
@@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Machine independent migration tests +* +* This is just a very simple test that is intended to stress the migration +* support in the test harness. This could be expanded to test more guest +* library code, but architecture-specific tests should be used to test +* migration of tricky machine state. +*/ +#include <libcflat.h> +#include <migrate.h> + +#define NR_MIGRATIONS 30 + +int main (int argc,char **argv) +{ +int i =0 ; + +report_prefix_push ("migration" ); + +for (i =0 ; i <NR_MIGRATIONS ; i++) +migrate_quiet (); + +report (true,"simple harness stress test" ); + +report_prefix_pop (); + +return report_summary (); +}
powerpc/Makefile.common +1 -0
@@ -6,6 +6,7 @@ tests-common = \ $(TEST_DIR)/selftest.elf \ + $(TEST_DIR)/selftest-migration.elf \ $(TEST_DIR)/spapr_hcall.elf \ $(TEST_DIR)/rtas.elf \ $(TEST_DIR)/emulator.elf \
powerpc/selftest-migration.c new file +1 -0
@@ -0,0 +1 @@ +../common/selftest-migration.c
powerpc/unittests.cfg +4 -0
@@ -36,6 +36,10 @@ smp = 2 extra_params = -m 256 -append 'setup smp=2 mem=256' groups = selftest +[selftest-migration] +file = selftest-migration.elf +groups = selftest migration + [spapr_hcall] file = spapr_hcall.elf
s390x/Makefile +1 -0
@@ -1,4 +1,5 @@ tests = $(TEST_DIR)/selftest.elf +tests += $(TEST_DIR)/selftest-migration.elf tests += $(TEST_DIR)/intercept.elf tests += $(TEST_DIR)/emulator.elf tests += $(TEST_DIR)/sieve.elf
s390x/selftest-migration.c new file +1 -0
@@ -0,0 +1 @@ +../common/selftest-migration.c
s390x/unittests.cfg +4 -0
@@ -24,6 +24,10 @@ groups = selftest # please keep the kernel cmdline in sync with $(TEST_DIR)/selftest.parmfile extra_params = -append 'test 123' +[selftest-migration] +file = selftest-migration.elf +groups = selftest migration + [intercept] file = intercept.elf
Signature · 1 line
2.42.0
Re: [kvm-unit-tests PATCH v5 7/8] Add common/ directory for architecture-independent tests
In reply to Nicholas PigginQuoted 6 lines · Nicholas Piggin
x86/sieve.cis used by s390x, arm, and riscv via symbolic link. Make a new directory common/ for architecture-independent tests and movesieve.chere.Reviewed-by Thomas Huth <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>
Quoted 10 lines
--- arm/sieve.c | 2 +- common/sieve.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ riscv/sieve.c | 2 +- s390x/sieve.c | 2 +- x86/sieve.c | 52 +------------------------------------------------- 5 files changed, 55 insertions(+), 54 deletions(-) create mode 100644 common/sieve.c mode change 100644 => 120000 x86/sieve.c
Quoted 6 lines · Nicholas Piggin
Now that strange arm64 hang is found to be QEMU bug, I'll repost. Since arm64 requires Thomas's uart patch and it is worse affected by the QEMU bug, I will just not build it on arm. The QEMU bug still affects powerpc (and presumably s390x) but it's not causing so much trouble for this test case.
Quoted 8 lines
I have another test case that can hit it reliably and doesn't cause crashes but that takes some harness and common lib work so I'll send that another time.
Since v4:
- Don't build selftest-migration on arm.
- Reduce selftest-migration iterations from 100 to 30 to make the test run faster (it's ~0.5s per migration).
Thanks, I think the series is ready to go now ... we just have to wait for your QEMU TCG migration fix to get merged first. Or should we maybe mark the selftest-migration with "accel = kvm" for now and remove that line later once QEMU has been fixed?
Thomas
Quoted 16 lines · Thomas Huth
Quoted 6 lines · Nicholas Piggin
Now that strange arm64 hang is found to be QEMU bug, I'll repost. Since arm64 requires Thomas's uart patch and it is worse affected by the QEMU bug, I will just not build it on arm. The QEMU bug still affects powerpc (and presumably s390x) but it's not causing so much trouble for this test case.
Quoted 8 lines
I have another test case that can hit it reliably and doesn't cause crashes but that takes some harness and common lib work so I'll send that another time.
Since v4:
- Don't build selftest-migration on arm.
- Reduce selftest-migration iterations from 100 to 30 to make the test run faster (it's ~0.5s per migration).
Quoted 4 lines
Thanks, I think the series is ready to go now ... we just have to wait for your QEMU TCG migration fix to get merged first. Or should we maybe mark the selftest-migration with "accel = kvm" for now and remove that line later once QEMU has been fixed?
Could we merge it? I'm juggling a bunch of different things and prone to lose track of something :\ I'll need to drum up a bit of interest to review the QEMU fixes from those who know the code too, so that may take some time.
I left it out of arm unittests.cfg entirely, and s390 and powerpc seems to work by luck enough to be useful for gitlab CI so I don't think there is a chnage needed really unless you're paranoid.
I do have a later patch that adds a memory tester that does trigger it right away on powerpc. I'll send that out after this series is merged... but we do still have the issue that the gitlab CI image has the old QEMU don't we? Until we update distro.
Thanks,
Nick
Quoted 22 lines · Nicholas Piggin
Quoted 16 lines · Thomas Huth
Quoted 6 lines · Nicholas Piggin
Now that strange arm64 hang is found to be QEMU bug, I'll repost. Since arm64 requires Thomas's uart patch and it is worse affected by the QEMU bug, I will just not build it on arm. The QEMU bug still affects powerpc (and presumably s390x) but it's not causing so much trouble for this test case.
Quoted 8 lines
I have another test case that can hit it reliably and doesn't cause crashes but that takes some harness and common lib work so I'll send that another time.
Since v4:
- Don't build selftest-migration on arm.
- Reduce selftest-migration iterations from 100 to 30 to make the test run faster (it's ~0.5s per migration).Quoted 4 lines
Thanks, I think the series is ready to go now ... we just have to wait for your QEMU TCG migration fix to get merged first. Or should we maybe mark the selftest-migration with "accel = kvm" for now and remove that line later once QEMU has been fixed?
Quoted 4 lines
Could we merge it? I'm juggling a bunch of different things and prone to lose track of something :\ I'll need to drum up a bit of interest to review the QEMU fixes from those who know the code too, so that may take some time.
Ok, I merged it, but with "accel = kvm" for the time being (otherwise this would be quite a pitfall for people trying to run the k-u-t with TCG when they don't know that they have to fetch a patch from the mailing list to get it working).
Quoted 3 lines
I left it out of arm unittests.cfg entirely, and s390 and powerpc seems to work by luck enough to be useful for gitlab CI so I don't think there is a chnage needed really unless you're paranoid.
At least the s390x test does not work reliably at all when running with TCG without your QEMU patch, so I think we really need the "accel = kvm" for the time being here.
Quoted 4 lines
I do have a later patch that adds a memory tester that does trigger it right away on powerpc. I'll send that out after this series is merged... but we do still have the issue that the gitlab CI image has the old QEMU don't we? Until we update distro.
We only run selected tests in the gitlab-CI, so unless you add it to .gitlab-ci.yml, the selftest-migration test won't be run there.
Thomas