]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/extra/0005-monitor-qmp-resume-monitor-when-clearing-its-queue.patch
merge monitor oob fixup
[pve-qemu.git] / debian / patches / extra / 0005-monitor-qmp-resume-monitor-when-clearing-its-queue.patch
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
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
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
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 ---
19 monitor.c | 21 ++++++++++++++++-----
20 1 file changed, 16 insertions(+), 5 deletions(-)
21
22 diff --git a/monitor.c b/monitor.c
23 index 4807bbe811..daadbcdede 100644
24 --- a/monitor.c
25 +++ b/monitor.c
26 @@ -356,12 +356,28 @@ static void qmp_request_free(QMPRequest *req)
27 g_free(req);
28 }
29
30 +static bool qmp_oob_enabled(Monitor *mon)
31 +{
32 + return mon->qmp.capab[QMP_CAPABILITY_OOB];
33 +}
34 +
35 /* Caller must hold mon->qmp.qmp_queue_lock */
36 static void monitor_qmp_cleanup_req_queue_locked(Monitor *mon)
37 {
38 + bool need_resume =
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));
43 }
44 + if (need_resume) {
45 + /*
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
48 + * bh got scheduled.
49 + */
50 + monitor_resume(mon);
51 + }
52 }
53
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);
57 }
58
59 -static bool qmp_oob_enabled(Monitor *mon)
60 -{
61 - return mon->qmp.capab[QMP_CAPABILITY_OOB];
62 -}
63 -
64 static void monitor_qmp_caps_reset(Monitor *mon)
65 {
66 memset(mon->qmp.capab_offered, 0, sizeof(mon->qmp.capab_offered));
67 --
68 2.20.1
69