From dcfa6c650d44a640b1869bac941fb89c88f7e2cf Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 18 Jan 2022 10:06:38 +0100 Subject: [PATCH] qemuDomainPinIOThread: Copy the cpu bitmap instead of re-parsing it MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The bitmap recorded in the live/persistent definition was re-parsed two more times. We can copy it which is cheaper and less verbose. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko Reviewed-by: Pavel Hrdina --- src/qemu/qemu_driver.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e150b86cef..077547e1d3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5011,7 +5011,6 @@ qemuDomainPinIOThread(virDomainPtr dom, if (def) { virDomainIOThreadIDDef *iothrid; - virBitmap *cpumask; if (!(iothrid = virDomainIOThreadIDFind(def, iothread_id))) { virReportError(VIR_ERR_INVALID_ARG, @@ -5019,11 +5018,8 @@ qemuDomainPinIOThread(virDomainPtr dom, goto endjob; } - if (!(cpumask = virBitmapNewData(cpumap, maplen))) - goto endjob; - virBitmapFree(iothrid->cpumask); - iothrid->cpumask = cpumask; + iothrid->cpumask = virBitmapNewCopy(pcpumap); iothrid->autofill = false; /* Configure the corresponding cpuset cgroup before set affinity. */ @@ -5060,7 +5056,6 @@ qemuDomainPinIOThread(virDomainPtr dom, if (persistentDef) { virDomainIOThreadIDDef *iothrid; - virBitmap *cpumask; if (!(iothrid = virDomainIOThreadIDFind(persistentDef, iothread_id))) { virReportError(VIR_ERR_INVALID_ARG, @@ -5068,11 +5063,8 @@ qemuDomainPinIOThread(virDomainPtr dom, goto endjob; } - if (!(cpumask = virBitmapNewData(cpumap, maplen))) - goto endjob; - virBitmapFree(iothrid->cpumask); - iothrid->cpumask = cpumask; + iothrid->cpumask = virBitmapNewCopy(pcpumap); iothrid->autofill = false; ret = virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir); -- 2.47.3