]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu_x86: Add debug messages to x86DecodeUseCandidate
authorJiri Denemark <jdenemar@redhat.com>
Fri, 5 Jan 2018 16:43:27 +0000 (17:43 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 10 Jan 2018 10:07:23 +0000 (11:07 +0100)
When translating CPUID data into CPU model + features, the code
sometimes uses an unexpected CPU model. There may be several reasons for
this, starting with wrong expectations and ending with an actual bug in
our code. These debug messages will help determining the reason.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/cpu/cpu_x86.c

index 26314a5b3a40bfb617675f82b83fa6a06a95690d..2a2f7cbf39c15f9932d163416785edec299db3d7 100644 (file)
@@ -1774,12 +1774,15 @@ x86DecodeUseCandidate(virCPUx86ModelPtr current,
         }
     }
 
-    if (preferred &&
-        STREQ(cpuCandidate->model, preferred))
+    if (preferred && STREQ(cpuCandidate->model, preferred)) {
+        VIR_DEBUG("%s is the preferred model", cpuCandidate->model);
         return 2;
+    }
 
-    if (!cpuCurrent)
+    if (!cpuCurrent) {
+        VIR_DEBUG("%s is better than nothing", cpuCandidate->model);
         return 1;
+    }
 
     /* Ideally we want to select a model with family/model equal to
      * family/model of the real CPU. Once we found such model, we only
@@ -1787,20 +1790,30 @@ x86DecodeUseCandidate(virCPUx86ModelPtr current,
      */
     if (signature &&
         current->signature == signature &&
-        candidate->signature != signature)
+        candidate->signature != signature) {
+        VIR_DEBUG("%s differs in signature from matching %s",
+                  cpuCandidate->model, cpuCurrent->model);
         return 0;
+    }
 
-    if (cpuCurrent->nfeatures > cpuCandidate->nfeatures)
+    if (cpuCurrent->nfeatures > cpuCandidate->nfeatures) {
+        VIR_DEBUG("%s results in shorter feature list than %s",
+                  cpuCandidate->model, cpuCurrent->model);
         return 1;
+    }
 
     /* Prefer a candidate with matching signature even though it would
      * result in longer list of features.
      */
     if (signature &&
         candidate->signature == signature &&
-        current->signature != signature)
+        current->signature != signature) {
+        VIR_DEBUG("%s provides matching signature", cpuCandidate->model);
         return 1;
+    }
 
+    VIR_DEBUG("%s does not result in shorter feature list than %s",
+              cpuCandidate->model, cpuCurrent->model);
     return 0;
 }