From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com
Subject: [PATCH kvm-unit-tests 2/8] scripts/arch-run: run_migration improvements
Date: Wed, 7 Feb 2018 20:03:28 +0100 [thread overview]
Message-ID: <20180207190334.16516-3-drjones@redhat.com> (raw)
In-Reply-To: <20180207190334.16516-1-drjones@redhat.com>
- Don't assume the first argument is QEMU, it's actually most
likely 'timeout'.
- Don't assume run_migration is called from a subshell (even
though it is) and use return and a RETURN trap handler instead
(and make this change in env_generate_errata() as well).
- Cleanup all child processes on termination
- Make sure the exit code of the unit test is propagated.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
scripts/arch-run.bash | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index 1e41eb7bd4ab..565e299295db 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -108,12 +108,9 @@ run_migration ()
{
if ! command -v nc >/dev/null 2>&1; then
echo "${FUNCNAME[0]} needs nc (netcat)" >&2
- exit 2
+ return 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`
@@ -121,13 +118,15 @@ run_migration ()
qmpout1=/dev/null
qmpout2=/dev/null
- trap 'rm -f ${migout1} ${migsock} ${qmp1} ${qmp2}' EXIT
+ trap 'kill 0; exit 2' INT TERM
+ trap 'rm -f ${migout1} ${migsock} ${qmp1} ${qmp2}' RETURN EXIT
- $qemu "$@" -chardev socket,id=mon1,path=${qmp1},server,nowait \
- -mon chardev=mon1,mode=control | tee ${migout1} &
+ eval "$@" -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} &
+ eval "$@" -chardev socket,id=mon2,path=${qmp2},server,nowait \
+ -mon chardev=mon2,mode=control -incoming unix:${migsock} &
+ incoming_pid=`jobs -l %+ | awk '{print$2}'`
# The test must prompt the user to migrate, so wait for the "migrate" keyword
while ! grep -q -i "migrate" < ${migout1} ; do
@@ -145,14 +144,17 @@ run_migration ()
echo "ERROR: Migration failed." >&2
qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null
qmp ${qmp2} '"quit"'> ${qmpout2} 2>/dev/null
- exit 2
+ return 2
fi
done
qmp ${qmp1} '"quit"'> ${qmpout1} 2>/dev/null
qmp ${qmp2} '"inject-nmi"'> ${qmpout2}
+ wait $incoming_pid
+ ret=$?
wait
+ return $ret
}
migration_cmd ()
@@ -254,7 +256,7 @@ env_generate_errata ()
if ! [[ $v =~ ^[0-9]+$ ]] || ! [[ $p =~ ^[0-9]+$ ]]; then
echo "Bad minimum kernel version in $ERRATATXT, $minver"
- exit 2
+ return 2
fi
! [[ $s =~ ^[0-9]+$ ]] && unset $s
! [[ $x =~ ^[0-9]+$ ]] && unset $x
--
2.13.6
next prev parent reply other threads:[~2018-02-07 19:03 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 19:03 [PATCH kvm-unit-tests 0/8] arm/arm64: extend psci tests Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 1/8] virtio-mmio: fix queue allocation Andrew Jones
2018-02-07 19:32 ` Andrew Jones
2018-02-07 19:34 ` [PATCH kvm-unit-tests v2 " Andrew Jones
2018-02-07 19:03 ` Andrew Jones [this message]
2018-02-07 19:03 ` [PATCH kvm-unit-tests 3/8] powerpc: don't use NMI's to signal end of migration Andrew Jones
2018-02-08 10:58 ` Thomas Huth
2018-02-07 19:03 ` [PATCH kvm-unit-tests 4/8] powerpc: Introduce getchar Andrew Jones
2018-02-08 11:06 ` Thomas Huth
2018-02-08 12:59 ` Andrew Jones
2018-02-14 11:43 ` Paolo Bonzini
2018-02-14 12:38 ` Andrew Jones
2018-02-14 13:25 ` Paolo Bonzini
2018-02-14 14:38 ` Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 5/8] lib: Introduce do_migration Andrew Jones
2018-02-14 11:45 ` Paolo Bonzini
2018-02-14 12:44 ` Andrew Jones
2018-02-14 13:24 ` Paolo Bonzini
2018-02-07 19:03 ` [PATCH kvm-unit-tests 6/8] arm/arm64: Add support for migration tests Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 7/8] arm/arm64: psci: add migration test Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 8/8] arm/psci: add smccc 1.1 tests Andrew Jones
2018-02-14 11:46 ` [PATCH kvm-unit-tests 0/8] arm/arm64: extend psci tests Paolo Bonzini
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=20180207190334.16516-3-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).