qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC v2 21/22] qmp: introduce QMPCapability


From: Peter Xu
Subject: [Qemu-devel] [RFC v2 21/22] qmp: introduce QMPCapability
Date: Fri, 29 Sep 2017 11:38:43 +0800

There was no QMP capabilities defined.  Define the first "oob" as
capability to allow out-of-band messages.

Signed-off-by: Peter Xu <address@hidden>
---
 monitor.c        | 15 +++++++++++++--
 qapi-schema.json | 13 +++++++++++++
 tests/qmp-test.c |  2 +-
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/monitor.c b/monitor.c
index 649491a2ce..e33f7fa069 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4160,12 +4160,23 @@ void monitor_resume(Monitor *mon)
 
 static QObject *get_qmp_greeting(void)
 {
+    QDict *result = qdict_new(), *qmp = qdict_new();
+    QList *cap_list = qlist_new();
     QObject *ver = NULL;
+    QMPCapability cap;
+
+    qdict_put(result, "QMP", qmp);
 
     qmp_marshal_query_version(NULL, &ver, NULL);
+    qdict_put_obj(qmp, "version", ver);
+
+    for (cap = 0; cap < QMP_CAPABILITY__MAX; cap++) {
+        qlist_append(cap_list, qstring_from_str(
+                         QMPCapability_str(cap)));
+    }
+    qdict_put(qmp, "capabilities", cap_list);
 
-    return qobject_from_jsonf("{'QMP': {'version': %p, 'capabilities': []}}",
-                              ver);
+    return QOBJECT(result);
 }
 
 static void monitor_qmp_event(void *opaque, int event)
diff --git a/qapi-schema.json b/qapi-schema.json
index 0b04e06a4c..82122986d9 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -119,6 +119,19 @@
 { 'command': 'qmp_capabilities' }
 
 ##
+# @QMPCapability:
+#
+# QMP supported capabilities to be broadcasted to the clients.
+#
+# @oob:   QMP ability to support Out-Of-Band requests.
+#
+# Since: 2.11
+#
+##
+{ 'enum': 'QMPCapability',
+  'data': [ 'oob' ] }
+
+##
 # @VersionTriple:
 #
 # A three-part version number.
diff --git a/tests/qmp-test.c b/tests/qmp-test.c
index c5a5c10b41..91049ab215 100644
--- a/tests/qmp-test.c
+++ b/tests/qmp-test.c
@@ -84,7 +84,7 @@ static void test_qmp_protocol(void)
     g_assert(q);
     test_version(qdict_get(q, "version"));
     capabilities = qdict_get_qlist(q, "capabilities");
-    g_assert(capabilities && qlist_empty(capabilities));
+    g_assert(capabilities);
     QDECREF(resp);
 
     /* Test valid command before handshake */
-- 
2.13.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]