]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
virt: use /proc/xen as indicator for a Xen domain (#6442, #6662) (#7555)
authorOlaf Hering <olaf@aepfle.de>
Wed, 6 Dec 2017 18:59:30 +0000 (19:59 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 6 Dec 2017 18:59:30 +0000 (19:59 +0100)
The file /proc/xen/capabilities is only available if xenfs is mounted.

With a classic xenlinux based kernel that file is available
unconditionally. But with a modern pvops based kernel, xenfs must be
mounted before the "capabilities" may appear. xenfs is mounted very late
via .services files provided by the Xen toolstack. Other units may be
scheduled before xenfs is mounted, which will confuse the detection of
VIRTUALIZATION_XEN.

In all Xen enabled kernels, and if that kernel is actually running on
the Xen hypervisor, the "/proc/xen" directory is the reliable indicator
that this instance runs in a "Xen guest".

Adjust the code to check for /proc/xen instead of
/proc/xen/capabilities.

Fixes commit 3f61278b5 ("basic: Bugfix Detect XEN Dom0 as no virtualization")

src/basic/virt.c

index fdbb5018191529c054dea8b150e885fe7c9aa634..ca771830d134cc29ce4fbe27aa6a3a8b86fe833f 100644 (file)
@@ -219,13 +219,13 @@ 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) {
-                log_debug("Virtualization XEN not found, /proc/xen/capabilities does not exist");
+           The presence of /proc/xen indicates some form of a Xen domain */
+        if (access("/proc/xen", F_OK) < 0) {
+                log_debug("Virtualization XEN not found, /proc/xen does not exist");
                 return VIRTUALIZATION_NONE;
         }
 
-        log_debug("Virtualization XEN found (/proc/xen/capabilities exists)");
+        log_debug("Virtualization XEN found (/proc/xen exists)");
         return VIRTUALIZATION_XEN;
 }
 
@@ -357,11 +357,10 @@ int detect_vm(void) {
         }
 
         /* 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
-         * file next. If that's not found, then we check for the high-level
-         * hypervisor sysfs file:
-         *
-         * https://bugs.freedesktop.org/show_bug.cgi?id=77271 */
+         * because we're not an x86 guest), then we should try the /proc/xen
+         * directory next. If that's not found, then we check for the high-level
+         * hypervisor sysfs file.
+        */
 
         r = detect_vm_xen();
         if (r < 0)