On 10/26/26 16:05, Denis V. Lunev via Devel wrote:
From: Denis V. Lunev <den@openvz.org>
virObjectEventStateQueueRemote() checks state->timer before taking the state lock. If the last callback is removed in between, virObjectEventStateCleanupTimer() removes the timer and clears the queue, and the event is then queued with no timer to flush it. A callback registered later gets a new timer, but that timer is armed only when a push takes the queue from empty to one event, which never happens again. Neither the stale event nor anything queued after it is dispatched, and no client receives events until the daemon restarts.
A client holding the last callback can trigger this by exiting: its connection drops the callbacks while the hypervisor reports the side effects of the exit, e.g. VNC_DISCONNECTED for a VNC session it had open.
Check the timer under the lock.
The test removes the last callback while another thread is blocked queueing an event, using a freecb that runs under the state lock, and then checks that a newly registered callback still receives events.
Signed-off-by: Denis V. Lunev <den@openvz.org> --- Seen on a host where a management daemon was the only event consumer: after it was restarted with a VNC session open, libvirtd delivered no domain events to anyone, a fresh 'virsh event --all' included, until libvirtd itself was restarted. Restarting that daemon in a loop with a VM running reproduced it in the 11th round; gdb on libvirtd showed timer == -1 with queue->count == 1 right after the daemon exited.
The new test failed 5 of 5 runs without the fix and passed 20 of 20 with it. With the fix the event is simply dropped, so the test does not depend on thread timing. The whole test suite, syntax-check included, passes.
object_event.c has had the unlocked check since it was split out of domain_event.c in v1.2.1, and domain_event.c had it before that.
src/conf/object_event.c | 5 ++- tests/objecteventtest.c | 92 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 2 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> and merged. Sorry for letting this slip the release. Michal