mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
cpu_x86: Use g_auto* in virCPUx86Translate
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
2748e91c54
commit
dff5902018
@ -3015,45 +3015,39 @@ static int
|
|||||||
virCPUx86Translate(virCPUDefPtr cpu,
|
virCPUx86Translate(virCPUDefPtr cpu,
|
||||||
virDomainCapsCPUModelsPtr models)
|
virDomainCapsCPUModelsPtr models)
|
||||||
{
|
{
|
||||||
virCPUDefPtr translated = NULL;
|
g_autoptr(virCPUDef) translated = NULL;
|
||||||
virCPUx86MapPtr map;
|
virCPUx86MapPtr map;
|
||||||
virCPUx86ModelPtr model = NULL;
|
g_autoptr(virCPUx86Model) model = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!(map = virCPUx86GetMap()))
|
if (!(map = virCPUx86GetMap()))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(model = x86ModelFromCPU(cpu, map, -1)))
|
if (!(model = x86ModelFromCPU(cpu, map, -1)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (model->vendor &&
|
if (model->vendor &&
|
||||||
virCPUx86DataAddItem(&model->data, &model->vendor->data) < 0)
|
virCPUx86DataAddItem(&model->data, &model->vendor->data) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (model->signatures &&
|
if (model->signatures &&
|
||||||
x86DataAddSignature(&model->data, model->signatures[0]) < 0)
|
x86DataAddSignature(&model->data, model->signatures[0]) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(translated = virCPUDefCopyWithoutModel(cpu)))
|
if (!(translated = virCPUDefCopyWithoutModel(cpu)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (x86Decode(translated, &model->data, models, NULL, false) < 0)
|
if (x86Decode(translated, &model->data, models, NULL, false) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < cpu->nfeatures; i++) {
|
for (i = 0; i < cpu->nfeatures; i++) {
|
||||||
virCPUFeatureDefPtr f = cpu->features + i;
|
virCPUFeatureDefPtr f = cpu->features + i;
|
||||||
if (virCPUDefUpdateFeature(translated, f->name, f->policy) < 0)
|
if (virCPUDefUpdateFeature(translated, f->name, f->policy) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virCPUDefStealModel(cpu, translated, true);
|
virCPUDefStealModel(cpu, translated, true);
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virCPUDefFree(translated);
|
|
||||||
x86ModelFree(model);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user