[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 13/25] monitor: add 'async' capability
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH v2 13/25] monitor: add 'async' capability |
Date: |
Wed, 18 Jan 2017 20:03:20 +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 but the client doesn't
support async.
Signed-off-by: Marc-André Lureau <address@hidden>
---
qapi-schema.json | 16 ++++++++++++++--
include/qapi/qmp/dispatch.h | 1 +
monitor.c | 19 ++++++++++++++++---
3 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/qapi-schema.json b/qapi-schema.json
index ddc878390e..8366206415 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -72,11 +72,23 @@
##
##
+# @QMPCapability:
+#
+# QMP protocol capabilities
+#
+# @async: enables async messages
+#
+# Since: 2.9
+##
+{ 'enum': 'QMPCapability',
+ 'data': ['async'] }
+
+##
# @qmp_capabilities:
#
# Enable QMP capabilities.
#
-# Arguments: None.
+# @capabilities: #optional an array of @QMPCapability (since 2.9)
#
# Example:
#
@@ -90,7 +102,7 @@
# Since: 0.13
#
##
-{ 'command': 'qmp_capabilities' }
+{ 'command': 'qmp_capabilities', 'data': { '*capabilities': ['QMPCapability']
} }
##
# @LostTickPolicy:
diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h
index e13e381834..4dd6de5ab2 100644
--- a/include/qapi/qmp/dispatch.h
+++ b/include/qapi/qmp/dispatch.h
@@ -32,6 +32,7 @@ struct QmpClient {
QmpDispatchReturn *return_cb;
QLIST_HEAD(, QmpReturn) pending;
+ bool has_async; /* the client has async capability */
};
typedef void (QmpCommandFunc)(QDict *, QObject **, Error **);
diff --git a/monitor.c b/monitor.c
index 98ba40b573..585f7b6a1a 100644
--- a/monitor.c
+++ b/monitor.c
@@ -563,9 +563,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.client.has_async = has_async;
}
static void handle_hmp_command(Monitor *mon, const char *cmdline);
@@ -3845,8 +3858,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)
--
2.11.0.295.gd7dffce1c
- [Qemu-devel] [PATCH v2 03/25] qmp: teach qmp_dispatch() to take a pre-filled QDict, (continued)
- [Qemu-devel] [PATCH v2 03/25] qmp: teach qmp_dispatch() to take a pre-filled QDict, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 04/25] qmp: use a return callback for the command reply, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 05/25] qmp: add QmpClient, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 06/25] qmp: add qmp_return_is_cancelled(), Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 08/25] qapi: ignore top-level 'id' field, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 07/25] qmp: introduce async command type, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 09/25] qmp: take 'id' from request, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 10/25] qmp: check that async command have an 'id', Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 11/25] scripts: learn 'async' qapi commands, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 12/25] tests: add dispatch async tests, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 13/25] monitor: add 'async' capability,
Marc-André Lureau <=
- [Qemu-devel] [PATCH v2 14/25] monitor: add !qmp pre-conditions, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 15/25] monitor: suspend when running async and client has no async, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 16/25] qmp: update qmp-spec about async capability, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 17/25] qtest: add qtest-timeout, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 19/25] tests: add tests for async and non-async clients, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 18/25] qtest: add qtest_init_qmp_caps(), Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 20/25] qapi: improve 'screendump' documentation, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 21/25] console: graphic_hw_update return true if async, Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 22/25] console: add graphic_hw_update_done(), Marc-André Lureau, 2017/01/18
- [Qemu-devel] [PATCH v2 23/25] console: make screendump async, Marc-André Lureau, 2017/01/18