X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbasic%2Fvirt.c;h=6eb1d0c46e41730f3f1015ed286c4313e2149a7b;hb=bc983c987eb3f92eceb373ba4e1c2076b0b3ca88;hp=4b6286567899fc2376ba8a30d30a91f742ea7480;hpb=21412e2985ee882965d78612895ceab7afe8d499;p=elogind.git diff --git a/src/basic/virt.c b/src/basic/virt.c index 4b6286567..6eb1d0c46 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -1,5 +1,3 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - /*** This file is part of systemd. @@ -20,6 +18,8 @@ ***/ #include +#include +#include #include #include @@ -27,11 +27,11 @@ #include "dirent-util.h" #include "fd-util.h" #include "fileio.h" +#include "macro.h" #include "process-util.h" #include "stat-util.h" #include "string-table.h" #include "string-util.h" -#include "util.h" #include "virt.h" #if 0 /// UNNEEDED by elogind @@ -270,13 +270,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)