teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0859-virt-Fix-the-detection-for-Hyper-V-VMs.patch

6f381c
From e732bc987f2f779e89f30193bf694e0456ab7ce0 Mon Sep 17 00:00:00 2001
6f381c
From: Boqun Feng <boqun.feng@gmail.com>
6f381c
Date: Tue, 23 Nov 2021 15:09:26 +0800
6f381c
Subject: [PATCH] virt: Fix the detection for Hyper-V VMs
6f381c
6f381c
Use product_version instead of product_name in DMI table and the string
6f381c
"Hyper-V" to avoid misdetection.
6f381c
6f381c
Fixes: #21468
6f381c
6f381c
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
6f381c
(cherry picked from commit 76eec0649936d9ae2f9087769f463feaf0cf5cb4)
6f381c
6f381c
Related: #2158307
6f381c
---
6f381c
 src/basic/virt.c | 5 +++--
6f381c
 1 file changed, 3 insertions(+), 2 deletions(-)
6f381c
6f381c
diff --git a/src/basic/virt.c b/src/basic/virt.c
6f381c
index cc95097101..f750a0463f 100644
6f381c
--- a/src/basic/virt.c
6f381c
+++ b/src/basic/virt.c
6f381c
@@ -143,7 +143,8 @@ static int detect_vm_dmi_vendor(void) {
6f381c
                 "/sys/class/dmi/id/product_name", /* Test this before sys_vendor to detect KVM over QEMU */
6f381c
                 "/sys/class/dmi/id/sys_vendor",
6f381c
                 "/sys/class/dmi/id/board_vendor",
6f381c
-                "/sys/class/dmi/id/bios_vendor"
6f381c
+                "/sys/class/dmi/id/bios_vendor",
6f381c
+                "/sys/class/dmi/id/product_version" /* For Hyper-V VMs test */
6f381c
         };
6f381c
 
6f381c
         static const struct {
6f381c
@@ -162,7 +163,7 @@ static int detect_vm_dmi_vendor(void) {
6f381c
                 { "Parallels",     VIRTUALIZATION_PARALLELS },
6f381c
                 /* https://wiki.freebsd.org/bhyve */
6f381c
                 { "BHYVE",         VIRTUALIZATION_BHYVE     },
6f381c
-                { "Microsoft",           VIRTUALIZATION_MICROSOFT },
6f381c
+                { "Hyper-V",             VIRTUALIZATION_MICROSOFT },
6f381c
         };
6f381c
         unsigned i;
6f381c
         int r;