From 44797bae448c446e06bb6922f242d8ee054051b7 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 7 Dec 2021 17:22:26 +0100 Subject: [PATCH] qemuDomainSetVcpusInternal: Refactor cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_hotplug.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f307420ac1..b4c8536b47 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6665,16 +6665,15 @@ qemuDomainSetVcpusInternal(virQEMUDriver *driver, bool hotpluggable) { g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); - virBitmap *vcpumap = NULL; + g_autoptr(virBitmap) vcpumap = NULL; bool enable; - int ret = -1; if (def && nvcpus > virDomainDefGetVcpusMax(def)) { virReportError(VIR_ERR_INVALID_ARG, _("requested vcpus is greater than max allowable" " vcpus for the live domain: %u > %u"), nvcpus, virDomainDefGetVcpusMax(def)); - goto cleanup; + return -1; } if (persistentDef && nvcpus > virDomainDefGetVcpusMax(persistentDef)) { @@ -6682,30 +6681,26 @@ qemuDomainSetVcpusInternal(virQEMUDriver *driver, _("requested vcpus is greater than max allowable" " vcpus for the persistent domain: %u > %u"), nvcpus, virDomainDefGetVcpusMax(persistentDef)); - goto cleanup; + return -1; } if (def) { if (!(vcpumap = qemuDomainSelectHotplugVcpuEntities(vm->def, nvcpus, &enable))) - goto cleanup; + return -1; if (qemuDomainSetVcpusLive(driver, cfg, vm, vcpumap, enable) < 0) - goto cleanup; + return -1; } if (persistentDef) { qemuDomainSetVcpusConfig(persistentDef, nvcpus, hotpluggable); if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir) < 0) - goto cleanup; + return -1; } - ret = 0; - - cleanup: - virBitmapFree(vcpumap); - return ret; + return 0; }