mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-06 06:15:46 +00:00
cpu_x86: Refactor feature list comparison in x86DecodeUseCandidate
It will become more complicated and so it deserves to be separated into a new function. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
35ce086667
commit
1d6ca40ac2
@ -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
|
* Checks whether a candidate model is a better fit for the CPU data than the
|
||||||
* current model.
|
* current model.
|
||||||
@ -2024,15 +2045,7 @@ x86DecodeUseCandidate(virCPUx86Model *current,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cpuCurrent->nfeatures > cpuCandidate->nfeatures) {
|
return virCPUx86CompareCandidateFeatureList(cpuCurrent, cpuCandidate);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user