mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
qemu: Fix leak in qemuProcessInitCpuAffinity()
In two out of three scenarios we are cleaning up properly after
ourselves, but commit 5f2212c062
has changed the remaining one
in a way that caused it to start leaking cpumapToSet.
Refactor the logic so that cpumapToSet is always a freshly
allocated bitmap that gets cleaned up automatically thanks to
VIR_AUTOPTR(); this also allows us to remove the hostcpumap
variable.
Reported-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
b34fb1fb6f
commit
2f2254c7f4
@ -2464,8 +2464,7 @@ static int
|
|||||||
qemuProcessInitCpuAffinity(virDomainObjPtr vm)
|
qemuProcessInitCpuAffinity(virDomainObjPtr vm)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virBitmapPtr cpumapToSet = NULL;
|
VIR_AUTOPTR(virBitmap) cpumapToSet = NULL;
|
||||||
VIR_AUTOPTR(virBitmap) hostcpumap = NULL;
|
|
||||||
virDomainNumatuneMemMode mem_mode;
|
virDomainNumatuneMemMode mem_mode;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
|
||||||
@ -2500,11 +2499,11 @@ qemuProcessInitCpuAffinity(virDomainObjPtr vm)
|
|||||||
if (virNumaNodesetToCPUset(nodeset, &cpumapToSet) < 0)
|
if (virNumaNodesetToCPUset(nodeset, &cpumapToSet) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (vm->def->cputune.emulatorpin) {
|
} else if (vm->def->cputune.emulatorpin) {
|
||||||
cpumapToSet = vm->def->cputune.emulatorpin;
|
if (virBitmapCopy(cpumapToSet, vm->def->cputune.emulatorpin) < 0)
|
||||||
} else {
|
goto cleanup;
|
||||||
if (qemuProcessGetAllCpuAffinity(&hostcpumap) < 0)
|
} else {
|
||||||
|
if (qemuProcessGetAllCpuAffinity(&cpumapToSet) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
cpumapToSet = hostcpumap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cpumapToSet &&
|
if (cpumapToSet &&
|
||||||
|
Loading…
Reference in New Issue
Block a user