X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=src%2Fbasic%2Fvirt.c;h=fdbb5018191529c054dea8b150e885fe7c9aa634;hb=53e1b683907c2f12330f00feb9630150196f064d;hp=d8eeb54dbf43846dafbfe31027b9127d11486eba;hpb=df0ff127758809a45105893772de76082d12a26d;p=thirdparty%2Fsystemd.git diff --git a/src/basic/virt.c b/src/basic/virt.c index d8eeb54dbf4..fdbb5018191 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ /*** This file is part of systemd. @@ -216,6 +217,7 @@ static int detect_vm_dmi(void) { } static int detect_vm_xen(void) { + /* Check for Dom0 will be executed later in detect_vm_xen_dom0 Thats why we dont check the content of /proc/xen/capabilities here. */ if (access("/proc/xen/capabilities", F_OK) < 0) { @@ -224,8 +226,7 @@ static int detect_vm_xen(void) { } log_debug("Virtualization XEN found (/proc/xen/capabilities exists)"); - return VIRTUALIZATION_XEN; - + return VIRTUALIZATION_XEN; } static bool detect_vm_xen_dom0(void) { @@ -317,6 +318,7 @@ static int detect_vm_zvm(void) { int detect_vm(void) { static thread_local int cached_found = _VIRTUALIZATION_INVALID; int r, dmi; + bool other = false; if (cached_found >= 0) return cached_found; @@ -337,14 +339,22 @@ int detect_vm(void) { r = detect_vm_cpuid(); if (r < 0) return r; - if (r != VIRTUALIZATION_NONE) - goto finish; + if (r != VIRTUALIZATION_NONE) { + if (r == VIRTUALIZATION_VM_OTHER) + other = true; + else + goto finish; + } r = dmi; if (r < 0) return r; - if (r != VIRTUALIZATION_NONE) - goto finish; + if (r != VIRTUALIZATION_NONE) { + if (r == VIRTUALIZATION_VM_OTHER) + other = true; + else + goto finish; + } /* x86 xen will most likely be detected by cpuid. If not (most likely * because we're not an x86 guest), then we should try the xen capabilities @@ -356,26 +366,42 @@ int detect_vm(void) { r = detect_vm_xen(); if (r < 0) return r; - if (r != VIRTUALIZATION_NONE) - goto finish; + if (r != VIRTUALIZATION_NONE) { + if (r == VIRTUALIZATION_VM_OTHER) + other = true; + else + goto finish; + } r = detect_vm_hypervisor(); if (r < 0) return r; - if (r != VIRTUALIZATION_NONE) - goto finish; + if (r != VIRTUALIZATION_NONE) { + if (r == VIRTUALIZATION_VM_OTHER) + other = true; + else + goto finish; + } r = detect_vm_device_tree(); if (r < 0) return r; - if (r != VIRTUALIZATION_NONE) - goto finish; + if (r != VIRTUALIZATION_NONE) { + if (r == VIRTUALIZATION_VM_OTHER) + other = true; + else + goto finish; + } r = detect_vm_uml(); if (r < 0) return r; - if (r != VIRTUALIZATION_NONE) - goto finish; + if (r != VIRTUALIZATION_NONE) { + if (r == VIRTUALIZATION_VM_OTHER) + other = true; + else + goto finish; + } r = detect_vm_zvm(); if (r < 0) @@ -387,6 +413,8 @@ finish: * double-check it */ if (r == VIRTUALIZATION_XEN && detect_vm_xen_dom0()) r = VIRTUALIZATION_NONE; + else if (r == VIRTUALIZATION_NONE && other) + r = VIRTUALIZATION_VM_OTHER; cached_found = r; log_debug("Found VM virtualization %s", virtualization_to_string(r));