When running
while true ; do date ; ../tools/virsh -q -c test:///default 'shutdown test;
undefine test; dominfo test' ; done
we often experiance hangs or crashes or memory corruption in
glibc. The reason is that when the virConnectPtr is free'd this
in turn frees the event state, which in turn unregisters the
event timer. The timer may, however, still fire one last time
and it is possible this occurs after the event state has been
freed.
The solution in this series is to only register the timer when
the first callback is added and unregister the timer, when the
last callback is removed.
In doing this patch, I decide to unify more of the event handling
across drivers, and simplify the API usage by drivers, and hide
all the impl details.