From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: alex.bennee@linaro.org, pbonzini@redhat.com
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 [thread overview]
Message-ID: <1438624311-28713-4-git-send-email-drjones@redhat.com> (raw)
In-Reply-To: <1438624311-28713-1-git-send-email-drjones@redhat.com>
Inspired by a patch by Alex Bennée. This version uses a new
unittests.cfg variable and includes support for DRYRUN.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
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="$PROCESSOR"
+if [ -c /dev/kvm ]; then
+ if [ "$HOST" = "arm" ] && [ "$ARCH" = "arm" ]; then
+ kvm_available=yes
+ elif [ "$HOST" = "aarch64" ]; then
+ kvm_available=yes
+ fi
+fi
+
+if [ "$kvm_available" != "yes" ] && [ "$ACCEL" = "kvm" ]; then
+ printf "skip $TESTNAME (kvm only)\n\n"
+ exit 2
+fi
+
+if [ "$kvm_available" != "yes" ] || [ "$ACCEL" = "tcg" ]; then
+ accel=",accel=tcg"
+else
+ accel=",accel=kvm"
+ if [ "$ARCH" = "arm64" ]; then
+ # arm64 must use '-cpu host' with kvm
+ processor="host"
+ fi
+fi
+
+if [ "$DRYRUN" = "yes" ]; then
+ # Output kvm with tcg fallback for dryrun, since the
+ # command line we output may get used elsewhere.
+ accel=",accel=kvm:tcg"
+fi
+
qemu="${QEMU:-qemu-system-$ARCH_NAME}"
qpath=$(which $qemu 2>/dev/null)
@@ -33,15 +62,10 @@ if $qemu $M -chardev testdev,id=id -initrd . 2>&1 \
exit 2
fi
-M='-machine virt,accel=kvm:tcg'
chr_testdev='-device virtio-serial-device'
chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd'
-# arm64 must use '-cpu host' with kvm
-if [ "$(arch)" = "aarch64" ] && [ "$ARCH" = "arm64" ] && [ -c /dev/kvm ]; then
- processor="host"
-fi
-
+M+=$accel
command="$qemu $M -cpu $processor $chr_testdev"
command+=" -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 = foo.flat # Name of the flat file to be used
# smp = 2 # Number of processors the VM will use during this test
# extra_params = -append <params...> # Additional parameters used
-# arch = arm/arm64 # Only if test case is specific to one
+# arch = arm|arm64 # Only if test case is specific to one
# groups = group1 group2 # Used to identify test cases with run_tests -g ...
+# accel = kvm|tcg # Optionally specify if test must run with kvm or tcg.
+# # If not specified, then kvm will be used when available.
#
# Test that the configured number of processors (smp = <num>), 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="$5"
local arch="$6"
local check="$7"
+ local accel="$8"
if [ -z "$testname" ]; then
return
@@ -46,7 +47,7 @@ function run()
fi
done
- cmdline="TESTNAME=$testname ./$TEST_DIR-run $kernel -smp $smp $opts"
+ cmdline="TESTNAME=$testname ACCEL=$accel ./$TEST_DIR-run $kernel -smp $smp $opts"
if [ $verbose != 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
exec {fd}<"$unittests"
while read -u $fd line; do
if [[ "$line" =~ ^\[(.*)\]$ ]]; then
- "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check"
+ "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel"
testname=${BASH_REMATCH[1]}
smp=1
kernel=""
@@ -23,6 +24,7 @@ function for_each_unittest()
groups=""
arch=""
check=""
+ accel=""
elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then
kernel=$TEST_DIR/${BASH_REMATCH[1]}
elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then
@@ -35,8 +37,10 @@ function for_each_unittest()
arch=${BASH_REMATCH[1]}
elif [[ $line =~ ^check\ *=\ *(.*)$ ]]; then
check=${BASH_REMATCH[1]}
+ elif [[ $line =~ ^accel\ *=\ *(.*)$ ]]; then
+ accel=${BASH_REMATCH[1]}
fi
done
- "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check"
+ "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel"
exec {fd}<&-
}
--
2.4.3
next prev parent reply other threads:[~2015-08-03 17:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-03 17:51 [kvm-unit-tests PATCH 0/3] tcg is becoming a first class citizen Andrew Jones
2015-08-03 17:51 ` [kvm-unit-tests PATCH 1/3] configure: emit HOST=$host to config.mak Andrew Jones
2015-08-03 17:51 ` [kvm-unit-tests PATCH 2/3] run_tests: pass test name to run script Andrew Jones
2015-08-03 17:51 ` Andrew Jones [this message]
2015-08-04 7:18 ` [kvm-unit-tests PATCH 3/3] arm/run: use ACCEL to choose between kvm and tcg Andrew Jones
2015-08-06 18:29 ` Alex Bennée
2015-08-07 8:00 ` Andrew Jones
2015-08-04 7:25 [kvm-unit-tests PATCH 0/3] tcg is becoming a first class citizen Andrew Jones
2015-08-04 7:25 ` [kvm-unit-tests PATCH 3/3] arm/run: use ACCEL to choose between kvm and tcg Andrew Jones
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=1438624311-28713-4-git-send-email-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@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.