From cf4934df94ba491527306bebb8cec2fe27281d62 Mon Sep 17 00:00:00 2001
From: Luiz Capitulino <lcapitulino@redhat.com>
Date: Mon, 25 Jan 2010 20:26:14 -0200
Subject: [PATCH 10/11] QMP: Emit asynchronous events on all QMP monitors

RH-Author: Luiz Capitulino <lcapitulino@redhat.com>
Message-id: <20100125182614.6910c43b@doriath>
Patchwork-id: 6615
O-Subject: [PATCH RHEL6 qemu-kvm] QMP: Emit asynchronous events on all QMP
	monitors
Bugzilla: 558619
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Daniel P. Berrange <berrange@redhat.com>

Bugzilla: 558619

This commit is a merge of the following upstream commits:

f039a563f200beee80cc10fd70b21ea396979dab
23fabed13645fdf66473e458f318baa63be56b22

The first one fixes monitor_protocol_emitter() to emit events on all
QMP Monitors (and not only the default one), the second commit fixes
an introduced regression which would cause some async events not to
be delivered when running QEMU with a QMP Monitor and a User Monitor.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 monitor.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/monitor.c b/monitor.c
index 8c36b10..613ee9d 100644
--- a/monitor.c
+++ b/monitor.c
@@ -337,13 +337,10 @@ void monitor_protocol_event(MonitorEvent event, QObject *data)
 {
     QDict *qmp;
     const char *event_name;
-    Monitor *mon = cur_mon;
+    Monitor *mon;
 
     assert(event < QEVENT_MAX);
 
-    if (!monitor_ctrl_mode(mon))
-        return;
-
     switch (event) {
         case QEVENT_DEBUG:
             event_name = "DEBUG";
@@ -373,7 +370,11 @@ void monitor_protocol_event(MonitorEvent event, QObject *data)
         qdict_put_obj(qmp, "data", data);
     }
 
-    monitor_json_emitter(mon, QOBJECT(qmp));
+    QLIST_FOREACH(mon, &mon_list, entry) {
+        if (monitor_ctrl_mode(mon)) {
+            monitor_json_emitter(mon, QOBJECT(qmp));
+        }
+    }
     QDECREF(qmp);
 }
 
-- 
1.6.3.rc4.29.g8146

