summaryrefslogtreecommitdiff
path: root/src/basic/virt.c
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2017-01-04 06:40:46 +0100
committerSven Eden <yamakuzure@gmx.net>2017-03-14 10:18:46 +0100
commit21ecddbbb2c9e06d080b2526a870898a8b90f52a (patch)
tree458198518cde60db77fc2acc0191a082e37dea33 /src/basic/virt.c
parent54ce5835917e44761df5c7071fa9111f5be4008a (diff)
Prep v225: Applying various fixes and changes to src/basic that got lost during git am transfer.
Diffstat (limited to 'src/basic/virt.c')
-rw-r--r--src/basic/virt.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/basic/virt.c b/src/basic/virt.c
index b2383e526..764de955a 100644
--- a/src/basic/virt.c
+++ b/src/basic/virt.c
@@ -188,7 +188,7 @@ int detect_vm(const char **id) {
_cleanup_free_ char *domcap = NULL, *cpuinfo_contents = NULL;
static thread_local int cached_found = -1;
static thread_local const char *cached_id = NULL;
- const char *_id = NULL;
+ const char *_id = NULL, *_id_cpuid = NULL;
int r;
if (_likely_(cached_found >= 0)) {
@@ -234,10 +234,26 @@ int detect_vm(const char **id) {
/* this will set _id to "other" and return 0 for unknown hypervisors */
r = detect_vm_cpuid(&_id);
- if (r != 0)
+
+ /* finish when found a known hypervisor other than kvm */
+ if (r < 0 || (r > 0 && !streq(_id, "kvm")))
goto finish;
+ _id_cpuid = _id;
+
r = detect_vm_dmi(&_id);
+
+ /* kvm with and without Virtualbox */
+ if (streq_ptr(_id_cpuid, "kvm")) {
+ if (r > 0 && streq(_id, "oracle"))
+ goto finish;
+
+ _id = _id_cpuid;
+ r = 1;
+ goto finish;
+ }
+
+ /* information from dmi */
if (r != 0)
goto finish;