mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemuDomainSetVcpuInternal: Refactor cleanup
Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
44797bae44
commit
41cd3d434d
@ -6845,19 +6845,18 @@ qemuDomainSetVcpuInternal(virQEMUDriver *driver,
|
|||||||
bool state)
|
bool state)
|
||||||
{
|
{
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||||
virBitmap *livevcpus = NULL;
|
g_autoptr(virBitmap) livevcpus = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (def) {
|
if (def) {
|
||||||
if (!qemuDomainSupportsNewVcpuHotplug(vm)) {
|
if (!qemuDomainSupportsNewVcpuHotplug(vm)) {
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
_("this qemu version does not support specific "
|
_("this qemu version does not support specific "
|
||||||
"vCPU hotplug"));
|
"vCPU hotplug"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(livevcpus = qemuDomainFilterHotplugVcpuEntities(def, map, state)))
|
if (!(livevcpus = qemuDomainFilterHotplugVcpuEntities(def, map, state)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* Make sure that only one hotpluggable entity is selected.
|
/* Make sure that only one hotpluggable entity is selected.
|
||||||
* qemuDomainSetVcpusLive allows setting more at once but error
|
* qemuDomainSetVcpusLive allows setting more at once but error
|
||||||
@ -6866,31 +6865,27 @@ qemuDomainSetVcpuInternal(virQEMUDriver *driver,
|
|||||||
if (virBitmapCountBits(livevcpus) != 1) {
|
if (virBitmapCountBits(livevcpus) != 1) {
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
_("only one hotpluggable entity can be selected"));
|
_("only one hotpluggable entity can be selected"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (persistentDef) {
|
if (persistentDef) {
|
||||||
if (qemuDomainVcpuValidateConfig(persistentDef, map) < 0)
|
if (qemuDomainVcpuValidateConfig(persistentDef, map) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (livevcpus &&
|
if (livevcpus &&
|
||||||
qemuDomainSetVcpusLive(driver, cfg, vm, livevcpus, state) < 0)
|
qemuDomainSetVcpusLive(driver, cfg, vm, livevcpus, state) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (persistentDef) {
|
if (persistentDef) {
|
||||||
qemuDomainSetVcpuConfig(persistentDef, map, state);
|
qemuDomainSetVcpuConfig(persistentDef, map, state);
|
||||||
|
|
||||||
if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir) < 0)
|
if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virBitmapFree(livevcpus);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user