From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, peter.maydell@linaro.org
Subject: [PULL 9/9] qmp: Resume OOB-enabled monitor before processing the request
Date: Thu, 4 Feb 2021 15:01:36 +0100 [thread overview]
Message-ID: <20210204140136.2769065-10-armbru@redhat.com> (raw)
In-Reply-To: <20210204140136.2769065-1-armbru@redhat.com>
monitor_qmp_dispatcher_co() needs to resume the monitor if
handle_qmp_command() suspended it. Two cases:
1. OOB enabled: suspended if mon->qmp_requests has no more space
2. OOB disabled: suspended always
We resume only after we processed the request. Which can take a long
time.
Resume the monitor right when the queue has space to keep the monitor
available for out-of-band commands even in this corner case.
Leave the "OOB disabled" case alone.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210201161504.1976989-4-armbru@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
[Trailing whitespace tidied up]
---
monitor/qmp.c | 33 +++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)
diff --git a/monitor/qmp.c b/monitor/qmp.c
index e37b047c8a..43880fa623 100644
--- a/monitor/qmp.c
+++ b/monitor/qmp.c
@@ -214,7 +214,7 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data)
{
QMPRequest *req_obj = NULL;
QDict *rsp;
- bool need_resume;
+ bool oob_enabled;
MonitorQMP *mon;
while (true) {
@@ -273,11 +273,32 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data)
aio_co_schedule(qemu_get_aio_context(), qmp_dispatcher_co);
qemu_coroutine_yield();
+ /*
+ * @req_obj has a request, we hold req_obj->mon->qmp_queue_lock
+ */
+
mon = req_obj->mon;
- /* qmp_oob_enabled() might change after "qmp_capabilities" */
- need_resume = !qmp_oob_enabled(mon) ||
- mon->qmp_requests->length == QMP_REQ_QUEUE_LEN_MAX - 1;
+
+ /*
+ * We need to resume the monitor if handle_qmp_command()
+ * suspended it. Two cases:
+ * 1. OOB enabled: mon->qmp_requests has no more space
+ * Resume right away, so that OOB commands can get executed while
+ * this request is being processed.
+ * 2. OOB disabled: always
+ * Resume only after we're done processing the request,
+ * We need to save qmp_oob_enabled() for later, because
+ * qmp_qmp_capabilities() can change it.
+ */
+ oob_enabled = qmp_oob_enabled(mon);
+ if (oob_enabled
+ && mon->qmp_requests->length == QMP_REQ_QUEUE_LEN_MAX - 1) {
+ monitor_resume(&mon->common);
+ }
+
qemu_mutex_unlock(&mon->qmp_queue_lock);
+
+ /* Process request */
if (req_obj->req) {
if (trace_event_get_state(TRACE_MONITOR_QMP_CMD_IN_BAND)) {
QDict *qdict = qobject_to(QDict, req_obj->req);
@@ -298,10 +319,10 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data)
qobject_unref(rsp);
}
- if (need_resume) {
- /* Pairs with the monitor_suspend() in handle_qmp_command() */
+ if (!oob_enabled) {
monitor_resume(&mon->common);
}
+
qmp_request_free(req_obj);
/*
--
2.26.2
next prev parent reply other threads:[~2021-02-04 14:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-04 14:01 [PULL 0/9] QMP patches patches for 2021-02-04 Markus Armbruster
2021-02-04 14:01 ` [PULL 1/9] monitor/qmp-cmds.c: Don't include ui/vnc.h Markus Armbruster
2021-02-04 14:01 ` [PULL 2/9] qobject: open brace '{' following struct go on the same line Markus Armbruster
2021-02-04 14:01 ` [PULL 3/9] qobject: code indent should never use tabs Markus Armbruster
2021-02-04 14:01 ` [PULL 4/9] qobject: spaces required around that operators Markus Armbruster
2021-02-04 14:01 ` [PULL 5/9] qobject: braces {} are necessary for all arms of this statement Markus Armbruster
2021-02-04 14:01 ` [PULL 6/9] docs/interop/qmp-spec: Document the request queue limit Markus Armbruster
2021-02-04 14:01 ` [PULL 7/9] qmp: Fix up comments after commit 9ce44e2ce2 Markus Armbruster
2021-02-04 14:01 ` [PULL 8/9] qmp: Add more tracepoints Markus Armbruster
2021-02-04 14:01 ` Markus Armbruster [this message]
2021-02-04 15:12 ` [PULL 0/9] QMP patches patches for 2021-02-04 no-reply
2021-02-04 15:19 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210204140136.2769065-10-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).