[libvirt] [PATCH 0/2] Fix a few memory leaks in libvirtd

Jiri Denemark (2): qemu: Don't leak reference to virQEMUDriverConfigPtr qemu: Free all driver data in qemuStateCleanup src/qemu/qemu_driver.c | 2 ++ src/qemu/qemu_process.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) -- 1.8.3.2

https://bugzilla.redhat.com/show_bug.cgi?id=1011330 (case D) qemuProcessStart created two references to virQEMUDriverConfigPtr before calling fork(): cfg = virQEMUDriverGetConfig(driver); ... hookData.cfg = virObjectRef(cfg); However, the child only unreferenced hookData.cfg and the parent only removed the cfg reference. That said, we don't need to increment the reference counter when assigning cfg to hookData. Both the child and the parent will correctly remove the reference on cfg (the child will do that through hookData). Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/qemu/qemu_process.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2b9bfe3..d7be731 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3520,7 +3520,8 @@ int qemuProcessStart(virConnectPtr conn, hookData.conn = conn; hookData.vm = vm; hookData.driver = driver; - hookData.cfg = virObjectRef(cfg); + /* We don't increase cfg's reference counter here. */ + hookData.cfg = cfg; VIR_DEBUG("Beginning VM startup process"); -- 1.8.3.2

On 09/27/2013 07:47 AM, Jiri Denemark wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1011330 (case D)
qemuProcessStart created two references to virQEMUDriverConfigPtr before calling fork():
cfg = virQEMUDriverGetConfig(driver); ... hookData.cfg = virObjectRef(cfg);
However, the child only unreferenced hookData.cfg and the parent only removed the cfg reference. That said, we don't need to increment the reference counter when assigning cfg to hookData. Both the child and the parent will correctly remove the reference on cfg (the child will do that through hookData).
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/qemu/qemu_process.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

https://bugzilla.redhat.com/show_bug.cgi?id=1011330 (case A) While activeScsiHostdevs and webSocketPorts were allocated in qemuStateInitialize, they were not freed in qemuStateCleanup. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/qemu/qemu_driver.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ccd9cc6..e8bc04d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -986,12 +986,14 @@ qemuStateCleanup(void) { virObjectUnref(qemu_driver->activePciHostdevs); virObjectUnref(qemu_driver->inactivePciHostdevs); virObjectUnref(qemu_driver->activeUsbHostdevs); + virObjectUnref(qemu_driver->activeScsiHostdevs); virHashFree(qemu_driver->sharedDevices); virObjectUnref(qemu_driver->caps); virQEMUCapsCacheFree(qemu_driver->qemuCapsCache); virObjectUnref(qemu_driver->domains); virObjectUnref(qemu_driver->remotePorts); + virObjectUnref(qemu_driver->webSocketPorts); virObjectUnref(qemu_driver->xmlopt); -- 1.8.3.2

On 09/27/2013 07:47 AM, Jiri Denemark wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1011330 (case A)
While activeScsiHostdevs and webSocketPorts were allocated in qemuStateInitialize, they were not freed in qemuStateCleanup.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/qemu/qemu_driver.c | 2 ++ 1 file changed, 2 insertions(+)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Jiri Denemark