]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/extra/0001-monitor-qmp-resume-monitor-when-clearing-its-queue.patch
Update and rebase to QEMU 4.1
[pve-qemu.git] / debian / patches / extra / 0001-monitor-qmp-resume-monitor-when-clearing-its-queue.patch
CommitLineData
3b1986f0
WB
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
be901f66 3Date: Wed, 2 Oct 2019 10:30:03 +0200
3b1986f0
WB
4Subject: [PATCH] monitor/qmp: resume monitor when clearing its queue
5
6When a monitor's queue is filled up in handle_qmp_command()
7it gets suspended. It's the dispatcher bh's job currently to
be901f66 8resume the monitor, which it does after processing an event
3b1986f0
WB
9from the queue. However, it is possible for a
10CHR_EVENT_CLOSED event to be processed before before the bh
11is scheduled, which will clear the queue without resuming
12the monitor, thereby preventing the dispatcher from reaching
13the resume() call.
14Fix this by resuming the monitor when clearing a queue which
15was filled up.
16
17Signed-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
22diff --git a/monitor/qmp.c b/monitor/qmp.c
23index 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)