[libvirt] [PATCH] Fix potential events deadlock when unref'ing virConnectPtr

Eric Blake eblake at redhat.com
Mon May 21 15:07:50 UTC 2012


On 05/21/2012 05:17 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> When the last reference to a virConnectPtr is released by
> libvirtd, it was possible for a deadlock to occur in the
> virDomainEventState functions. The virDomainEventStatePtr
> holds a reference on virConnectPtr for each registered
> callback. When removing a callback, the virUnrefConnect
> function is run. If this causes the last reference on the
> virConnectPtr to be released, then virReleaseConnect can
> be run, which in turns calls qemudClose. This function has
> a call to virDomainEventStateDeregisterConn which is intended
> to remove all callbacks associated with the virConnectPtr
> instance.
> 
> Since each callback associated with a virConnectPtr holds a
> reference on virConnectPtr, it is impossible for the qemudClose
> method to be invoked while any callbacks are still registered.
> Thus the call to virDomainEventStateDeregisterConn must in fact
> be a no-op. Thus it is possible to just remove all trace of
> virDomainEventStateDeregisterConn and avoid the deadlock.
> 
> * src/conf/domain_event.c, src/conf/domain_event.h,
>   src/libvirt_private.syms: Delete virDomainEventStateDeregisterConn
> * src/libxl/libxl_driver.c, src/lxc/lxc_driver.c,
>   src/qemu/qemu_driver.c, src/uml/uml_driver.c: Remove
>   calls to virDomainEventStateDeregisterConn
> ---
>  src/conf/domain_event.c  |   61 ----------------------------------------------
>  src/conf/domain_event.h  |    4 ---
>  src/libvirt_private.syms |    1 -
>  src/libxl/libxl_driver.c |    4 ---
>  src/lxc/lxc_driver.c     |    2 --
>  src/qemu/qemu_driver.c   |    2 --
>  src/uml/uml_driver.c     |    2 --
>  7 files changed, 76 deletions(-)

Always fun to fix bugs by deletion.

ACK.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120521/acb02067/attachment-0001.sig>


More information about the libvir-list mailing list