From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Xu <peterx@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: [Qemu-devel] [PULL 27/36] monitor: send event when command queue full
Date: Mon, 12 Mar 2018 13:36:18 -0500 [thread overview]
Message-ID: <20180312183628.394722-28-eblake@redhat.com> (raw)
In-Reply-To: <20180312183628.394722-1-eblake@redhat.com>
From: Peter Xu <peterx@redhat.com>
Set maximum QMP command queue length to 8. If the queue is full,
instead of queuing the command, we directly return a "command-dropped"
event, telling the client that a specific command is dropped.
Note that this flow control mechanism is only valid if OOB is enabled.
If it's not, the effective queue length will always be 1, which strictly
follows original behavior of QMP command handling (which never drops
messages).
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20180309090006.10018-17-peterx@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: commit message grammar, abort on failure to send event]
Signed-off-by: Eric Blake <eblake@redhat.com>
---
monitor.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/monitor.c b/monitor.c
index 07446d6b879..d28457d60d7 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4007,6 +4007,8 @@ static void monitor_qmp_bh_dispatcher(void *data)
}
}
+#define QMP_REQ_QUEUE_LEN_MAX (8)
+
static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
{
QObject *req, *id = NULL;
@@ -4040,6 +4042,9 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
req_obj->req = req;
req_obj->need_resume = false;
+ /* Protect qmp_requests and fetching its length. */
+ qemu_mutex_lock(&mon->qmp.qmp_queue_lock);
+
/*
* If OOB is not enabled on the current monitor, we'll emulate the
* old behavior that we won't process the current monitor any more
@@ -4049,6 +4054,18 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
if (!qmp_oob_enabled(mon)) {
monitor_suspend(mon);
req_obj->need_resume = true;
+ } else {
+ /* Drop the request if queue is full. */
+ if (mon->qmp.qmp_requests->length >= QMP_REQ_QUEUE_LEN_MAX) {
+ qemu_mutex_unlock(&mon->qmp.qmp_queue_lock);
+ qapi_event_send_command_dropped(id,
+ COMMAND_DROP_REASON_QUEUE_FULL,
+ &error_abort);
+ qobject_decref(id);
+ qobject_decref(req);
+ g_free(req_obj);
+ return;
+ }
}
/*
@@ -4056,7 +4073,6 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
* handled in time order. Ownership for req_obj, req, id,
* etc. will be delivered to the handler side.
*/
- qemu_mutex_lock(&mon->qmp.qmp_queue_lock);
g_queue_push_tail(mon->qmp.qmp_requests, req_obj);
qemu_mutex_unlock(&mon->qmp.qmp_queue_lock);
--
2.14.3
next prev parent reply other threads:[~2018-03-12 18:36 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-12 18:35 [Qemu-devel] [PULL 00/36] QAPI patches for 2018-03-12, 2.12 softfreeze Eric Blake
2018-03-12 18:35 ` [Qemu-devel] [PULL 01/36] qapi2texi: minor python code simplification Eric Blake
2018-03-12 18:35 ` [Qemu-devel] [PULL 02/36] qlit: use QType instead of int Eric Blake
2018-03-12 18:35 ` [Qemu-devel] [PULL 03/36] qlit: add qobject_from_qlit() Eric Blake
2018-03-12 18:35 ` [Qemu-devel] [PULL 04/36] qapi: generate a literal qobject for introspection Eric Blake
2018-03-12 18:35 ` [Qemu-devel] [PULL 05/36] compiler: Add QEMU_BUILD_BUG_MSG() macro Eric Blake
2018-03-12 18:35 ` [Qemu-devel] [PULL 06/36] qapi: Add qobject_to() Eric Blake
2018-03-12 18:35 ` [Qemu-devel] [PULL 07/36] qapi: Replace qobject_to_X(o) by qobject_to(X, o) Eric Blake
2018-03-12 18:35 ` [Qemu-devel] [PULL 08/36] qapi: Remove qobject_to_X() functions Eric Blake
2018-04-12 17:51 ` [Qemu-devel] [PULL, " Yuval Shaia
2018-04-12 20:52 ` Eric Blake
2018-04-13 11:33 ` Yuval Shaia
2018-03-12 18:36 ` [Qemu-devel] [PULL 09/36] qapi: Make more of qobject_to() Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 10/36] block: Handle null backing link Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 11/36] block: Deprecate "backing": "" Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 12/36] docs: update QMP documents for OOB commands Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 13/36] qobject: introduce qstring_get_try_str() Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 14/36] qobject: introduce qobject_get_try_str() Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 15/36] qobject: let object_property_get_str() use new API Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 16/36] monitor: move skip_flush into monitor_data_init Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 17/36] monitor: move the cur_mon hack deeper for QMP Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 18/36] monitor: unify global init Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 19/36] monitor: let mon_list be tail queue Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 20/36] monitor: allow using IO thread for parsing Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 21/36] qmp: introduce QMPCapability Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 22/36] monitor: introduce monitor_qmp_respond() Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 23/36] monitor: let suspend_cnt be thread safe Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 24/36] monitor: let suspend/resume work even with QMPs Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 25/36] monitor: separate QMP parser and dispatcher Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 26/36] qmp: add new event "command-dropped" Eric Blake
2018-03-12 18:36 ` Eric Blake [this message]
2018-03-12 18:36 ` [Qemu-devel] [PULL 28/36] qapi: introduce new cmd option "allow-oob" Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 29/36] qmp: support out-of-band (oob) execution Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 30/36] qmp: isolate responses into io thread Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 31/36] monitor: enable IO thread for (qmp & !mux) typed Eric Blake
2018-03-21 12:37 ` Max Reitz
2018-03-21 12:41 ` Max Reitz
2018-03-21 17:11 ` Eric Blake
2018-03-21 17:15 ` Dr. David Alan Gilbert
2018-03-22 3:09 ` Peter Xu
2018-03-12 18:36 ` [Qemu-devel] [PULL 32/36] qmp: add command "x-oob-test" Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 33/36] tests: qmp-test: verify command batching Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 34/36] tests: qmp-test: add oob test Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 35/36] block/accounting: introduce latency histogram Eric Blake
2018-03-12 18:36 ` [Qemu-devel] [PULL 36/36] qapi: add block latency histogram interface Eric Blake
2018-03-13 14:02 ` [Qemu-devel] [PULL 00/36] QAPI patches for 2018-03-12, 2.12 softfreeze Peter Maydell
2018-03-13 14:17 ` Eric Blake
2018-03-13 15:21 ` Peter Xu
2018-03-13 21:55 ` Eric Blake
2018-03-14 12:31 ` 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=20180312183628.394722-28-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=peterx@redhat.com \
--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).