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