From ad80ccd3f9a96eb96dd92537b9df26031176fa48 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Fri, 5 Jan 2018 17:43:27 +0100 Subject: [PATCH] cpu_x86: Add debug messages to x86DecodeUseCandidate 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 Reviewed-by: Pavel Hrdina --- 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.39.5