[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 13/24] monitor: add 'async' capability
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH 13/24] monitor: add 'async' capability |
Date: |
Mon, 10 Oct 2016 13:22:50 +0400 |
Declare that the server supports async.
Check if the client supports it: the following patch will suspend the
qmp monitor if an async command is ongoing.
Signed-off-by: Marc-André Lureau <address@hidden>
---
monitor.c | 20 +++++++++++++++++---
qapi-schema.json | 4 ++--
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/monitor.c b/monitor.c
index d7baa86..4a20d81 100644
--- a/monitor.c
+++ b/monitor.c
@@ -173,6 +173,7 @@ typedef struct {
* mode.
*/
bool in_command_mode; /* are we in command mode? */
+ bool has_async; /* the client has async capability */
QmpClient client;
} MonitorQMP;
@@ -570,9 +571,22 @@ static void monitor_qapi_event_init(void)
qmp_event_set_func_emit(monitor_qapi_event_queue);
}
-void qmp_qmp_capabilities(Error **errp)
+void qmp_qmp_capabilities(bool has_capabilities,
+ QMPCapabilityList *capabilities, Error **errp)
{
+ bool has_async = false;
+
+ if (has_capabilities) {
+ while (capabilities) {
+ if (capabilities->value == QMP_CAPABILITY_ASYNC) {
+ has_async = true;
+ }
+ capabilities = capabilities->next;
+ }
+ }
+
cur_mon->qmp.in_command_mode = true;
+ cur_mon->qmp.has_async = has_async;
}
static void handle_hmp_command(Monitor *mon, const char *cmdline);
@@ -3852,8 +3866,8 @@ static QObject *get_qmp_greeting(void)
qmp_marshal_query_version(NULL, &ver, NULL);
- return qobject_from_jsonf("{'QMP': {'version': %p, 'capabilities': []}}",
- ver);
+ return qobject_from_jsonf("{'QMP': {'version': %p, 'capabilities': ["
+ "'async']}}", ver);
}
static void monitor_qmp_event(void *opaque, int event)
diff --git a/qapi-schema.json b/qapi-schema.json
index 93b2929..95d3c72 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -37,7 +37,7 @@
#
# Enable QMP capabilities.
#
-# Arguments: None.
+# @capabilities: #optional an array of QMPCapability (since 2.8)
#
# Example:
#
@@ -51,7 +51,7 @@
# Since: 0.13
#
##
-{ 'command': 'qmp_capabilities' }
+{ 'command': 'qmp_capabilities', 'data': { '*capabilities': ['QMPCapability']
} }
##
# @LostTickPolicy:
--
2.10.0
- Re: [Qemu-devel] [PATCH 03/24] qmp: teach qmp_dispatch() to take a pre-filled QDict, (continued)
- [Qemu-devel] [PATCH 04/24] qmp: use a return callback for the command reply, Marc-André Lureau, 2016/10/10
- [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 <=
- [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, 2016/10/10
- [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