diff mbox

QMP: Emit asynchronous events on all QMP monitors

Message ID 1263566042.3536.11.camel@aglitke
State New
Headers show

Commit Message

Adam Litke Jan. 15, 2010, 2:34 p.m. UTC
When using a control/QMP monitor in tandem with a regular monitor, asynchronous
messages can get lost depending on the order of the QEMU program arguments.
QEMU events issued by monitor_protocol_event() always go to cur_mon.  If the
user monitor was specified on the command line first (or it has ,default), the
message will be directed to the user monitor (not the QMP monitor).
Additionally, only one QMP session is currently able to receive async messages.

To avoid this confusion, scan through the list of monitors and emit the message
on each QMP monitor.

Signed-off-by: Adam Litke <agl@us.ibm.com>

Comments

Luiz Capitulino Jan. 15, 2010, 3 p.m. UTC | #1
On Fri, 15 Jan 2010 08:34:02 -0600
Adam Litke <agl@us.ibm.com> wrote:

> When using a control/QMP monitor in tandem with a regular monitor, asynchronous
> messages can get lost depending on the order of the QEMU program arguments.
> QEMU events issued by monitor_protocol_event() always go to cur_mon.  If the
> user monitor was specified on the command line first (or it has ,default), the
> message will be directed to the user monitor (not the QMP monitor).
> Additionally, only one QMP session is currently able to receive async messages.
> 
> To avoid this confusion, scan through the list of monitors and emit the message
> on each QMP monitor.
> 
> Signed-off-by: Adam Litke <agl@us.ibm.com>
> 
> diff --git a/monitor.c b/monitor.c
> index 134ed15..06c8bf0 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -334,13 +334,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,12 @@ 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))
> +            return;
> +
> +        monitor_json_emitter(mon, QOBJECT(qmp));
> +    }

 The function will return on the first !QMP Monitor, the
right QLIST_FOREACH() body is:

if (monitor_ctrl_mode(mon)) {
 monitor_json_emitter(mon, QOBJECT(qmp));
}

 I'll ACK the respin.

>      QDECREF(qmp);
>  }
>  
> 
>
Anthony Liguori Jan. 19, 2010, 10:40 p.m. UTC | #2
On 01/15/2010 08:34 AM, Adam Litke wrote:
> When using a control/QMP monitor in tandem with a regular monitor, asynchronous
> messages can get lost depending on the order of the QEMU program arguments.
> QEMU events issued by monitor_protocol_event() always go to cur_mon.  If the
> user monitor was specified on the command line first (or it has ,default), the
> message will be directed to the user monitor (not the QMP monitor).
> Additionally, only one QMP session is currently able to receive async messages.
>
> To avoid this confusion, scan through the list of monitors and emit the message
> on each QMP monitor.
>
> Signed-off-by: Adam Litke<agl@us.ibm.com>
>    

Applied.  Thanks.

Regards,

Anthony Liguori
> diff --git a/monitor.c b/monitor.c
> index 134ed15..06c8bf0 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -334,13 +334,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,12 @@ 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))
> +            return;
> +
> +        monitor_json_emitter(mon, QOBJECT(qmp));
> +    }
>       QDECREF(qmp);
>   }
>
>
>
>
diff mbox

Patch

diff --git a/monitor.c b/monitor.c
index 134ed15..06c8bf0 100644
--- a/monitor.c
+++ b/monitor.c
@@ -334,13 +334,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,12 @@  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))
+            return;
+
+        monitor_json_emitter(mon, QOBJECT(qmp));
+    }
     QDECREF(qmp);
 }