Fix for KVM with explicit -cpu model parameter.
authorRichard W.M. Jones <rjones@redhat.com>
Wed, 25 May 2011 10:13:50 +0000 (11:13 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Wed, 25 May 2011 10:14:21 +0000 (11:14 +0100)
virt-what.in

index e0fdf5b..a27be10 100644 (file)
@@ -166,13 +166,14 @@ fi
 # Check for Parallels.
 if echo "$dmi" | grep -q 'Vendor: Parallels'; then
     echo parallels
+    skip_qemu_kvm=1
 fi
 
 # Check for Xen.
 
 if [ "$cpuid" = "XenVMMXenVMM" ]; then
     echo xen; echo xen-hvm
-    is_xen=1
+    skip_qemu_kvm=1
 elif [ -f $root/proc/xen/capabilities ]; then
     echo xen
     if grep -q "control_d" $root/proc/xen/capabilities; then
@@ -180,7 +181,7 @@ elif [ -f $root/proc/xen/capabilities ]; then
     else
         echo xen-domU
     fi
-    is_xen=1
+    skip_qemu_kvm=1
 elif [ -f $root/sys/hypervisor/type ] &&
     grep -q "xen" $root/sys/hypervisor/type; then
     # Ordinary kernel with pv_ops.  There does not seem to be
@@ -190,15 +191,20 @@ elif [ -f $root/sys/hypervisor/type ] &&
 fi
 
 # Check for QEMU/KVM.
+#
+# Parallels exports KVMKVMKVM leaf, so skip this test if we've already
+# seen that it's Parallels.  Xen uses QEMU as the device model, so
+# skip this test if we know it is Xen.
 
-if [ ! "$is_xen" ]; then
-    # Disable this test if we know this is Xen already, because Xen
-    # uses QEMU for its device model.
-
-    if grep -q 'QEMU' $root/proc/cpuinfo; then
-       if [ "$cpuid" = "KVMKVMKVM" ]; then
-           echo kvm
-       else
+if [ ! "$skip_qemu_kvm" ]; then
+    if [ "$cpuid" = "KVMKVMKVM" ]; then
+       echo kvm
+    else
+        # XXX This is known to fail for qemu with the explicit -cpu
+        # option, since /proc/cpuinfo will not contain the QEMU
+        # string.  The long term fix for this would be to export
+        # another CPUID leaf for non-accelerated qemu.
+        if grep -q 'QEMU' $root/proc/cpuinfo; then
            echo qemu
        fi
     fi