a03d84
From a4365b9dc13ecc0cad34599c7cbe466612436d8a Mon Sep 17 00:00:00 2001
a03d84
From: "Richard W.M. Jones" <rjones@redhat.com>
a03d84
Date: Fri, 4 Oct 2019 18:30:01 +0100
a03d84
Subject: [PATCH 7/8] helper: Fix KVM signature.
a03d84
a03d84
Thanks: Paolo Bonzini.
a03d84
(cherry picked from commit 5cdf740942a4f443977344428dfe6c43f232f0eb)
a03d84
---
a03d84
 virt-what-cpuid-helper.c | 9 +++++----
a03d84
 1 file changed, 5 insertions(+), 4 deletions(-)
a03d84
a03d84
diff --git a/virt-what-cpuid-helper.c b/virt-what-cpuid-helper.c
a03d84
index 0cd4a6f..9c6cdb2 100644
a03d84
--- a/virt-what-cpuid-helper.c
a03d84
+++ b/virt-what-cpuid-helper.c
a03d84
@@ -28,15 +28,16 @@
a03d84
 #if defined(__i386__) || defined(__x86_64__)
a03d84
 
a03d84
 /* Known x86 hypervisor signatures.  Note that if you add a new test
a03d84
- * to virt-what.in you may need to update this list.  The signature is
a03d84
- * always 12 bytes except in the case of KVM.
a03d84
+ * to virt-what.in you may need to update this list.  Note the
a03d84
+ * signature is always 12 bytes long, plus we add \0 to the end to
a03d84
+ * make it 13 bytes.
a03d84
  */
a03d84
 static int
a03d84
-known_signature (char *sig)
a03d84
+known_signature (const char *sig)
a03d84
 {
a03d84
   return
a03d84
     strcmp (sig, "bhyve bhyve ") == 0 ||
a03d84
-    strcmp (sig, "KVMKVMKVM") == 0 ||
a03d84
+    memcmp (sig, "KVMKVMKVM\0\0\0", 12) == 0 ||
a03d84
     strcmp (sig, "LKVMLKVMLKVM") == 0 ||
a03d84
     strcmp (sig, "Microsoft Hv") == 0 ||
a03d84
     strcmp (sig, "OpenBSDVMM58") == 0 ||
a03d84
-- 
a03d84
2.32.0
a03d84