@@ -8,6 +8,15 @@ fi
source config.mak
processor="$PROCESSOR"
+# Default to using KVM if available and on the right ARM host
+if [ -c /dev/kvm ]; then
+ if [ "$HOST" = "arm" ] && [ "$ARCH" = "arm" ]; then
+ usingkvm=yes
+ elif [ "$HOST" = "aarch64" ]; then
+ usingkvm=yes
+ fi
+fi
+
qemu="${QEMU:-qemu-system-$ARCH_NAME}"
qpath=$(which $qemu 2>/dev/null)
@@ -22,6 +31,12 @@ if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then
fi
M='-machine virt'
+if [ "$usingkvm" = "yes" ]; then
+ M+=',accel=kvm'
+else
+ echo "Running with TCG"
+ M+=',accel=tcg'
+fi
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=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
+if [ "$usingkvm" = "yes" ] && [ "$ARCH" = "arm64" ]; then
processor="host"
fi