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 <jdene...@redhat.com>
---
 src/cpu/cpu_x86.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 26314a5b3a..2a2f7cbf39 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -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;
 }
 
-- 
2.15.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to