[kvm-unit-tests RFC 1/2] scripts: Check kvm availability by asking qemu

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The existence of the /dev/kvm character device doesn't imply that the
kvm module is part of the kernel or that it's always magically loaded
when needed.

Signed-off-by: Janosch Frank <frankja@xxxxxxxxxxxxx>
---
 arm/run               | 4 ++--
 powerpc/run           | 4 ++--
 s390x/run             | 4 ++--
 scripts/arch-run.bash | 7 +++++--
 x86/run               | 4 ++--
 5 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/arm/run b/arm/run
index a390ca5a..ca2d44e0 100755
--- a/arm/run
+++ b/arm/run
@@ -10,10 +10,10 @@ if [ -z "$STANDALONE" ]; then
 fi
 processor="$PROCESSOR"
 
-ACCEL=$(get_qemu_accelerator) ||
+qemu=$(search_qemu_binary) ||
 	exit $?
 
-qemu=$(search_qemu_binary) ||
+ACCEL=$(get_qemu_accelerator) ||
 	exit $?
 
 if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then
diff --git a/powerpc/run b/powerpc/run
index 597ab96e..b51ac6fc 100755
--- a/powerpc/run
+++ b/powerpc/run
@@ -9,10 +9,10 @@ if [ -z "$STANDALONE" ]; then
 	source scripts/arch-run.bash
 fi
 
-ACCEL=$(get_qemu_accelerator) ||
+qemu=$(search_qemu_binary) ||
 	exit $?
 
-qemu=$(search_qemu_binary) ||
+ACCEL=$(get_qemu_accelerator) ||
 	exit $?
 
 if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then
diff --git a/s390x/run b/s390x/run
index 09805044..2ec6da70 100755
--- a/s390x/run
+++ b/s390x/run
@@ -9,10 +9,10 @@ if [ -z "$STANDALONE" ]; then
 	source scripts/arch-run.bash
 fi
 
-ACCEL=$(get_qemu_accelerator) ||
+qemu=$(search_qemu_binary) ||
 	exit $?
 
-qemu=$(search_qemu_binary) ||
+ACCEL=$(get_qemu_accelerator) ||
 	exit $?
 
 M='-machine s390-ccw-virtio'
diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index 5997e384..8cc9a61e 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -342,8 +342,11 @@ trap_exit_push ()
 
 kvm_available ()
 {
-	[ -c /dev/kvm ] ||
-		return 1
+	if $($qemu -accel kvm 2> /dev/null); then
+		return 0;
+	else
+		return 1;
+	fi
 
 	[ "$HOST" = "$ARCH_NAME" ] ||
 		( [ "$HOST" = aarch64 ] && [ "$ARCH" = arm ] ) ||
diff --git a/x86/run b/x86/run
index 8b2425f4..cbf49143 100755
--- a/x86/run
+++ b/x86/run
@@ -9,10 +9,10 @@ if [ -z "$STANDALONE" ]; then
 	source scripts/arch-run.bash
 fi
 
-ACCEL=$(get_qemu_accelerator) ||
+qemu=$(search_qemu_binary) ||
 	exit $?
 
-qemu=$(search_qemu_binary) ||
+ACCEL=$(get_qemu_accelerator) ||
 	exit $?
 
 if ! ${qemu} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null;
-- 
2.27.0




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux