c313de
From 3335b5e0db21375053c5005be9f820f7ba945010 Mon Sep 17 00:00:00 2001
c313de
Message-Id: <3335b5e0db21375053c5005be9f820f7ba945010@dist-git>
c313de
From: Jiri Denemark <jdenemar@redhat.com>
c313de
Date: Fri, 21 Jun 2019 09:25:02 +0200
c313de
Subject: [PATCH] cpu_x86: Log decoded CPU model and signatures
c313de
MIME-Version: 1.0
c313de
Content-Type: text/plain; charset=UTF-8
c313de
Content-Transfer-Encoding: 8bit
c313de
c313de
The log message may be useful when debugging why a specific CPU model
c313de
was selected for a given set of CPUID data.
c313de
c313de
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
(cherry picked from commit 5ced12decea42f1d588f2cb28b10ca7a5772098e)
c313de
c313de
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
c313de
c313de
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c313de
Message-Id: <cae19825427465e352de05433920c96dc44552ff.1561068591.git.jdenemar@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
---
c313de
 src/cpu/cpu_x86.c | 26 ++++++++++++++++++++++++++
c313de
 1 file changed, 26 insertions(+)
c313de
c313de
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
c313de
index 7bd8119c23..ba14a6097d 100644
c313de
--- a/src/cpu/cpu_x86.c
c313de
+++ b/src/cpu/cpu_x86.c
c313de
@@ -1769,6 +1769,26 @@ x86ModelHasSignature(virCPUx86ModelPtr model,
c313de
 }
c313de
 
c313de
 
c313de
+static char *
c313de
+x86FormatSignatures(virCPUx86ModelPtr model)
c313de
+{
c313de
+    virBuffer buf = VIR_BUFFER_INITIALIZER;
c313de
+    size_t i;
c313de
+
c313de
+    for (i = 0; i < model->nsignatures; i++) {
c313de
+        virBufferAsprintf(&buf, "%06lx,",
c313de
+                          (unsigned long)model->signatures[i]);
c313de
+    }
c313de
+
c313de
+    virBufferTrim(&buf, ",", -1);
c313de
+
c313de
+    if (virBufferCheckError(&buf) < 0)
c313de
+        return NULL;
c313de
+
c313de
+    return virBufferContentAndReset(&buf;;
c313de
+}
c313de
+
c313de
+
c313de
 /*
c313de
  * Checks whether a candidate model is a better fit for the CPU data than the
c313de
  * current model.
c313de
@@ -1892,6 +1912,7 @@ x86Decode(virCPUDefPtr cpu,
c313de
     virCPUx86Data features = VIR_CPU_X86_DATA_INIT;
c313de
     virCPUx86VendorPtr vendor;
c313de
     virDomainCapsCPUModelPtr hvModel = NULL;
c313de
+    VIR_AUTOFREE(char *) sigs = NULL;
c313de
     uint32_t signature;
c313de
     ssize_t i;
c313de
     int rc;
c313de
@@ -1984,6 +2005,11 @@ x86Decode(virCPUDefPtr cpu,
c313de
     if (vendor && VIR_STRDUP(cpu->vendor, vendor->name) < 0)
c313de
         goto cleanup;
c313de
 
c313de
+    sigs = x86FormatSignatures(model);
c313de
+
c313de
+    VIR_DEBUG("Using CPU model %s (signatures %s) for CPU with signature %06lx",
c313de
+              model->name, NULLSTR(sigs), (unsigned long)signature);
c313de
+
c313de
     VIR_STEAL_PTR(cpu->model, cpuModel->model);
c313de
     VIR_STEAL_PTR(cpu->features, cpuModel->features);
c313de
     cpu->nfeatures = cpuModel->nfeatures;
c313de
-- 
c313de
2.22.0
c313de