From: Thomas Huth <thuth@redhat.com>
To: kvm@vger.kernel.org, "Laurent Vivier" <lvivier@redhat.com>,
"Drew Jones" <drjones@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>
Cc: kvm-ppc@vger.kernel.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Cédric Le Goater" <clg@kaod.org>,
"David Matlack" <dmatlack@google.com>
Subject: [kvm-unit-tests PATCH v4 1/2] Add the possibility to do simple migration tests
Date: Wed, 22 Mar 2017 08:28:06 +0000 [thread overview]
Message-ID: <1490171287-30893-2-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1490171287-30893-1-git-send-email-thuth@redhat.com>
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 | 2 +-
scripts/arch-run.bash | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++
scripts/runtime.bash | 3 +++
3 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/powerpc/run b/powerpc/run
index 6269abb..d92608e 100755
--- a/powerpc/run
+++ b/powerpc/run
@@ -46,7 +46,7 @@ M+=",accel=$ACCEL"
command="$qemu -nodefaults $M -bios $FIRMWARE"
[ -f "$ENV" ] && command+=" -initrd $ENV"
command+=" -display none -serial stdio -kernel"
-command="$(timeout_cmd) $command"
+command="$(migration_cmd) $(timeout_cmd) $command"
echo $command "$@"
# powerpc tests currently exit with rtas-poweroff, which exits with 0.
diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index 1610f3b..96bd5c4 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -70,3 +70,66 @@ timeout_cmd ()
echo "timeout -k 1s --foreground $TIMEOUT"
fi
}
+
+qmp ()
+{
+ echo '{ "execute": "qmp_capabilities" }{ "execute":' "$2" '}' | nc -U $1
+}
+
+run_migration ()
+{
+ if ! command -v nc >/dev/null 2>&1; then
+ echo "$0 needs nc (netcat)" >&2
+ exit 2
+ fi
+
+ qemu=$1
+ shift
+
+ migsock=`mktemp -u -t mig-helper-socket.XXXXXXXXXX`
+ migout1=`mktemp -t mig-helper-stdout1.XXXXXXXXXX`
+ qmp1=`mktemp -u -t mig-helper-qmp1.XXXXXXXXXX`
+ qmp2=`mktemp -u -t mig-helper-qmp2.XXXXXXXXXX`
+ qmpout1=/dev/null
+ qmpout2=/dev/null
+
+ trap 'rm -f ${migout1} ${migsock} ${qmp1} ${qmp2}' EXIT
+
+ $qemu "$@" -chardev socket,id=mon1,path=${qmp1},server,nowait \
+ -mon chardev=mon1,mode=control | tee ${migout1} &
+
+ $qemu "$@" -chardev socket,id=mon2,path=${qmp2},server,nowait \
+ -mon chardev=mon2,mode=control -incoming unix:${migsock} &
+
+ # The test must prompt the user to migrate, so wait for the "migrate" keyword
+ while ! grep -q -i "migrate" < ${migout1} ; do
+ sleep 1
+ done
+
+ qmp ${qmp1} '"migrate", "arguments": { "uri": "unix:'${migsock}'" }' > ${qmpout1}
+
+ # Wait for the migration to complete
+ migstatus=`qmp ${qmp1} '"query-migrate"' | grep return`
+ while ! grep -q '"completed"' <<<"$migstatus" ; do
+ sleep 1
+ migstatus=`qmp ${qmp1} '"query-migrate"' | grep return`
+ if grep -q '"failed"' <<<"$migstatus" ; then
+ echo "ERROR: Migration failed." >&2
+ qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null
+ qmp ${qmp2} '"quit"'> ${qmpout2} 2>/dev/null
+ exit 2
+ fi
+ done
+ qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null
+
+ qmp ${qmp2} '"inject-nmi"'> ${qmpout2}
+
+ wait
+}
+
+migration_cmd ()
+{
+ if [ "$MIGRATION" = "yes" ]; then
+ echo "run_migration"
+ fi
+}
diff --git a/scripts/runtime.bash b/scripts/runtime.bash
index 98f1835..e630279 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -99,6 +99,9 @@ function run()
}
cmdline=$(get_cmdline $kernel)
+ if grep -qw "migration" <<<$groups ; then
+ cmdline="MIGRATION=yes $cmdline"
+ fi
if [ "$verbose" = "yes" ]; then
echo $cmdline
fi
--
1.8.3.1
WARNING: multiple messages have this Message-ID (diff)
From: Thomas Huth <thuth@redhat.com>
To: kvm@vger.kernel.org, "Laurent Vivier" <lvivier@redhat.com>,
"Drew Jones" <drjones@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>
Cc: kvm-ppc@vger.kernel.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Cédric Le Goater" <clg@kaod.org>,
"David Matlack" <dmatlack@google.com>
Subject: [kvm-unit-tests PATCH v4 1/2] Add the possibility to do simple migration tests
Date: Wed, 22 Mar 2017 09:28:06 +0100 [thread overview]
Message-ID: <1490171287-30893-2-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1490171287-30893-1-git-send-email-thuth@redhat.com>
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 | 2 +-
scripts/arch-run.bash | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++
scripts/runtime.bash | 3 +++
3 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/powerpc/run b/powerpc/run
index 6269abb..d92608e 100755
--- a/powerpc/run
+++ b/powerpc/run
@@ -46,7 +46,7 @@ M+=",accel=$ACCEL"
command="$qemu -nodefaults $M -bios $FIRMWARE"
[ -f "$ENV" ] && command+=" -initrd $ENV"
command+=" -display none -serial stdio -kernel"
-command="$(timeout_cmd) $command"
+command="$(migration_cmd) $(timeout_cmd) $command"
echo $command "$@"
# powerpc tests currently exit with rtas-poweroff, which exits with 0.
diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index 1610f3b..96bd5c4 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -70,3 +70,66 @@ timeout_cmd ()
echo "timeout -k 1s --foreground $TIMEOUT"
fi
}
+
+qmp ()
+{
+ echo '{ "execute": "qmp_capabilities" }{ "execute":' "$2" '}' | nc -U $1
+}
+
+run_migration ()
+{
+ if ! command -v nc >/dev/null 2>&1; then
+ echo "$0 needs nc (netcat)" >&2
+ exit 2
+ fi
+
+ qemu=$1
+ shift
+
+ migsock=`mktemp -u -t mig-helper-socket.XXXXXXXXXX`
+ migout1=`mktemp -t mig-helper-stdout1.XXXXXXXXXX`
+ qmp1=`mktemp -u -t mig-helper-qmp1.XXXXXXXXXX`
+ qmp2=`mktemp -u -t mig-helper-qmp2.XXXXXXXXXX`
+ qmpout1=/dev/null
+ qmpout2=/dev/null
+
+ trap 'rm -f ${migout1} ${migsock} ${qmp1} ${qmp2}' EXIT
+
+ $qemu "$@" -chardev socket,id=mon1,path=${qmp1},server,nowait \
+ -mon chardev=mon1,mode=control | tee ${migout1} &
+
+ $qemu "$@" -chardev socket,id=mon2,path=${qmp2},server,nowait \
+ -mon chardev=mon2,mode=control -incoming unix:${migsock} &
+
+ # The test must prompt the user to migrate, so wait for the "migrate" keyword
+ while ! grep -q -i "migrate" < ${migout1} ; do
+ sleep 1
+ done
+
+ qmp ${qmp1} '"migrate", "arguments": { "uri": "unix:'${migsock}'" }' > ${qmpout1}
+
+ # Wait for the migration to complete
+ migstatus=`qmp ${qmp1} '"query-migrate"' | grep return`
+ while ! grep -q '"completed"' <<<"$migstatus" ; do
+ sleep 1
+ migstatus=`qmp ${qmp1} '"query-migrate"' | grep return`
+ if grep -q '"failed"' <<<"$migstatus" ; then
+ echo "ERROR: Migration failed." >&2
+ qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null
+ qmp ${qmp2} '"quit"'> ${qmpout2} 2>/dev/null
+ exit 2
+ fi
+ done
+ qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null
+
+ qmp ${qmp2} '"inject-nmi"'> ${qmpout2}
+
+ wait
+}
+
+migration_cmd ()
+{
+ if [ "$MIGRATION" = "yes" ]; then
+ echo "run_migration"
+ fi
+}
diff --git a/scripts/runtime.bash b/scripts/runtime.bash
index 98f1835..e630279 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -99,6 +99,9 @@ function run()
}
cmdline=$(get_cmdline $kernel)
+ if grep -qw "migration" <<<$groups ; then
+ cmdline="MIGRATION=yes $cmdline"
+ fi
if [ "$verbose" = "yes" ]; then
echo $cmdline
fi
--
1.8.3.1
next prev parent reply other threads:[~2017-03-22 8:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-22 8:28 [kvm-unit-tests PATCH v4 0/2] powerpc: Test SPR persistency during migration Thomas Huth
2017-03-22 8:28 ` Thomas Huth
2017-03-22 8:28 ` Thomas Huth [this message]
2017-03-22 8:28 ` [kvm-unit-tests PATCH v4 1/2] Add the possibility to do simple migration tests Thomas Huth
2017-03-22 8:41 ` Andrew Jones
2017-03-22 8:41 ` Andrew Jones
2017-03-22 8:28 ` [kvm-unit-tests PATCH v4 2/2] powerpc: Add Special Purpose Register persistency test Thomas Huth
2017-03-22 8:28 ` Thomas Huth
2017-03-22 15:20 ` [kvm-unit-tests PATCH v4 0/2] powerpc: Test SPR persistency during migration Laurent Vivier
2017-03-22 15:20 ` Laurent Vivier
2017-03-22 17:27 ` Thomas Huth
2017-03-22 17:27 ` Thomas Huth
2017-03-23 22:41 ` Paul Mackerras
2017-03-23 22:41 ` Paul Mackerras
2017-03-24 7:43 ` Thomas Huth
2017-03-24 7:43 ` Thomas Huth
2017-03-22 17:39 ` Cédric Le Goater
2017-03-22 17:39 ` 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=1490171287-30893-2-git-send-email-thuth@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.