From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: Re: [kvm-unit-tests PATCH 3/3] arm/run: use ACCEL to choose between kvm and tcg Date: Tue, 4 Aug 2015 09:18:05 +0200 Message-ID: <20150804071805.GA13384@hawk.localdomain> References: <1438624311-28713-1-git-send-email-drjones@redhat.com> <1438624311-28713-4-git-send-email-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: alex.bennee@linaro.org, pbonzini@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:35122 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752976AbbHDHSK (ORCPT ); Tue, 4 Aug 2015 03:18:10 -0400 Content-Disposition: inline In-Reply-To: <1438624311-28713-4-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Aug 03, 2015 at 07:51:51PM +0200, Andrew Jones wrote: > Inspired by a patch by Alex Benn=E9e. This version uses a new > unittests.cfg variable and includes support for DRYRUN. >=20 > Signed-off-by: Andrew Jones > --- >=20 > Another difference with Alex's patch is we no longer output > 'Running with TCG', as I don't think it's necessary. The > command line captures that, and the whole point of the patch > is to silence the '"kvm" accelerator not found.' messages > anyway. I forgot to actually test mkstandlone... The dryrun stuff in this patch isn't sufficient for the new unittests variable. I've worked up a v2 and will post the series again shortly. drew >=20 > arm/run | 36 ++++++++++++++++++++++++++++++------ > arm/unittests.cfg | 4 +++- > run_tests.sh | 3 ++- > scripts/functions.bash | 8 ++++++-- > 4 files changed, 41 insertions(+), 10 deletions(-) >=20 > diff --git a/arm/run b/arm/run > index 8cc2fa2571967..1208a22b776d9 100755 > --- a/arm/run > +++ b/arm/run > @@ -7,6 +7,35 @@ 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 [ "$kvm_available" !=3D "yes" ] && [ "$ACCEL" =3D "kvm" ]; then > + printf "skip $TESTNAME (kvm only)\n\n" > + exit 2 > +fi > + > +if [ "$kvm_available" !=3D "yes" ] || [ "$ACCEL" =3D "tcg" ]; then > + accel=3D",accel=3Dtcg" > +else > + accel=3D",accel=3Dkvm" > + if [ "$ARCH" =3D "arm64" ]; then > + # arm64 must use '-cpu host' with kvm > + processor=3D"host" > + fi > +fi > + > +if [ "$DRYRUN" =3D "yes" ]; then > + # Output kvm with tcg fallback for dryrun, since the > + # command line we output may get used elsewhere. > + accel=3D",accel=3Dkvm:tcg" > +fi > + > qemu=3D"${QEMU:-qemu-system-$ARCH_NAME}" > qpath=3D$(which $qemu 2>/dev/null) > =20 > @@ -33,15 +62,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 > 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}<&- > } > --=20 > 2.4.3 >=20 > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html