]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_x86: Log decoded CPU model and signatures
authorJiri Denemark <jdenemar@redhat.com>
Mon, 4 Mar 2019 15:37:31 +0000 (16:37 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 5 Mar 2019 13:40:37 +0000 (14:40 +0100)
The log message may be useful when debugging why a specific CPU model
was selected for a given set of CPUID data.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/cpu/cpu_x86.c

index 08677ef7ff63c2a60441c95caccaa97641de3bfd..60e3011521110b29bf7068bc5d6306162cd024d6 100644 (file)
@@ -1773,6 +1773,26 @@ x86ModelHasSignature(virCPUx86ModelPtr model,
 }
 
 
+static char *
+x86FormatSignatures(virCPUx86ModelPtr model)
+{
+    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    size_t i;
+
+    for (i = 0; i < model->nsignatures; i++) {
+        virBufferAsprintf(&buf, "%06lx,",
+                          (unsigned long)model->signatures[i]);
+    }
+
+    virBufferTrim(&buf, ",", -1);
+
+    if (virBufferCheckError(&buf) < 0)
+        return NULL;
+
+    return virBufferContentAndReset(&buf);
+}
+
+
 /*
  * Checks whether a candidate model is a better fit for the CPU data than the
  * current model.
@@ -1896,6 +1916,7 @@ x86Decode(virCPUDefPtr cpu,
     virCPUx86Data features = VIR_CPU_X86_DATA_INIT;
     virCPUx86VendorPtr vendor;
     virDomainCapsCPUModelPtr hvModel = NULL;
+    VIR_AUTOFREE(char *) sigs = NULL;
     uint32_t signature;
     ssize_t i;
     int rc;
@@ -1988,6 +2009,11 @@ x86Decode(virCPUDefPtr cpu,
     if (vendor && VIR_STRDUP(cpu->vendor, vendor->name) < 0)
         goto cleanup;
 
+    sigs = x86FormatSignatures(model);
+
+    VIR_DEBUG("Using CPU model %s (signatures %s) for CPU with signature %06lx",
+              model->name, NULLSTR(sigs), (unsigned long)signature);
+
     VIR_STEAL_PTR(cpu->model, cpuModel->model);
     VIR_STEAL_PTR(cpu->features, cpuModel->features);
     cpu->nfeatures = cpuModel->nfeatures;