diff options
author | Boqun Feng <boqun.feng@gmail.com> | 2021-11-23 15:09:26 +0800 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-11-23 13:23:33 +0100 |
commit | 76eec0649936d9ae2f9087769f463feaf0cf5cb4 (patch) | |
tree | f3f0f772dad232c57127591b0a2a8c4f58701e54 /src/basic/virt.c | |
parent | 244cab4a651d4a5b5d9f0275ef59b8273418ee51 (diff) | |
download | systemd-76eec0649936d9ae2f9087769f463feaf0cf5cb4.tar.gz |
virt: Fix the detection for Hyper-V VMs
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>
Diffstat (limited to 'src/basic/virt.c')
-rw-r--r-- | src/basic/virt.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/basic/virt.c b/src/basic/virt.c index 4e1cbf5b66..9b7dbdc205 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -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; |