Blame SOURCES/0269-detect-virt-dmi-look-for-KVM.patch

17b0f1
From 795d7cadb7b49ae11e2544ce325779f8d5ec7526 Mon Sep 17 00:00:00 2001
17b0f1
From: Andrew Jones <drjones@redhat.com>
17b0f1
Date: Mon, 9 Nov 2015 14:29:09 +0100
17b0f1
Subject: [PATCH] detect-virt: dmi: look for KVM
17b0f1
17b0f1
Some guests (ARM, AArch64, x86-RHEL) have 'KVM' in the product name.
17b0f1
Look for that first in order to more precisely report "kvm" when
17b0f1
detecting a QEMU/KVM guest. Without this patch we report "qemu",
17b0f1
even if KVM acceleration is in use on ARM/AArch64 guests.
17b0f1
17b0f1
I've only tested a backported version of this and the previous
17b0f1
patch on an AArch64 guest (which worked). Of course it would be
17b0f1
nice to get regression testing on all guest types that depend on
17b0f1
dmi done.
17b0f1
17b0f1
Cherry-picked from: 3728dcde4542b7b2792d9ef0baeb742d82983b03
17b0f1
Resolves: #1278165
17b0f1
---
17b0f1
 src/shared/virt.c | 2 ++
17b0f1
 1 file changed, 2 insertions(+)
17b0f1
17b0f1
diff --git a/src/shared/virt.c b/src/shared/virt.c
17b0f1
index d3ce8dda7f..55a6ca90fb 100644
17b0f1
--- a/src/shared/virt.c
17b0f1
+++ b/src/shared/virt.c
17b0f1
@@ -142,12 +142,14 @@ static int detect_vm_dmi(const char **_id) {
17b0f1
 #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
17b0f1
 
17b0f1
         static const char *const dmi_vendors[] = {
17b0f1
+                "/sys/class/dmi/id/product_name", /* Test this before sys_vendor to detect KVM over QEMU */
17b0f1
                 "/sys/class/dmi/id/sys_vendor",
17b0f1
                 "/sys/class/dmi/id/board_vendor",
17b0f1
                 "/sys/class/dmi/id/bios_vendor"
17b0f1
         };
17b0f1
 
17b0f1
         static const char dmi_vendor_table[] =
17b0f1
+                "KVM\0"                   "kvm\0"
17b0f1
                 "QEMU\0"                  "qemu\0"
17b0f1
                 /* http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458 */
17b0f1
                 "VMware\0"                "vmware\0"