]>
Commit | Line | Data |
---|---|---|
3b1986f0 WB |
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
2 | From: Wolfgang Bumiller <w.bumiller@proxmox.com> | |
be901f66 | 3 | Date: Wed, 2 Oct 2019 10:30:03 +0200 |
3b1986f0 WB |
4 | Subject: [PATCH] monitor/qmp: resume monitor when clearing its queue |
5 | ||
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 | |
be901f66 | 8 | resume the monitor, which it does after processing an event |
3b1986f0 WB |
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 | |
13 | the resume() call. | |
14 | Fix this by resuming the monitor when clearing a queue which | |
15 | was filled up. | |
16 | ||
17 | Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com> | |
18 | --- | |
be901f66 SR |
19 | monitor/qmp.c | 10 ++++++++++ |
20 | 1 file changed, 10 insertions(+) | |
3b1986f0 | 21 | |
be901f66 SR |
22 | diff --git a/monitor/qmp.c b/monitor/qmp.c |
23 | index e1b196217d..fb3e66c62a 100644 | |
24 | --- a/monitor/qmp.c | |
25 | +++ b/monitor/qmp.c | |
26 | @@ -70,9 +70,19 @@ static void qmp_request_free(QMPRequest *req) | |
3b1986f0 | 27 | /* Caller must hold mon->qmp.qmp_queue_lock */ |
be901f66 | 28 | static void monitor_qmp_cleanup_req_queue_locked(MonitorQMP *mon) |
3b1986f0 | 29 | { |
be901f66 SR |
30 | + bool need_resume = (!qmp_oob_enabled(mon) && mon->qmp_requests->length > 0) |
31 | + || mon->qmp_requests->length == QMP_REQ_QUEUE_LEN_MAX; | |
32 | while (!g_queue_is_empty(mon->qmp_requests)) { | |
33 | qmp_request_free(g_queue_pop_head(mon->qmp_requests)); | |
3b1986f0 WB |
34 | } |
35 | + if (need_resume) { | |
36 | + /* | |
37 | + * Pairs with the monitor_suspend() in handle_qmp_command() in case the | |
38 | + * queue gets cleared from a CH_EVENT_CLOSED event before the dispatch | |
39 | + * bh got scheduled. | |
40 | + */ | |
be901f66 | 41 | + monitor_resume(&mon->common); |
3b1986f0 WB |
42 | + } |
43 | } | |
44 | ||
be901f66 | 45 | static void monitor_qmp_cleanup_queues(MonitorQMP *mon) |