It will become more complicated and so it deserves to be separated into a new function. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/cpu/cpu_x86.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 80019ebd70..fdee107ce9 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1956,6 +1956,27 @@ virCPUx86Compare(virCPUDef *host, } +static int +virCPUx86CompareCandidateFeatureList(virCPUDef *cpuCurrent, + virCPUDef *cpuCandidate) +{ + size_t current = cpuCurrent->nfeatures; + size_t candidate = cpuCandidate->nfeatures; + + if (candidate < current) { + VIR_DEBUG("%s is better than %s: %zu < %zu", + cpuCandidate->model, cpuCurrent->model, + candidate, current); + return 1; + } + + VIR_DEBUG("%s is not better than %s: %zu >= %zu", + cpuCandidate->model, cpuCurrent->model, + candidate, current); + return 0; +} + + /* * Checks whether a candidate model is a better fit for the CPU data than the * current model. @@ -2024,15 +2045,7 @@ x86DecodeUseCandidate(virCPUx86Model *current, } } - if (cpuCurrent->nfeatures > cpuCandidate->nfeatures) { - VIR_DEBUG("%s results in shorter feature list than %s", - cpuCandidate->model, cpuCurrent->model); - return 1; - } - - VIR_DEBUG("%s does not result in shorter feature list than %s", - cpuCandidate->model, cpuCurrent->model); - return 0; + return virCPUx86CompareCandidateFeatureList(cpuCurrent, cpuCandidate); } -- 2.35.1