From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [kvm-unit-tests PATCH v4 3/3] arm/run: introduce usingkvm var and use it Date: Wed, 22 Jul 2015 18:49:56 +0100 Message-ID: <1437587396-4568-4-git-send-email-alex.bennee@linaro.org> References: <1437587396-4568-1-git-send-email-alex.bennee@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: drjones@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= To: kvm@vger.kernel.org Return-path: Received: from mail-wi0-f180.google.com ([209.85.212.180]:37750 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756701AbbGVRuG (ORCPT ); Wed, 22 Jul 2015 13:50:06 -0400 Received: by wibud3 with SMTP id ud3so183811532wib.0 for ; Wed, 22 Jul 2015 10:50:05 -0700 (PDT) In-Reply-To: <1437587396-4568-1-git-send-email-alex.bennee@linaro.org> Sender: kvm-owner@vger.kernel.org List-ID: This makes the script a little cleaner by only checking for KVM support in one place. If KVM isn't available we can fall back to TCG emulation and echo the fact to the screen rather than let QEMU complain. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Andrew Jones --- v2 - rm redundant M=3D statement v3 - make usingkvm use "yes" - merge patches 3/4 into one v4 - use single quotes consistently - add r-b tag --- arm/run | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/arm/run b/arm/run index 6b42a2e..6b3d558 100755 --- a/arm/run +++ b/arm/run @@ -8,6 +8,15 @@ fi source config.mak processor=3D"$PROCESSOR" =20 +# Default to using KVM if available and on the right ARM host +if [ -c /dev/kvm ]; then + if [ "$HOST" =3D "arm" ] && [ "$ARCH" =3D "arm" ]; then + usingkvm=3Dyes + elif [ "$HOST" =3D "aarch64" ]; then + usingkvm=3Dyes + fi +fi + qemu=3D"${QEMU:-qemu-system-$ARCH_NAME}" qpath=3D$(which $qemu 2>/dev/null) =20 @@ -22,6 +31,12 @@ if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Mac= hine' > /dev/null; then fi =20 M=3D'-machine virt' +if [ "$usingkvm" =3D "yes" ]; then + M+=3D',accel=3Dkvm' +else + echo "Running with TCG" + M+=3D',accel=3Dtcg' +fi =20 if ! $qemu $M -device '?' 2>&1 | grep virtconsole > /dev/null; then echo "$qpath doesn't support virtio-console for chr-testdev. Exiting.= " @@ -34,12 +49,11 @@ 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 +if [ "$usingkvm" =3D "yes" ] && [ "$ARCH" =3D "arm64" ]; then processor=3D"host" fi =20 --=20 2.4.5