summaryrefslogtreecommitdiff
path: root/src/basic/virt.c
diff options
context:
space:
mode:
authorChristian Hesse <mail@eworm.de>2017-02-15 23:51:31 +0100
committerSven Eden <yamakuzure@gmx.net>2017-07-17 17:58:36 +0200
commitc215fdfe0ea740def6e63c999e1dc9431c8b68b5 (patch)
tree1fe4c9dfa8336e283fa55f1206d6bb8214a724e7 /src/basic/virt.c
parentdfa83c1e0c059b5030b8927bbbc9afcc48486c17 (diff)
virt: swap order of cpuid and dmi again, but properly detect oracle (#5355)
This breaks again, this time for setups where Qemu is not reported via DMI for whatever reason. So swap order of cpuid and dmi again, but properly detect oracle. See issue #5318.
Diffstat (limited to 'src/basic/virt.c')
-rw-r--r--src/basic/virt.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/basic/virt.c b/src/basic/virt.c
index e25a274e8..66ce7ecfe 100644
--- a/src/basic/virt.c
+++ b/src/basic/virt.c
@@ -315,31 +315,29 @@ 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, cpuid;
+ int r, dmi;
if (cached_found >= 0)
return cached_found;
/* We have to use the correct order here:
*
- * -> 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. */
+ * -> 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. */
- cpuid = detect_vm_cpuid();
- r = detect_vm_dmi();
-
- if (r == VIRTUALIZATION_QEMU && cpuid == VIRTUALIZATION_KVM)
- return cpuid;
+ dmi = detect_vm_dmi();
+ if (dmi == VIRTUALIZATION_ORACLE)
+ return dmi;
+ r = detect_vm_cpuid();
if (r < 0)
return r;
if (r != VIRTUALIZATION_NONE)
goto finish;
- r = cpuid;
+ r = dmi;
if (r < 0)
return r;
if (r != VIRTUALIZATION_NONE)