]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
virt: detect "linux,dummy-virt" devicetree VMs 36655/head
authorLennart Poettering <lennart@poettering.net>
Fri, 7 Mar 2025 10:57:43 +0000 (11:57 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 7 Mar 2025 14:18:08 +0000 (15:18 +0100)
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

index f5a88ed3d6fbe349fa5fa17eee8c5f30df45303a..a69997b00ac02d902a0d431e4d512d5cadd643fd 100644 (file)
@@ -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/*");