|
|
0a7476 |
From c34dd2135b250a3681c36eead2e85630ad2e13a2 Mon Sep 17 00:00:00 2001
|
|
|
0a7476 |
Message-Id: <c34dd2135b250a3681c36eead2e85630ad2e13a2@dist-git>
|
|
|
0a7476 |
From: Andrea Bolognani <abologna@redhat.com>
|
|
|
0a7476 |
Date: Tue, 4 Jun 2019 16:22:07 +0200
|
|
|
0a7476 |
Subject: [PATCH] qemu: Fix leak in qemuProcessInitCpuAffinity()
|
|
|
0a7476 |
MIME-Version: 1.0
|
|
|
0a7476 |
Content-Type: text/plain; charset=UTF-8
|
|
|
0a7476 |
Content-Transfer-Encoding: 8bit
|
|
|
0a7476 |
|
|
|
0a7476 |
In two out of three scenarios we are cleaning up properly after
|
|
|
0a7476 |
ourselves, but commit 5f2212c062c7 has changed the remaining one
|
|
|
0a7476 |
in a way that caused it to start leaking cpumapToSet.
|
|
|
0a7476 |
|
|
|
0a7476 |
Refactor the logic so that cpumapToSet is always a freshly
|
|
|
0a7476 |
allocated bitmap that gets cleaned up automatically thanks to
|
|
|
0a7476 |
VIR_AUTOPTR(); this also allows us to remove the hostcpumap
|
|
|
0a7476 |
variable.
|
|
|
0a7476 |
|
|
|
0a7476 |
Reported-by: John Ferlan <jferlan@redhat.com>
|
|
|
0a7476 |
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
0a7476 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
0a7476 |
(cherry picked from commit 2f2254c7f4e5bff52ea62a77831230bebc076bab)
|
|
|
0a7476 |
|
|
|
0a7476 |
Conflicts:
|
|
|
0a7476 |
|
|
|
0a7476 |
* src/qemu/qemu_process.c:
|
|
|
0a7476 |
- When upstream commit f136b83139c6 was backported to RHEL
|
|
|
0a7476 |
7.7 as downstream commit eb7ef8053311, the cleanup path in
|
|
|
0a7476 |
qemuProcessInitCpuAffinity() had to be modified to account
|
|
|
0a7476 |
for the lack of VIR_AUTO*() in libvirt 4.5.0; since I'm
|
|
|
0a7476 |
dragging in the memory management macros as part of this
|
|
|
0a7476 |
series, however, I took the opportunity to update the
|
|
|
0a7476 |
cleanup path again: it now matches upstream.
|
|
|
0a7476 |
|
|
|
0a7476 |
https://bugzilla.redhat.com/show_bug.cgi?id=1703661
|
|
|
0a7476 |
|
|
|
0a7476 |
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
0a7476 |
Message-Id: <20190604142207.2036-7-abologna@redhat.com>
|
|
|
0a7476 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
0a7476 |
---
|
|
|
0a7476 |
src/qemu/qemu_process.c | 12 +++++-------
|
|
|
0a7476 |
1 file changed, 5 insertions(+), 7 deletions(-)
|
|
|
0a7476 |
|
|
|
0a7476 |
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
|
0a7476 |
index 4c28f250f6..f77c2ad275 100644
|
|
|
0a7476 |
--- a/src/qemu/qemu_process.c
|
|
|
0a7476 |
+++ b/src/qemu/qemu_process.c
|
|
|
0a7476 |
@@ -2357,8 +2357,7 @@ static int
|
|
|
0a7476 |
qemuProcessInitCpuAffinity(virDomainObjPtr vm)
|
|
|
0a7476 |
{
|
|
|
0a7476 |
int ret = -1;
|
|
|
0a7476 |
- virBitmapPtr cpumapToSet = NULL;
|
|
|
0a7476 |
- virBitmapPtr hostcpumap = NULL;
|
|
|
0a7476 |
+ VIR_AUTOPTR(virBitmap) cpumapToSet = NULL;
|
|
|
0a7476 |
virDomainNumatuneMemMode mem_mode;
|
|
|
0a7476 |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
0a7476 |
|
|
|
0a7476 |
@@ -2393,11 +2392,11 @@ qemuProcessInitCpuAffinity(virDomainObjPtr vm)
|
|
|
0a7476 |
if (virNumaNodesetToCPUset(nodeset, &cpumapToSet) < 0)
|
|
|
0a7476 |
goto cleanup;
|
|
|
0a7476 |
} else if (vm->def->cputune.emulatorpin) {
|
|
|
0a7476 |
- cpumapToSet = vm->def->cputune.emulatorpin;
|
|
|
0a7476 |
- } else {
|
|
|
0a7476 |
- if (qemuProcessGetAllCpuAffinity(&hostcpumap) < 0)
|
|
|
0a7476 |
+ if (virBitmapCopy(cpumapToSet, vm->def->cputune.emulatorpin) < 0)
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+ } else {
|
|
|
0a7476 |
+ if (qemuProcessGetAllCpuAffinity(&cpumapToSet) < 0)
|
|
|
0a7476 |
goto cleanup;
|
|
|
0a7476 |
- cpumapToSet = hostcpumap;
|
|
|
0a7476 |
}
|
|
|
0a7476 |
|
|
|
0a7476 |
if (cpumapToSet &&
|
|
|
0a7476 |
@@ -2406,7 +2405,6 @@ qemuProcessInitCpuAffinity(virDomainObjPtr vm)
|
|
|
0a7476 |
|
|
|
0a7476 |
ret = 0;
|
|
|
0a7476 |
cleanup:
|
|
|
0a7476 |
- virBitmapFree(hostcpumap);
|
|
|
0a7476 |
return ret;
|
|
|
0a7476 |
}
|
|
|
0a7476 |
|
|
|
0a7476 |
--
|
|
|
0a7476 |
2.21.0
|
|
|
0a7476 |
|