From patchwork Fri Jan 15 14:34:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Litke X-Patchwork-Id: 42969 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 893C5B7C8D for ; Sat, 16 Jan 2010 01:42:24 +1100 (EST) Received: from localhost ([127.0.0.1]:39571 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVnIl-0007ua-9S for incoming@patchwork.ozlabs.org; Fri, 15 Jan 2010 09:37:27 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NVnFn-0006dz-Ev for qemu-devel@nongnu.org; Fri, 15 Jan 2010 09:34:23 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NVnFi-0006aB-Gi for qemu-devel@nongnu.org; Fri, 15 Jan 2010 09:34:22 -0500 Received: from [199.232.76.173] (port=44349 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVnFi-0006Zz-61 for qemu-devel@nongnu.org; Fri, 15 Jan 2010 09:34:18 -0500 Received: from e9.ny.us.ibm.com ([32.97.182.139]:47052) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NVnFh-0003Qq-2f for qemu-devel@nongnu.org; Fri, 15 Jan 2010 09:34:17 -0500 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by e9.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id o0FEQENV012386 for ; Fri, 15 Jan 2010 09:26:14 -0500 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o0FEY34P1319120 for ; Fri, 15 Jan 2010 09:34:04 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o0FEY34X016971 for ; Fri, 15 Jan 2010 12:34:03 -0200 Received: from [9.76.77.174] (sig-9-76-77-174.mts.ibm.com [9.76.77.174]) by d01av03.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o0FEY2Qd016907; Fri, 15 Jan 2010 12:34:03 -0200 From: Adam Litke To: Luiz Capitulino In-Reply-To: <20100115113845.588e2398@doriath> References: <1263504010.2847.27.camel@aglitke> <20100115113845.588e2398@doriath> Organization: IBM Date: Fri, 15 Jan 2010 08:34:02 -0600 Message-ID: <1263566042.3536.11.camel@aglitke> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] QMP: Emit asynchronous events on all QMP monitors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 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); }