diff options
Diffstat (limited to 'src/basic/virt.c')
-rw-r--r-- | src/basic/virt.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/basic/virt.c b/src/basic/virt.c index d088b7a804..b82680a54b 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -24,6 +24,8 @@ #include <unistd.h> #include "alloc-util.h" +#include "dirent-util.h" +#include "fd-util.h" #include "fileio.h" #include "process-util.h" #include "stat-util.h" @@ -267,13 +269,20 @@ int detect_vm(void) { if (cached_found >= 0) return cached_found; - r = detect_vm_cpuid(); + /* We have to use the correct order here: + * Some virtualization technologies do use KVM hypervisor but are + * expected to be detected as something else. So detect DMI first. + * + * An example is Virtualbox since version 5.0, which uses KVM backend. + * Detection via DMI works corretly, the CPU ID would find KVM + * only. */ + r = detect_vm_dmi(); if (r < 0) return r; if (r != VIRTUALIZATION_NONE) goto finish; - r = detect_vm_dmi(); + r = detect_vm_cpuid(); if (r < 0) return r; if (r != VIRTUALIZATION_NONE) |