mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
cpu_s390.c: modernize virCPUs390Update
Use automatic cleanup of variables. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Message-Id: <20200522195620.3843442-4-danielhb413@gmail.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
05739fa1ad
commit
a0ba662382
@ -45,8 +45,7 @@ static int
|
|||||||
virCPUs390Update(virCPUDefPtr guest,
|
virCPUs390Update(virCPUDefPtr guest,
|
||||||
const virCPUDef *host)
|
const virCPUDef *host)
|
||||||
{
|
{
|
||||||
virCPUDefPtr updated = NULL;
|
g_autoptr(virCPUDef) updated = NULL;
|
||||||
int ret = -1;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (guest->mode == VIR_CPU_MODE_CUSTOM) {
|
if (guest->mode == VIR_CPU_MODE_CUSTOM) {
|
||||||
@ -58,37 +57,34 @@ virCPUs390Update(virCPUDefPtr guest,
|
|||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("optional CPU features are not supported"));
|
_("optional CPU features are not supported"));
|
||||||
}
|
}
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!host) {
|
if (!host) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("unknown host CPU model"));
|
_("unknown host CPU model"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(updated = virCPUDefCopyWithoutModel(guest)))
|
if (!(updated = virCPUDefCopyWithoutModel(guest)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
updated->mode = VIR_CPU_MODE_CUSTOM;
|
updated->mode = VIR_CPU_MODE_CUSTOM;
|
||||||
if (virCPUDefCopyModel(updated, host, true) < 0)
|
if (virCPUDefCopyModel(updated, host, true) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < guest->nfeatures; i++) {
|
for (i = 0; i < guest->nfeatures; i++) {
|
||||||
if (virCPUDefUpdateFeature(updated,
|
if (virCPUDefUpdateFeature(updated,
|
||||||
guest->features[i].name,
|
guest->features[i].name,
|
||||||
guest->features[i].policy) < 0)
|
guest->features[i].policy) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virCPUDefStealModel(guest, updated, false);
|
virCPUDefStealModel(guest, updated, false);
|
||||||
guest->mode = VIR_CPU_MODE_CUSTOM;
|
guest->mode = VIR_CPU_MODE_CUSTOM;
|
||||||
guest->match = VIR_CPU_MATCH_EXACT;
|
guest->match = VIR_CPU_MATCH_EXACT;
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
cleanup:
|
return 0;
|
||||||
virCPUDefFree(updated);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user