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.
This commit is contained in:
Lennart Poettering
2025-03-07 15:18:08 +01:00
parent 4d53d76f5e
commit 600e135a0b
+10 -3
View 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/*");