diff options
author | Djalal Harouni <tixxdz@opendz.org> | 2017-02-14 21:45:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-14 21:45:23 +0100 |
commit | b1d7520ab5c94f648c51991aaa603bbccc2610f5 (patch) | |
tree | 63f1754c6061a82b8694cc420e3024e3e1a7b02b /src | |
parent | fb4819f137b7c1c6def5c4ee6255436ea8c613f5 (diff) | |
parent | 5f1c788ca963dbacbf09b165acd7b8563ddd34d9 (diff) |
Merge pull request #5343 from eworm-de/virt-kvm
virt: detect qemu/kvm as 'kvm'
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/virt.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/basic/virt.c b/src/basic/virt.c index 03ce71a728..0fbbdea602 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -316,25 +316,31 @@ static int detect_vm_zvm(void) { /* Returns a short identifier for the various VM implementations */ int detect_vm(void) { static thread_local int cached_found = _VIRTUALIZATION_INVALID; - int r; + int r, cpuid; if (cached_found >= 0) return cached_found; /* 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. */ + * -> First try to detect qemu/kvm and return 'kvm'. + * -> Some virtualization technologies do use KVM hypervisor but are + * expected to be detected as something else. Virtualbox since + * version 5.0 is an example. So detect DMI next. + * -> Get infos from CPUID third. */ + + cpuid = detect_vm_cpuid(); r = detect_vm_dmi(); + + if (r == VIRTUALIZATION_QEMU && cpuid == VIRTUALIZATION_KVM) + return cpuid; + if (r < 0) return r; if (r != VIRTUALIZATION_NONE) goto finish; - r = detect_vm_cpuid(); + r = cpuid; if (r < 0) return r; if (r != VIRTUALIZATION_NONE) |