mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
cpuCompare: Fix comparison of two host CPUs
When a CPU to be compared with host CPU describes a host CPU instead of a guest CPU, the result is incorrect. This is because instead of treating additional features in host CPU description as required, they were treated as if they were mentioned with all possible policies at the same time.
This commit is contained in:
parent
4677b06428
commit
ac3daf0899
@ -826,8 +826,7 @@ x86ModelFromCPU(const virCPUDefPtr cpu,
|
|||||||
struct x86_model *model = NULL;
|
struct x86_model *model = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (cpu->type == VIR_CPU_TYPE_HOST
|
if (policy == VIR_CPU_FEATURE_REQUIRE) {
|
||||||
|| policy == VIR_CPU_FEATURE_REQUIRE) {
|
|
||||||
if ((model = x86ModelFind(map, cpu->model)) == NULL) {
|
if ((model = x86ModelFind(map, cpu->model)) == NULL) {
|
||||||
virCPUReportError(VIR_ERR_INTERNAL_ERROR,
|
virCPUReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unknown CPU model %s"), cpu->model);
|
_("Unknown CPU model %s"), cpu->model);
|
||||||
@ -839,6 +838,8 @@ x86ModelFromCPU(const virCPUDefPtr cpu,
|
|||||||
}
|
}
|
||||||
else if (VIR_ALLOC(model) < 0)
|
else if (VIR_ALLOC(model) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
else if (cpu->type == VIR_CPU_TYPE_HOST)
|
||||||
|
return model;
|
||||||
|
|
||||||
for (i = 0; i < cpu->nfeatures; i++) {
|
for (i = 0; i < cpu->nfeatures; i++) {
|
||||||
const struct x86_feature *feature;
|
const struct x86_feature *feature;
|
||||||
@ -1181,7 +1182,7 @@ x86Compute(virCPUDefPtr host,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(map = x86LoadMap()) ||
|
if (!(map = x86LoadMap()) ||
|
||||||
!(host_model = x86ModelFromCPU(host, map, 0)) ||
|
!(host_model = x86ModelFromCPU(host, map, VIR_CPU_FEATURE_REQUIRE)) ||
|
||||||
!(cpu_force = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_FORCE)) ||
|
!(cpu_force = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_FORCE)) ||
|
||||||
!(cpu_require = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_REQUIRE)) ||
|
!(cpu_require = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_REQUIRE)) ||
|
||||||
!(cpu_optional = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_OPTIONAL)) ||
|
!(cpu_optional = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_OPTIONAL)) ||
|
||||||
@ -1611,7 +1612,7 @@ x86Baseline(virCPUDefPtr *cpus,
|
|||||||
if (!(map = x86LoadMap()))
|
if (!(map = x86LoadMap()))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!(base_model = x86ModelFromCPU(cpus[0], map, 0)))
|
if (!(base_model = x86ModelFromCPU(cpus[0], map, VIR_CPU_FEATURE_REQUIRE)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (VIR_ALLOC(cpu) < 0 ||
|
if (VIR_ALLOC(cpu) < 0 ||
|
||||||
@ -1630,7 +1631,7 @@ x86Baseline(virCPUDefPtr *cpus,
|
|||||||
for (i = 1; i < ncpus; i++) {
|
for (i = 1; i < ncpus; i++) {
|
||||||
const char *vn = NULL;
|
const char *vn = NULL;
|
||||||
|
|
||||||
if (!(model = x86ModelFromCPU(cpus[i], map, 0)))
|
if (!(model = x86ModelFromCPU(cpus[i], map, VIR_CPU_FEATURE_REQUIRE)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (cpus[i]->vendor && model->vendor &&
|
if (cpus[i]->vendor && model->vendor &&
|
||||||
@ -1710,7 +1711,7 @@ x86Update(virCPUDefPtr guest,
|
|||||||
union cpuData *data = NULL;
|
union cpuData *data = NULL;
|
||||||
|
|
||||||
if (!(map = x86LoadMap()) ||
|
if (!(map = x86LoadMap()) ||
|
||||||
!(host_model = x86ModelFromCPU(host, map, 0)))
|
!(host_model = x86ModelFromCPU(host, map, VIR_CPU_FEATURE_REQUIRE)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; i < guest->nfeatures; i++) {
|
for (i = 0; i < guest->nfeatures; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user