From: Thomas Huth Date: Fri, 10 Mar 2017 09:03:46 +0000 Subject: Re: [kvm-unit-tests PATCH 1/2] Add the possibility to do simple migration tests Message-Id: <01a727e7-f302-e2ab-5451-3cd0d958149b@redhat.com> List-Id: References: <1489080427-27103-1-git-send-email-thuth@redhat.com> <1489080427-27103-2-git-send-email-thuth@redhat.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= , kvm@vger.kernel.org, Laurent Vivier , Drew Jones Cc: kvm-ppc@vger.kernel.org, Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= On 10.03.2017 09:30, C=C3=A9dric Le Goater wrote: > On 03/09/2017 06:27 PM, Thomas Huth wrote: >> To be able to do simple migration tests with kvm-unit-tests, too, >> add a helper script that does all the necessary work: Start two >> instances of QEMU (source and destination) with QMP sockets for >> sending commands to them, then trigger the migration from one >> instance to the other and finally signal the end of the migration >> to the guest by injecting an NMI. >> This helper script is now used automatically for powerpc tests >> if the test is put into the "migration" group in the unittests.cfg >> file. >> >> Signed-off-by: Thomas Huth >> --- >> powerpc/run | 5 ++++ >> scripts/qemu-migration-helper.sh | 51 +++++++++++++++++++++++++++++++++= +++++++ >> scripts/runtime.bash | 3 +++ >> 3 files changed, 59 insertions(+) >> create mode 100755 scripts/qemu-migration-helper.sh >> >> diff --git a/powerpc/run b/powerpc/run >> index 6269abb..126fed5 100755 >> --- a/powerpc/run >> +++ b/powerpc/run >> @@ -41,6 +41,11 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/= null; then >> exit 2 >> fi >> =20 >> +if [ "$MIGRATION" =3D "1" ]; then >> + export QEMU_BIN=3D"$qemu" >> + qemu=3D`dirname $0`/../scripts/qemu-migration-helper.sh >> +fi >> + >> M=3D'-machine pseries' >> M+=3D",accel=3D$ACCEL" >> command=3D"$qemu -nodefaults $M -bios $FIRMWARE" >> diff --git a/scripts/qemu-migration-helper.sh b/scripts/qemu-migration-h= elper.sh >> new file mode 100755 >> index 0000000..0cb7e4a >> --- /dev/null >> +++ b/scripts/qemu-migration-helper.sh >> @@ -0,0 +1,51 @@ >> +#!/bin/sh >> + >> +# This script runs two instances of QEMU and then migrates the guest fr= om one >> +# instance to the other. The end of the migration is signalled to the g= uest by >> +# injecting an NMI. >> + >> +if [ "x$QEMU_BIN" =3D "x" ]; then >> + echo "QEMU_BIN must be set to the QEMU binary" >> + exit 1 >> +fi >> + >> +if ! command -v nc >/dev/null 2>&1; then >> + echo "$0 needs nc (netcat)" >> + exit 1 >> +fi >> + >> +qmp_cmd() >> +{ >> + echo '{ "execute": "qmp_capabilities" }{ "execute":' "$2" '}' | nc = -U $1 >> +} >> + >> +tempname=3D`mktemp` >> +qmp1=3D${tempname}.qmp1 >> +qmp2=3D${tempname}.qmp2 >> +qmpout1=3D${tempname}.qmpout1 >> +qmpout2=3D${tempname}.qmpout2 >> +stdout1=3D${tempname}.stdout1 >> +stdout2=3D${tempname}.stdout2 >> +migsock=3D${tempname}.mig >> + >> +$QEMU_BIN $* -chardev socket,id=3Dmon1,path=3D${qmp1},server,nowait \ >> + -mon chardev=3Dmon1,mode=3Dcontrol > ${stdout1} & >> + >> +$QEMU_BIN $* -chardev socket,id=3Dmon2,path=3D${qmp2},server,nowait \ >> + -mon chardev=3Dmon2,mode=3Dcontrol -incoming unix:${migsock} > ${stdou= t2} & >> + >> +sleep 1 >> + >> +qmp_cmd ${qmp1} '"migrate", "arguments": { "uri": "unix:'${migsock}'" }= ' > ${qmpout1} >> +while qmp_cmd ${qmp1} '"query-migrate"' | grep -q '"active"' ; do >> + sleep 1 >> +done >=20 > I had to add an extra sleep here, else I was getting :=20 >=20 > qemu-system-ppc64: Not a migration stream > qemu-system-ppc64: load of migration failed: Invalid argument >=20 > May be the synchronization on completion of the migration needs=20 > to be improved. Right, there seems to be another state called "setup" which could be reported by query-migrate. So you likely got that state here and the while loop terminated too early. I'll fix that and send a new version (after waiting for some more review feedback)... Thanks for your testing! Thomas