mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 20:45:18 +00:00
qemuProcessSetupHotpluggableVcpus: Use automatic memory freeing
'bootHotplug' can be auto-freed when terminating the function and moving the declaration of 'vcpuprops' to the loop which uses it along with automatic freeing allows us to simplify cleanup in certain cases. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
0b6888451f
commit
a257668ede
@ -5985,12 +5985,11 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *driver,
|
|||||||
qemuCgroupEmulatorAllNodesData *emulatorCgroup = NULL;
|
qemuCgroupEmulatorAllNodesData *emulatorCgroup = NULL;
|
||||||
virDomainVcpuDef *vcpu;
|
virDomainVcpuDef *vcpu;
|
||||||
qemuDomainVcpuPrivate *vcpupriv;
|
qemuDomainVcpuPrivate *vcpupriv;
|
||||||
virJSONValue *vcpuprops = NULL;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
virDomainVcpuDef **bootHotplug = NULL;
|
g_autofree virDomainVcpuDef **bootHotplug = NULL;
|
||||||
size_t nbootHotplug = 0;
|
size_t nbootHotplug = 0;
|
||||||
|
|
||||||
for (i = 0; i < maxvcpus; i++) {
|
for (i = 0; i < maxvcpus; i++) {
|
||||||
@ -6005,10 +6004,8 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *driver,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbootHotplug == 0) {
|
if (nbootHotplug == 0)
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
qsort(bootHotplug, nbootHotplug, sizeof(*bootHotplug),
|
qsort(bootHotplug, nbootHotplug, sizeof(*bootHotplug),
|
||||||
qemuProcessVcpusSortOrder);
|
qemuProcessVcpusSortOrder);
|
||||||
@ -6017,6 +6014,7 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; i < nbootHotplug; i++) {
|
for (i = 0; i < nbootHotplug; i++) {
|
||||||
|
g_autoptr(virJSONValue) vcpuprops = NULL;
|
||||||
vcpu = bootHotplug[i];
|
vcpu = bootHotplug[i];
|
||||||
|
|
||||||
if (!(vcpuprops = qemuBuildHotpluggableCPUProps(vcpu)))
|
if (!(vcpuprops = qemuBuildHotpluggableCPUProps(vcpu)))
|
||||||
@ -6033,16 +6031,12 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *driver,
|
|||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virJSONValueFree(vcpuprops);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuCgroupEmulatorAllNodesRestore(emulatorCgroup);
|
qemuCgroupEmulatorAllNodesRestore(emulatorCgroup);
|
||||||
VIR_FREE(bootHotplug);
|
|
||||||
virJSONValueFree(vcpuprops);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user