mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemuDomainSetVcpusInternal: 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
5b7653a628
commit
44797bae44
@ -6665,16 +6665,15 @@ qemuDomainSetVcpusInternal(virQEMUDriver *driver,
|
|||||||
bool hotpluggable)
|
bool hotpluggable)
|
||||||
{
|
{
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||||
virBitmap *vcpumap = NULL;
|
g_autoptr(virBitmap) vcpumap = NULL;
|
||||||
bool enable;
|
bool enable;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (def && nvcpus > virDomainDefGetVcpusMax(def)) {
|
if (def && nvcpus > virDomainDefGetVcpusMax(def)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("requested vcpus is greater than max allowable"
|
_("requested vcpus is greater than max allowable"
|
||||||
" vcpus for the live domain: %u > %u"),
|
" vcpus for the live domain: %u > %u"),
|
||||||
nvcpus, virDomainDefGetVcpusMax(def));
|
nvcpus, virDomainDefGetVcpusMax(def));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (persistentDef && nvcpus > virDomainDefGetVcpusMax(persistentDef)) {
|
if (persistentDef && nvcpus > virDomainDefGetVcpusMax(persistentDef)) {
|
||||||
@ -6682,30 +6681,26 @@ qemuDomainSetVcpusInternal(virQEMUDriver *driver,
|
|||||||
_("requested vcpus is greater than max allowable"
|
_("requested vcpus is greater than max allowable"
|
||||||
" vcpus for the persistent domain: %u > %u"),
|
" vcpus for the persistent domain: %u > %u"),
|
||||||
nvcpus, virDomainDefGetVcpusMax(persistentDef));
|
nvcpus, virDomainDefGetVcpusMax(persistentDef));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def) {
|
if (def) {
|
||||||
if (!(vcpumap = qemuDomainSelectHotplugVcpuEntities(vm->def, nvcpus,
|
if (!(vcpumap = qemuDomainSelectHotplugVcpuEntities(vm->def, nvcpus,
|
||||||
&enable)))
|
&enable)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuDomainSetVcpusLive(driver, cfg, vm, vcpumap, enable) < 0)
|
if (qemuDomainSetVcpusLive(driver, cfg, vm, vcpumap, enable) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (persistentDef) {
|
if (persistentDef) {
|
||||||
qemuDomainSetVcpusConfig(persistentDef, nvcpus, hotpluggable);
|
qemuDomainSetVcpusConfig(persistentDef, nvcpus, hotpluggable);
|
||||||
|
|
||||||
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(vcpumap);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user