mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-13 08:05:16 +00:00
cpu: Make x86ModelFromCPU easier to read
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
803497a8ac
commit
cb8026dbec
@ -1019,21 +1019,28 @@ x86ModelFromCPU(const virCPUDef *cpu,
|
|||||||
virCPUx86ModelPtr model = NULL;
|
virCPUx86ModelPtr model = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
/* host CPU only contains required features; requesting other features
|
||||||
|
* just returns an empty model
|
||||||
|
*/
|
||||||
|
if (cpu->type == VIR_CPU_TYPE_HOST &&
|
||||||
|
policy != VIR_CPU_FEATURE_REQUIRE)
|
||||||
|
return x86ModelNew();
|
||||||
|
|
||||||
if (policy == VIR_CPU_FEATURE_REQUIRE) {
|
if (policy == VIR_CPU_FEATURE_REQUIRE) {
|
||||||
if (!(model = x86ModelFind(map, cpu->model))) {
|
if (!(model = x86ModelFind(map, cpu->model))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unknown CPU model %s"), cpu->model);
|
_("Unknown CPU model %s"), cpu->model);
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(model = x86ModelCopy(model)))
|
model = x86ModelCopy(model);
|
||||||
goto error;
|
} else {
|
||||||
} else if (!(model = x86ModelNew())) {
|
model = x86ModelNew();
|
||||||
goto error;
|
|
||||||
} else if (cpu->type == VIR_CPU_TYPE_HOST) {
|
|
||||||
return model;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!model)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < cpu->nfeatures; i++) {
|
for (i = 0; i < cpu->nfeatures; i++) {
|
||||||
virCPUx86FeaturePtr feature;
|
virCPUx86FeaturePtr feature;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user