summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hesse <mail@eworm.de>2017-02-15 23:51:31 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-02-15 17:51:31 -0500
commit28b1a3eac252d471de4fbb6f317353af30d68878 (patch)
tree4a6f6a65ee56244c7eca2cef1bfb08e28ebb03fe
parentcda3d0c240d345a238822b74d4614d4f412455a5 (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.
-rw-r--r--man/systemd-detect-virt.xml6
-rw-r--r--src/basic/virt.c22
2 files changed, 14 insertions, 14 deletions
diff --git a/man/systemd-detect-virt.xml b/man/systemd-detect-virt.xml
index dc10b4dd43..72ea35892f 100644
--- a/man/systemd-detect-virt.xml
+++ b/man/systemd-detect-virt.xml
@@ -96,7 +96,8 @@
<row>
<entry><varname>kvm</varname></entry>
- <entry>Linux KVM kernel virtual machine, from within QEMU</entry>
+ <entry>Linux KVM kernel virtual machine, with whatever software, except
+ Oracle Virtualbox</entry>
</row>
<row>
@@ -116,7 +117,8 @@
<row>
<entry><varname>oracle</varname></entry>
- <entry>Oracle VM VirtualBox (historically marketed by innotek and Sun Microsystems)</entry>
+ <entry>Oracle VM VirtualBox (historically marketed by innotek and Sun Microsystems),
+ for legacy and KVM hypervisor</entry>
</row>
<row>
diff --git a/src/basic/virt.c b/src/basic/virt.c
index 0fbbdea602..830dc655e3 100644
--- a/src/basic/virt.c
+++ b/src/basic/virt.c
@@ -316,31 +316,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)