chiark / gitweb /
virt: if we detect Xen by DMI, trust that over CPUID
authorLennart Poettering <lennart@poettering.net>
Mon, 30 Apr 2018 10:23:03 +0000 (12:23 +0200)
committerSven Eden <yamakuzure@gmx.net>
Thu, 28 Jun 2018 07:24:07 +0000 (09:24 +0200)
Apparently Xen sometimes lies about its identity when queried via CPUID.
Let's hence prefer DMI tests for CPUID

Fixes: #8844
(cherry picked from commit f2fe2865cd19cd4318b82d01b9b62d22b1697b3a)

src/basic/virt.c

index aaff4ea580fb1c45e7fe660c4f6f4173b3ee299a..9290dff3be8184499ed07ddfe1f3dc802264a854 100644 (file)
@@ -333,13 +333,16 @@ int detect_vm(void) {
 
         /* We have to use the correct order here:
          *
-         * -> First try to detect Oracle Virtualbox, even if it uses KVM.
-         * -> Second try to detect from cpuid, this will report KVM for
-         *    whatever software is used even if info in dmi is overwritten.
-         * -> Third try to detect from dmi. */
+         * → First, try to detect Oracle Virtualbox, even if it uses KVM, as well as Xen even if it cloaks as Microsoft
+         *   Hyper-V.
+         *
+         * → Second, try to detect from CPUID, this will report KVM for whatever software is used even if info in DMI is
+         *   overwritten.
+         *
+         * → Third, try to detect from DMI. */
 
         dmi = detect_vm_dmi();
-        if (dmi == VIRTUALIZATION_ORACLE) {
+        if (IN_SET(dmi, VIRTUALIZATION_ORACLE, VIRTUALIZATION_XEN)) {
                 r = dmi;
                 goto finish;
         }