render / rpms / libvirt

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