]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Fix reference handling leak on qemuMonitor
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 10 Jun 2010 14:11:30 +0000 (15:11 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 23 Jun 2010 13:08:05 +0000 (14:08 +0100)
commitc21216026051ca5ad2298b0a50b9e0317b30ff80
treebe69df3dafd0483a75cf9892a009843552a404ad
parent8d616decc5faa6bbb9da6693cfe154e8728d555f
Fix reference handling leak on qemuMonitor

The current code pattern requires that callers of qemuMonitorClose
check for the return value == 0, and if so, set priv->mon = NULL
and release the reference held on the associated virDomainObjPtr

The change d84bb6d6a3bd2fdd530184cc9743249ebddbee71 violated that
requirement, meaning that priv->mon never gets set to NULL, and
a reference count is leaked on virDomainObjPtr.

This design was a bad one, so remove the need to check the return
valueof qemuMonitorClose(). Instead allow registration of a
callback that's invoked just when the last reference on qemuMonitorPtr
is released.

Finally there was a potential reference leak in qemuConnectMonitor
in the failure path.

* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add a destroy
  callback invoked from qemuMonitorFree
* src/qemu/qemu_driver.c: Use the destroy callback to release the
  reference on virDomainObjPtr when the monitor is freed. Fix other
  potential reference count leak in connecting to monitor
src/qemu/qemu_driver.c
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h