From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [kvm-unit-tests PATCH 09/18] arm/run: use ACCEL to choose between kvm and tcg Date: Tue, 10 Nov 2015 17:30:54 +0100 Message-ID: <56421BBE.1090001@redhat.com> References: <1446769483-21586-1-git-send-email-drjones@redhat.com> <1446769483-21586-10-git-send-email-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: alex.bennee@linaro.org, cov@codeaurora.org To: Andrew Jones , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:35195 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753789AbbKJQbA (ORCPT ); Tue, 10 Nov 2015 11:31:00 -0500 In-Reply-To: <1446769483-21586-10-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 06/11/2015 01:24, Andrew Jones wrote: > Inspired by a patch by Alex Benn=C3=A9e. This version uses a new > unittests.cfg variable and includes support for DRYRUN. >=20 > Signed-off-by: Andrew Jones > --- > arm/run | 43 +++++++++++++++++++++++++++++++++++++--= ---- > arm/unittests.cfg | 4 +++- > run_tests.sh | 3 ++- > scripts/functions.bash | 8 ++++++-- > scripts/mkstandalone.sh | 15 +++++++++++---- > 5 files changed, 59 insertions(+), 14 deletions(-) >=20 > diff --git a/arm/run b/arm/run > index 8cc2fa2571967..4a648697d7fb5 100755 > --- a/arm/run > +++ b/arm/run > @@ -7,6 +7,42 @@ fi > source config.mak > processor=3D"$PROCESSOR" > =20 > +if [ -c /dev/kvm ]; then > + if [ "$HOST" =3D "arm" ] && [ "$ARCH" =3D "arm" ]; then > + kvm_available=3Dyes > + elif [ "$HOST" =3D "aarch64" ]; then > + kvm_available=3Dyes > + fi > +fi > + > +if [ "$ACCEL" =3D "kvm" ] && [ "$kvm_available" !=3D "yes" ] && > + [ "$DRYRUN" !=3D "yes" ]; then > + printf "skip $TESTNAME (kvm only)\n\n" > + exit 2 > +fi > + > +if [ -z "$ACCEL" ]; then > + if [ "$DRYRUN" =3D "yes" ]; then > + # Output kvm with tcg fallback for dryrun (when both are > + # allowed), since the command line we output may get used > + # elsewhere. > + ACCEL=3D"kvm:tcg" > + elif [ "$kvm_available" =3D "yes" ]; then > + ACCEL=3D"kvm" > + else > + ACCEL=3D"tcg" > + fi > +fi > + > +if [ "$ARCH" =3D "arm64" ]; then > + if [[ $ACCEL =3D~ kvm ]]; then > + # arm64 must use '-cpu host' with kvm, and we can't use > + # '-cpu host' with tcg, so we force kvm-only (no fallback) > + ACCEL=3D"kvm" > + processor=3D"host" > + fi > +fi > + > qemu=3D"${QEMU:-qemu-system-$ARCH_NAME}" > qpath=3D$(which $qemu 2>/dev/null) > =20 > @@ -33,15 +69,10 @@ if $qemu $M -chardev testdev,id=3Did -initrd . 2>= &1 \ > exit 2 > fi > =20 > -M=3D'-machine virt,accel=3Dkvm:tcg' > chr_testdev=3D'-device virtio-serial-device' > chr_testdev+=3D' -device virtconsole,chardev=3Dctd -chardev testdev,= id=3Dctd' > =20 > -# arm64 must use '-cpu host' with kvm > -if [ "$(arch)" =3D "aarch64" ] && [ "$ARCH" =3D "arm64" ] && [ -c /d= ev/kvm ]; then > - processor=3D"host" > -fi > - > +M+=3D",accel=3D$ACCEL" > command=3D"$qemu $M -cpu $processor $chr_testdev" > command+=3D" -display none -serial stdio -kernel" > echo $command "$@" > diff --git a/arm/unittests.cfg b/arm/unittests.cfg > index e068a0cdd9c1f..243c13301811b 100644 > --- a/arm/unittests.cfg > +++ b/arm/unittests.cfg > @@ -3,8 +3,10 @@ > # file =3D foo.flat # Name of the flat file to be used > # smp =3D 2 # Number of processors the VM will use during th= is test > # extra_params =3D -append # Additional parameters used > -# arch =3D arm/arm64 # Only if test case is specif= ic to one > +# arch =3D arm|arm64 # Only if test case is specif= ic to one > # groups =3D group1 group2 # Used to identify test cases with run_te= sts -g ... > +# accel =3D kvm|tcg # Optionally specify if test must run with kvm o= r tcg. > +# # If not specified, then kvm will be used when ava= ilable. > =20 > # > # Test that the configured number of processors (smp =3D ), and > diff --git a/run_tests.sh b/run_tests.sh > index 80b87823c3358..b1b4c541ecaea 100755 > --- a/run_tests.sh > +++ b/run_tests.sh > @@ -20,6 +20,7 @@ function run() > local opts=3D"$5" > local arch=3D"$6" > local check=3D"$7" > + local accel=3D"$8" > =20 > if [ -z "$testname" ]; then > return > @@ -46,7 +47,7 @@ function run() > fi > done > =20 > - cmdline=3D"TESTNAME=3D$testname ./$TEST_DIR-run $kernel -smp $sm= p $opts" > + cmdline=3D"TESTNAME=3D$testname ACCEL=3D$accel ./$TEST_DIR-run $= kernel -smp $smp $opts" > if [ $verbose !=3D 0 ]; then > echo $cmdline > fi > diff --git a/scripts/functions.bash b/scripts/functions.bash > index 7ed5a517250bc..f13fe6f88f23d 100644 > --- a/scripts/functions.bash > +++ b/scripts/functions.bash > @@ -10,12 +10,13 @@ function for_each_unittest() > local groups > local arch > local check > + local accel > =20 > exec {fd}<"$unittests" > =20 > while read -u $fd line; do > if [[ "$line" =3D~ ^\[(.*)\]$ ]]; then > - "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$c= heck" > + "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$c= heck" "$accel" > testname=3D${BASH_REMATCH[1]} > smp=3D1 > kernel=3D"" > @@ -23,6 +24,7 @@ function for_each_unittest() > groups=3D"" > arch=3D"" > check=3D"" > + accel=3D"" > elif [[ $line =3D~ ^file\ *=3D\ *(.*)$ ]]; then > kernel=3D$TEST_DIR/${BASH_REMATCH[1]} > elif [[ $line =3D~ ^smp\ *=3D\ *(.*)$ ]]; then > @@ -35,8 +37,10 @@ function for_each_unittest() > arch=3D${BASH_REMATCH[1]} > elif [[ $line =3D~ ^check\ *=3D\ *(.*)$ ]]; then > check=3D${BASH_REMATCH[1]} > + elif [[ $line =3D~ ^accel\ *=3D\ *(.*)$ ]]; then > + accel=3D${BASH_REMATCH[1]} > fi > done > - "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$che= ck" > + "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$che= ck" "$accel" > exec {fd}<&- > } > diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh > index 4cf346ab87d24..0c39451e538c9 100755 > --- a/scripts/mkstandalone.sh > +++ b/scripts/mkstandalone.sh > @@ -29,6 +29,7 @@ function mkstandalone() > local opts=3D"$5" > local arch=3D"$6" > local check=3D"$7" > + local accel=3D"$8" > =20 > if [ -z "$testname" ]; then > return 1 > @@ -39,7 +40,7 @@ function mkstandalone() > fi > =20 > standalone=3Dtests/$testname > - cmdline=3D$(DRYRUN=3Dyes ./$TEST_DIR-run $kernel) > + cmdline=3D$(DRYRUN=3Dyes ACCEL=3D$accel ./$TEST_DIR-run $kernel) > if [ $? -ne 0 ]; then > echo $cmdline > exit 1 > @@ -94,10 +95,16 @@ qemu=3D"$qemu" > if [ "\$QEMU" ]; then > qemu=3D"\$QEMU" > fi > -cmdline=3D"\`echo '$cmdline' | sed s%$kernel%\$bin%\`" > echo \$qemu $cmdline -smp $smp $opts > -\$qemu \$cmdline -smp $smp $opts > -ret=3D\$? > + > +cmdline=3D"\`echo '$cmdline' | sed s%$kernel%_NO_FILE_4Uhere_%\`" > +if \$qemu \$cmdline 2>&1 | grep 'No accelerator found'; then > + ret=3D2 > +else > + cmdline=3D"\`echo '$cmdline' | sed s%$kernel%\$bin%\`" > + \$qemu \$cmdline -smp $smp $opts > + ret=3D\$? > +fi > echo Return value from qemu: \$ret > if [ \$ret -le 1 ]; then > echo PASS $testname 1>&2 >=20 Applied, thanks. Paolo