From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NVnuZ-00041b-7s for qemu-devel@nongnu.org; Fri, 15 Jan 2010 10:16:31 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NVnuU-00041M-4e for qemu-devel@nongnu.org; Fri, 15 Jan 2010 10:16:30 -0500 Received: from [199.232.76.173] (port=43461 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVnuU-00041J-29 for qemu-devel@nongnu.org; Fri, 15 Jan 2010 10:16:26 -0500 Received: from e35.co.us.ibm.com ([32.97.110.153]:45309) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NVnuT-0007gj-MQ for qemu-devel@nongnu.org; Fri, 15 Jan 2010 10:16:25 -0500 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e35.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id o0FF2fK9027237 for ; Fri, 15 Jan 2010 08:02:41 -0700 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id o0FFG6bO100572 for ; Fri, 15 Jan 2010 08:16:10 -0700 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o0FFG5U5020824 for ; Fri, 15 Jan 2010 08:16:05 -0700 From: Adam Litke In-Reply-To: <20100115130051.024ff95b@doriath> References: <1263504010.2847.27.camel@aglitke> <20100115113845.588e2398@doriath> <1263566042.3536.11.camel@aglitke> <20100115130051.024ff95b@doriath> Content-Type: text/plain; charset="UTF-8" Date: Fri, 15 Jan 2010 09:16:03 -0600 Message-ID: <1263568563.3536.29.camel@aglitke> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH][RESPIN] QMP: Emit asynchronous events on all QMP monitors List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: qemu-devel@nongnu.org On Fri, 2010-01-15 at 13:00 -0200, Luiz Capitulino wrote: > 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. Ah right, of course. Thanks and here it is. 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 Acked-by: Luiz Capitulino diff --git a/monitor.c b/monitor.c index 134ed15..6a2c7fb 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,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); } -- Thanks, Adam