]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Only add the timer when a callback is registered
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 14 Dec 2011 00:25:58 +0000 (00:25 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 19 Dec 2011 11:08:25 +0000 (11:08 +0000)
commit707781fe1269dc49fad98de0ca943047ccf1053a
tree3c9c97a463aad9252028490d453b0f8add1260b5
parent34ad13536e5b48e96d7a981ff5ada8b2da9295b3
Only add the timer when a callback is registered

The lifetime of the virDomainEventState object is tied to
the lifetime of the driver, which in stateless drivers is
tied to the lifetime of the virConnectPtr.

If we add & remove a timer when allocating/freeing the
virDomainEventState object, we can get a situation where
the timer still triggers once after virDomainEventState
has been freed. The timeout callback can't keep a ref
on the event state though, since that would be a circular
reference.

The trick is to only register the timer when a callback
is registered with the event state & remove the timer
when the callback is unregistered.

The demo for the bug is to run

  while true ; do date ; ../tools/virsh -q -c test:///default 'shutdown test; undefine test; dominfo test' ; done

prior to this fix, it will frequently hang and / or
crash, or corrupt memory
src/conf/domain_event.c
src/conf/domain_event.h
src/libxl/libxl_driver.c
src/lxc/lxc_driver.c
src/qemu/qemu_driver.c
src/remote/remote_driver.c
src/test/test_driver.c
src/uml/uml_driver.c
src/vbox/vbox_tmpl.c
src/xen/xen_driver.c