test: make qemu use kvm if available
authorDaniel Mack <daniel@zonque.org>
Thu, 19 Nov 2015 12:17:15 +0000 (13:17 +0100)
committerDaniel Mack <daniel@zonque.org>
Thu, 19 Nov 2015 13:25:32 +0000 (14:25 +0100)
If we're running in a KVM virtualized environment (such as Semaphore's
Docker enabled platform), pass '-cpu host' to QEMU.

test/test-functions

index 0a9d4f8..5d223db 100644 (file)
@@ -68,8 +68,7 @@ selinux=0 \
 $KERNEL_APPEND \
 "
 
-    QEMU_OPTIONS="-machine accel=kvm:tcg \
--smp $QEMU_SMP \
+    QEMU_OPTIONS="-smp $QEMU_SMP \
 -net none \
 -m 512M \
 -nographic \
@@ -80,6 +79,10 @@ $KERNEL_APPEND \
         QEMU_OPTIONS="$QEMU_OPTIONS -initrd $INITRD"
     fi
 
+    if [ -c /dev/kvm ]; then
+        QEMU_OPTIONS="$QEMU_OPTIONS -machine accel=kvm -enable-kvm -cpu host"
+    fi
+
     ( set -x
       $QEMU_BIN $QEMU_OPTIONS -append "$KERNEL_APPEND" $TESTDIR/rootdisk.img ) || return 1
 }