• D
    Fix potential events deadlock when unref'ing virConnectPtr · fc8700e9
    Daniel P. Berrange 提交于
    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. This will try to grab a lock on virDomainEventState
    but this lock is already held. Deadlock ensues
    
    Thread 1 (Thread 0x7fcbb526a840 (LWP 23185)):
    
    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
    (cherry picked from commit 2cb0899e)
    fc8700e9
domain_event.c 49.2 KB