]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
virt: Fix the detection for Hyper-V VMs
authorBoqun Feng <boqun.feng@gmail.com>
Tue, 23 Nov 2021 07:09:26 +0000 (15:09 +0800)
committerLennart Poettering <lennart@poettering.net>
Tue, 23 Nov 2021 12:23:33 +0000 (13:23 +0100)
Use product_version instead of product_name in DMI table and the string
"Hyper-V" to avoid misdetection.

Fixes: #21468
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
src/basic/virt.c

index 4e1cbf5b666bf4292946d234d3d815528bec502e..9b7dbdc205fd8eda2f8c62f54689fe131596beae 100644 (file)
@@ -146,7 +146,8 @@ static int detect_vm_dmi_vendor(void) {
                 "/sys/class/dmi/id/product_name", /* Test this before sys_vendor to detect KVM over QEMU */
                 "/sys/class/dmi/id/sys_vendor",
                 "/sys/class/dmi/id/board_vendor",
-                "/sys/class/dmi/id/bios_vendor"
+                "/sys/class/dmi/id/bios_vendor",
+                "/sys/class/dmi/id/product_version" /* For Hyper-V VMs test */
         };
 
         static const struct {
@@ -165,7 +166,7 @@ static int detect_vm_dmi_vendor(void) {
                 { "Parallels",           VIRTUALIZATION_PARALLELS },
                 /* https://wiki.freebsd.org/bhyve */
                 { "BHYVE",               VIRTUALIZATION_BHYVE     },
-                { "Microsoft",           VIRTUALIZATION_MICROSOFT },
+                { "Hyper-V",             VIRTUALIZATION_MICROSOFT },
         };
         int r;