From 600e135a0bfaa343a1b938632f61acb54e2abf58 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 7 Mar 2025 11:57:43 +0100 Subject: [PATCH] virt: detect "linux,dummy-virt" devicetree VMs So apparently "linux,dummy-virt" is a devicetree in popular use by various hypervisors, including crosvm: https://github.com/google/crosvm/blob/e5d7a64d377d00b9b96bc026548769ab59cf216b/aarch64/src/fdt.rs#L692 and qemu: https://github.com/qemu/qemu/blob/98c7362b1efe651327385a25874a73e008c6549e/hw/arm/virt.c#L283 and that's because the kernel ships support for that natively: https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/linux%2Cdummy-virt.yaml It's explicitly for using in virtualization. Hence it's suitable for detecting it as generic fallback. This hence adds the check, similar to how we already look for one other qemu-specific devicetree. I ran into this while playing around with the new Pixel "Linux Terminal" app from google which runs a Debian in a crosvm apparently. So far systemd didn't recognize execution in it at all. Let's at least recognize it as VM at all, even if this doesn't recognize it as crosvm. --- src/basic/virt.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/basic/virt.c b/src/basic/virt.c index f5a88ed3d6f..a69997b00ac 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -127,9 +127,16 @@ static Virtualization detect_vm_device_tree(void) { r = read_one_line_file("/proc/device-tree/compatible", &compat); if (r < 0 && r != -ENOENT) return log_debug_errno(r, "Failed to read /proc/device-tree/compatible: %m"); - if (r >= 0 && streq(compat, "qemu,pseries")) { - log_debug("Virtualization %s found in /proc/device-tree/compatible", compat); - return VIRTUALIZATION_QEMU; + if (r >= 0) { + if (streq(compat, "qemu,pseries")) { + log_debug("Virtualization %s found in /proc/device-tree/compatible", compat); + return VIRTUALIZATION_QEMU; + } + if (streq(compat, "linux,dummy-virt")) { + /* https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/linux%2Cdummy-virt.yaml */ + log_debug("Generic virtualization %s found in /proc/device-tree/compatible", compat); + return VIRTUALIZATION_VM_OTHER; + } } log_debug("No virtualization found in /proc/device-tree/*"); -- 2.47.3