1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Wed, 2 Oct 2019 09:41:34 +0200
4 Subject: [PATCH] monitor/qmp: resume monitor when clearing its queue
6 When a monitor's queue is filled up in handle_qmp_command()
7 it gets suspended. It's the dispatcher bh's job currently to
8 resume the monitor, which it does after processing an even
9 from the queue. However, it is possible for a
10 CHR_EVENT_CLOSED event to be processed before before the bh
11 is scheduled, which will clear the queue without resuming
12 the monitor, thereby preventing the dispatcher from reaching
14 Fix this by resuming the monitor when clearing a queue which
17 Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
19 monitor.c | 21 ++++++++++++++++-----
20 1 file changed, 16 insertions(+), 5 deletions(-)
22 diff --git a/monitor.c b/monitor.c
23 index 4807bbe811..daadbcdede 100644
26 @@ -356,12 +356,28 @@ static void qmp_request_free(QMPRequest *req)
30 +static bool qmp_oob_enabled(Monitor *mon)
32 + return mon->qmp.capab[QMP_CAPABILITY_OOB];
35 /* Caller must hold mon->qmp.qmp_queue_lock */
36 static void monitor_qmp_cleanup_req_queue_locked(Monitor *mon)
39 + (!qmp_oob_enabled(mon) && mon->qmp.qmp_requests->length > 0)
40 + || mon->qmp.qmp_requests->length == QMP_REQ_QUEUE_LEN_MAX;
41 while (!g_queue_is_empty(mon->qmp.qmp_requests)) {
42 qmp_request_free(g_queue_pop_head(mon->qmp.qmp_requests));
46 + * Pairs with the monitor_suspend() in handle_qmp_command() in case the
47 + * queue gets cleared from a CH_EVENT_CLOSED event before the dispatch
50 + monitor_resume(mon);
54 static void monitor_qmp_cleanup_queues(Monitor *mon)
55 @@ -1157,11 +1173,6 @@ static void monitor_init_qmp_commands(void)
56 qmp_marshal_qmp_capabilities, QCO_ALLOW_PRECONFIG);
59 -static bool qmp_oob_enabled(Monitor *mon)
61 - return mon->qmp.capab[QMP_CAPABILITY_OOB];
64 static void monitor_qmp_caps_reset(Monitor *mon)
66 memset(mon->qmp.capab_offered, 0, sizeof(mon->qmp.capab_offered));