From: Thomas Huth <thuth@redhat.com>
To: David Matlack <dmatlack@google.com>
Cc: "kvm list" <kvm@vger.kernel.org>,
"Laurent Vivier" <lvivier@redhat.com>,
"Drew Jones" <drjones@redhat.com>,
kvm-ppc@vger.kernel.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Cédric Le Goater" <clg@kaod.org>
Subject: Re: [kvm-unit-tests PATCH 1/2] Add the possibility to do simple migration tests
Date: Tue, 14 Mar 2017 09:31:59 +0100 [thread overview]
Message-ID: <f145826f-151b-e199-5aff-a9cf4f57c8d9@redhat.com> (raw)
In-Reply-To: <CALzav=fUEFQFDTbWrLZtD=wZJ4=i_GEtQ9y+GZYH1=ZC9d4VAg@mail.gmail.com>
On 11.03.2017 02:42, David Matlack wrote:
> On Thu, Mar 9, 2017 at 9:27 AM, Thomas Huth <thuth@redhat.com> 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 <thuth@redhat.com>
>> ---
>> 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
>>
>> +if [ "$MIGRATION" = "1" ]; then
>> + export QEMU_BIN="$qemu"
>> + qemu=`dirname $0`/../scripts/qemu-migration-helper.sh
>> +fi
>> +
>> M='-machine pseries'
>> M+=",accel=$ACCEL"
>> command="$qemu -nodefaults $M -bios $FIRMWARE"
>> diff --git a/scripts/qemu-migration-helper.sh b/scripts/qemu-migration-helper.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 from one
>> +# instance to the other. The end of the migration is signalled to the guest by
>> +# injecting an NMI.
>> +
>> +if [ "x$QEMU_BIN" = "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=`mktemp`
>> +qmp1=${tempname}.qmp1
>> +qmp2=${tempname}.qmp2
>> +qmpout1=${tempname}.qmpout1
>> +qmpout2=${tempname}.qmpout2
>> +stdout1=${tempname}.stdout1
>> +stdout2=${tempname}.stdout2
>> +migsock=${tempname}.mig
>> +
>> +$QEMU_BIN $* -chardev socket,id=mon1,path=${qmp1},server,nowait \
>> + -mon chardev=mon1,mode=control > ${stdout1} &
>> +
>> +$QEMU_BIN $* -chardev socket,id=mon2,path=${qmp2},server,nowait \
>> + -mon chardev=mon2,mode=control -incoming unix:${migsock} > ${stdout2} &
>> +
>> +sleep 1
>
> Suggest monitoring the QEMU serial port for a specific token to know
> when to initiate the migration. e.g. the guest can print
> "MIGRATE_ME_NOW" when it's ready. This would avoid initiating a
> migration too early.
Yes, that's a good idea, I'll add a check for something like this.
>> +
>> +qmp_cmd ${qmp1} '"migrate", "arguments": { "uri": "unix:'${migsock}'" }' > ${qmpout1}
>> +while qmp_cmd ${qmp1} '"query-migrate"' | grep -q '"active"' ; do
>> + sleep 1
>> +done
>> +qmp_cmd ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null
>> +
>> +qmp_cmd ${qmp2} '"inject-nmi"'> ${qmpout2}
>
> Does "inject-nmi" work on other architectures?
It should work at least on x86. Not sure about ARM though.
> An alternative approach is to add a new Qemu testdev register that
> counts the number of times a VM has been migrated. The guest can
> monitor this to know when the migration is complete.
AFAIK the testdev only works on x86, so that's not an option for powerpc
here.
Thomas
next prev parent reply other threads:[~2017-03-14 8:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-09 17:27 [kvm-unit-tests PATCH 0/2] powerpc: Test SPR persistency during migration Thomas Huth
2017-03-09 17:27 ` [kvm-unit-tests PATCH 1/2] Add the possibility to do simple migration tests Thomas Huth
2017-03-10 8:30 ` Cédric Le Goater
2017-03-10 9:03 ` Thomas Huth
2017-03-10 15:04 ` Andrew Jones
2017-03-10 16:57 ` Thomas Huth
2017-03-11 1:42 ` David Matlack
2017-03-14 8:31 ` Thomas Huth [this message]
2017-03-09 17:27 ` [kvm-unit-tests PATCH 2/2] powerpc: Add Special Purpose Register persistency test Thomas Huth
2017-03-10 8:48 ` Cédric Le Goater
2017-03-10 8:53 ` Cédric Le Goater
2017-03-10 9:38 ` Thomas Huth
2017-03-10 10:27 ` Cédric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f145826f-151b-e199-5aff-a9cf4f57c8d9@redhat.com \
--to=thuth@redhat.com \
--cc=clg@kaod.org \
--cc=dmatlack@google.com \
--cc=drjones@redhat.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox