[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 15/24] monitor: suspend when running async and clien
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH 15/24] monitor: suspend when running async and client has no async |
Date: |
Mon, 10 Oct 2016 13:22:52 +0400 |
When the client doesn't support 'async' capability, let's suspend the
monitor until the on-going async command completes. That way, the client
will be able to use -async commands, but will get only in order
reply. (it won't be able to do concurrent commands)
Signed-off-by: Marc-André Lureau <address@hidden>
---
monitor.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/monitor.c b/monitor.c
index 61abb86..0b47f83 100644
--- a/monitor.c
+++ b/monitor.c
@@ -174,6 +174,7 @@ typedef struct {
*/
bool in_command_mode; /* are we in command mode? */
bool has_async; /* the client has async capability */
+ QObject *suspended;
QmpClient client;
} MonitorQMP;
@@ -3683,9 +3684,10 @@ static int monitor_can_read(void *opaque)
{
Monitor *mon = opaque;
- return (mon->suspend_cnt == 0) ? 1 : 0;
+ return (mon->suspend_cnt == 0 && !mon->qmp.suspended) ? 1 : 0;
}
+
static bool invalid_qmp_mode(const Monitor *mon, const char *cmd,
Error **errp)
{
@@ -3762,11 +3764,33 @@ static QDict *qmp_check_input_obj(QObject *input_obj,
Error **errp)
return input_dict;
}
+static void monitor_qmp_suspend(Monitor *mon, QObject *req)
+{
+ assert(monitor_is_qmp(mon));
+ assert(!mon->qmp.suspended);
+
+ qobject_incref(req);
+ mon->qmp.suspended = req;
+}
+
+static void monitor_qmp_resume(Monitor *mon)
+{
+ assert(monitor_is_qmp(mon));
+ assert(mon->qmp.suspended);
+
+ qobject_decref(mon->qmp.suspended);
+ mon->qmp.suspended = NULL;
+}
+
static void qmp_dispatch_return(QmpClient *client, QObject *rsp)
{
Monitor *mon = container_of(client, Monitor, qmp.client);
monitor_json_emitter(mon, rsp);
+
+ if (mon->qmp.suspended) {
+ monitor_qmp_resume(mon);
+ }
}
static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
@@ -3805,6 +3829,12 @@ static void handle_qmp_command(JSONMessageParser
*parser, GQueue *tokens)
}
qmp_dispatch(&mon->qmp.client, req, rqdict);
+
+ /* suspend if the command is on-going and client doesn't support async */
+ if (!QLIST_EMPTY(&mon->qmp.client.pending) && !mon->qmp.has_async) {
+ monitor_qmp_suspend(mon, req);
+ }
+
qobject_decref(req);
return;
--
2.10.0
- [Qemu-devel] [PATCH 05/24] qmp: add QmpClient, (continued)
- [Qemu-devel] [PATCH 05/24] qmp: add QmpClient, Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 06/24] qmp: add qmp_return_is_cancelled(), Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 07/24] qmp: introduce async command type, Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 08/24] qapi: ignore top-level 'id' field, Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 10/24] qmp: check that async command have an 'id', Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 09/24] qmp: take 'id' from request, Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 11/24] scripts: learn 'async' qapi commands, Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 12/24] tests: add dispatch async tests, Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 13/24] monitor: add 'async' capability, Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 14/24] monitor: add !qmp pre-conditions, Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 15/24] monitor: suspend when running async and client has no async,
Marc-André Lureau <=
- [Qemu-devel] [PATCH 16/24] qmp: update qmp-spec about async capability, Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 17/24] qtest: add qtest-timeout, Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 19/24] tests: add tests for async and non-async clients, Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 18/24] qtest: add qtest_init_qmp_caps(), Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 20/24] qapi: improve 'screendump' documentation, Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 21/24] console: graphic_hw_update return true if async, Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 22/24] console: add graphic_hw_update_done(), Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 23/24] console: make screendump async, Marc-André Lureau, 2016/10/10
- [Qemu-devel] [PATCH 24/24] qmp: move json-message-parser to QmpClient, Marc-André Lureau, 2016/10/10