render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
bcddb9
From 8877885f067aaa87b7ab42de914de5e50f4ef32d Mon Sep 17 00:00:00 2001
bcddb9
Message-Id: <8877885f067aaa87b7ab42de914de5e50f4ef32d@dist-git>
bcddb9
From: Jiri Denemark <jdenemar@redhat.com>
bcddb9
Date: Mon, 4 Mar 2019 16:37:31 +0100
bcddb9
Subject: [PATCH] cpu_x86: Log decoded CPU model and signatures
bcddb9
MIME-Version: 1.0
bcddb9
Content-Type: text/plain; charset=UTF-8
bcddb9
Content-Transfer-Encoding: 8bit
bcddb9
bcddb9
The log message may be useful when debugging why a specific CPU model
bcddb9
was selected for a given set of CPUID data.
bcddb9
bcddb9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
bcddb9
Reviewed-by: Ján Tomko <jtomko@redhat.com>
bcddb9
(cherry picked from commit 5ced12decea42f1d588f2cb28b10ca7a5772098e)
bcddb9
bcddb9
https://bugzilla.redhat.com/show_bug.cgi?id=1558558
bcddb9
https://bugzilla.redhat.com/show_bug.cgi?id=1687515
bcddb9
bcddb9
Conflicts:
bcddb9
	src/cpu/cpu_x86.c
bcddb9
            - VIR_AUTOFREE is not in RHEL-7.6
bcddb9
bcddb9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
bcddb9
Reviewed-by: Ján Tomko <jtomko@redhat.com>
bcddb9
---
bcddb9
 src/cpu/cpu_x86.c | 27 +++++++++++++++++++++++++++
bcddb9
 1 file changed, 27 insertions(+)
bcddb9
bcddb9
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
bcddb9
index 466c79031d..cf3d80eeb5 100644
bcddb9
--- a/src/cpu/cpu_x86.c
bcddb9
+++ b/src/cpu/cpu_x86.c
bcddb9
@@ -1821,6 +1821,26 @@ x86ModelHasSignature(virCPUx86ModelPtr model,
bcddb9
 }
bcddb9
 
bcddb9
 
bcddb9
+static char *
bcddb9
+x86FormatSignatures(virCPUx86ModelPtr model)
bcddb9
+{
bcddb9
+    virBuffer buf = VIR_BUFFER_INITIALIZER;
bcddb9
+    size_t i;
bcddb9
+
bcddb9
+    for (i = 0; i < model->nsignatures; i++) {
bcddb9
+        virBufferAsprintf(&buf, "%06lx,",
bcddb9
+                          (unsigned long)model->signatures[i]);
bcddb9
+    }
bcddb9
+
bcddb9
+    virBufferTrim(&buf, ",", -1);
bcddb9
+
bcddb9
+    if (virBufferCheckError(&buf) < 0)
bcddb9
+        return NULL;
bcddb9
+
bcddb9
+    return virBufferContentAndReset(&buf;;
bcddb9
+}
bcddb9
+
bcddb9
+
bcddb9
 /*
bcddb9
  * Checks whether a candidate model is a better fit for the CPU data than the
bcddb9
  * current model.
bcddb9
@@ -1944,6 +1964,7 @@ x86Decode(virCPUDefPtr cpu,
bcddb9
     virCPUx86Data features = VIR_CPU_X86_DATA_INIT;
bcddb9
     virCPUx86VendorPtr vendor;
bcddb9
     virDomainCapsCPUModelPtr hvModel = NULL;
bcddb9
+    char *sigs = NULL;
bcddb9
     uint32_t signature;
bcddb9
     ssize_t i;
bcddb9
     int rc;
bcddb9
@@ -2036,6 +2057,11 @@ x86Decode(virCPUDefPtr cpu,
bcddb9
     if (vendor && VIR_STRDUP(cpu->vendor, vendor->name) < 0)
bcddb9
         goto cleanup;
bcddb9
 
bcddb9
+    sigs = x86FormatSignatures(model);
bcddb9
+
bcddb9
+    VIR_DEBUG("Using CPU model %s (signatures %s) for CPU with signature %06lx",
bcddb9
+              model->name, NULLSTR(sigs), (unsigned long)signature);
bcddb9
+
bcddb9
     VIR_STEAL_PTR(cpu->model, cpuModel->model);
bcddb9
     VIR_STEAL_PTR(cpu->features, cpuModel->features);
bcddb9
     cpu->nfeatures = cpuModel->nfeatures;
bcddb9
@@ -2050,6 +2076,7 @@ x86Decode(virCPUDefPtr cpu,
bcddb9
     virCPUx86DataClear(&data);
bcddb9
     virCPUx86DataClear(©);
bcddb9
     virCPUx86DataClear(&features);
bcddb9
+    VIR_FREE(sigs);
bcddb9
     return ret;
bcddb9
 }
bcddb9
 
bcddb9
-- 
bcddb9
2.21.0
bcddb9