diff mbox

[05/11] QMP: advertise asynchronous messages

Message ID 1264108180-3666-6-git-send-email-lcapitulino@redhat.com
State New
Headers show

Commit Message

Luiz Capitulino Jan. 21, 2010, 9:09 p.m. UTC
With feature negotiation support asynchronous messages are
going to behave like any protocol capability, that is, it
is disabled by default, it can be negotiated and has to be
advertised.

TODO: update spec.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
diff mbox

Patch

diff --git a/monitor.c b/monitor.c
index fc6a1ed..70a59c7 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4251,6 +4251,21 @@  void monitor_resume(Monitor *mon)
         readline_show_prompt(mon->rs);
 }
 
+/* XXX: Do we need anything fancier here? */
+static QObject *qmp_capabilities(void)
+{
+    int i;
+    QList *qmp_caps;
+    const char *capabilities[] = { "async messages", NULL };
+
+    qmp_caps = qlist_new();
+    for (i = 0; capabilities[i]; i++) {
+        qlist_append(qmp_caps, qstring_from_str(capabilities[i]));
+    }
+
+    return QOBJECT(qmp_caps);
+}
+
 /**
  * monitor_control_event(): Print QMP gretting
  */
@@ -4262,7 +4277,8 @@  static void monitor_control_event(void *opaque, int event)
 
         json_message_parser_init(&mon->mc->parser, handle_qmp_command);
 
-        data = qobject_from_jsonf("{ 'QMP': { 'capabilities': [] } }");
+        data = qobject_from_jsonf("{ 'QMP': { 'capabilities': %p } }",
+                                  qmp_capabilities()); 
         assert(data != NULL);
 
         monitor_json_emitter(mon, data);