X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbasic%2Fvirt.c;h=764de955a5b75cb9bd55415fef65770383a891e3;hb=ba812e282b3406f478e8ede2b6eb885f61fae6fc;hp=1299a75ed54d242ef9b93964b7a24dfe302fff9c;hpb=1cfc78c91965df340cdde100ad6cb3ed50b28927;p=elogind.git diff --git a/src/basic/virt.c b/src/basic/virt.c index 1299a75ed..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; @@ -386,6 +402,8 @@ finish: return r; } +/// UNNEEDED by elogind +#if 0 /* Returns a short identifier for the various VM/container implementations */ int detect_virtualization(const char **id) { int r; @@ -404,3 +422,4 @@ int detect_virtualization(const char **id) { return VIRTUALIZATION_NONE; } +#endif // 0