All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [PATCH hci-dev] monitor: fix abort when a rate-limited event races with its timer #VSTOR-156540
@ 2026-11-23 21:29 Denis V. Lunev
  2026-11-23 21:32 ` no-reply
  2026-11-24 12:12 ` Andrey Drobyshev
  0 siblings, 2 replies; 3+ messages in thread
From: Denis V. Lunev @ 2026-11-23 21:29 UTC (permalink / raw)
  To: svt-core; +Cc: andrey.drobyshev, den

From: Denis V. Lunev <den@openvz.org>

Rate-limited events can be raised from iothreads, outside the BQL.
QUORUM_REPORT_BAD always could be. Since 2155d2dd7f73 BLOCK_IO_ERROR is
rate limited too, and any disk on an iothread raises it.

The rate-limit timer runs in the main loop. timerlist_run_timers()
takes it off the active list before it calls the handler, and only then
does the handler take monitor_lock. An iothread raising the same event
for the same device in between finds the rate-limit entry with a timer
that is no longer pending, and QEMU aborts with:

  Assertion `!evstate || timer_pending(evstate->timer)' failed.

This hits virtio-blk on an iothread with an error policy other than
stop when the storage goes away and every guest request fails.

The state is fine, the assert is wrong. Once the timer has fired, the
handler is committed to run: it takes the lock as soon as the iothread
drops it, sends the stored event and re-arms the timer, exactly as for
an event stored while the timer was pending. The event goes out at the
same moment it would have had the iothread come in after the handler.
The entry is only created, re-armed and freed under monitor_lock, so it
cannot go away under the iothread. Drop the assert.

Fixes: a24712af5425 ("monitor: Turn monitor_qapi_event_state[] into a hash table")
Fixes: 2155d2dd7f73 ("block-backend: per-device throttling of BLOCK_IO_ERROR reports")
Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Dr. David Alan Gilbert <dave@treblig.org>
Cc: qemu-stable@nongnu.org
---
 monitor/monitor.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/monitor/monitor.c b/monitor/monitor.c
index f7703d9bd05..408cbfeac58 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -397,13 +397,14 @@ monitor_qapi_event_queue_no_reenter(QAPIEvent event, QDict *qdict)
         MonitorQAPIEventState key = { .event = event, .data = data };
 
         evstate = g_hash_table_lookup(monitor_qapi_event_state, &key);
-        assert(!evstate || timer_pending(evstate->timer));
 
         if (evstate) {
             /*
              * Timer is pending for (at least) evconf->rate ns after
-             * last send.  Store event for sending when timer fires,
-             * replacing a prior stored event if any.
+             * last send, or it has expired and its handler has not
+             * taken monitor_lock yet. Either way the handler will
+             * send what is stored here. Store event for sending
+             * then, replacing a prior stored event if any.
              */
             qobject_unref(evstate->qdict);
             evstate->qdict = qobject_ref(qdict);

base-commit: dd934872c8855d6ed6752edb41bfd9720d584651
-- 
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-24 12:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 21:29 [PATCH hci-dev] monitor: fix abort when a rate-limited event races with its timer #VSTOR-156540 Denis V. Lunev
2026-11-23 21:32 ` no-reply
2026-11-24 12:12 ` Andrey Drobyshev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.