From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [kvm-unit-tests PATCH 3/3] arm/run: use ACCEL to choose between kvm and tcg Date: Mon, 3 Aug 2015 19:51:51 +0200 Message-ID: <1438624311-28713-4-git-send-email-drjones@redhat.com> References: <1438624311-28713-1-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, pbonzini@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:49264 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754061AbbHCRwA (ORCPT ); Mon, 3 Aug 2015 13:52:00 -0400 In-Reply-To: <1438624311-28713-1-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Inspired by a patch by Alex Benn=C3=A9e. This version uses a new unittests.cfg variable and includes support for DRYRUN. Signed-off-by: Andrew Jones --- 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. arm/run | 36 ++++++++++++++++++++++++++++++------ arm/unittests.cfg | 4 +++- run_tests.sh | 3 ++- scripts/functions.bash | 8 ++++++-- 4 files changed, 41 insertions(+), 10 deletions(-) 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 /dev= /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 this= test # extra_params =3D -append # Additional parameters used -# arch =3D arm/arm64 # Only if test case is specific= to one +# arch =3D arm|arm64 # Only if test case is specific= to one # groups =3D group1 group2 # Used to identify test cases with run_test= s -g ... +# accel =3D kvm|tcg # Optionally specify if test must run with kvm or = tcg. +# # If not specified, then kvm will be used when avail= able. =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 $smp = $opts" + cmdline=3D"TESTNAME=3D$testname ACCEL=3D$accel ./$TEST_DIR-run $ke= rnel -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" "$che= ck" + "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$che= ck" "$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" "$check= " + "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check= " "$accel" exec {fd}<&- } --=20 2.4.3