From patchwork Thu Jan 14 21:20:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Litke X-Patchwork-Id: 42927 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 7EB5E1007D2 for ; Fri, 15 Jan 2010 08:21:22 +1100 (EST) Received: from localhost ([127.0.0.1]:34493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVX81-00011d-Em for incoming@patchwork.ozlabs.org; Thu, 14 Jan 2010 16:21:17 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NVX7Z-0000wo-4g for qemu-devel@nongnu.org; Thu, 14 Jan 2010 16:20:49 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NVX7U-0000sv-5l for qemu-devel@nongnu.org; Thu, 14 Jan 2010 16:20:48 -0500 Received: from [199.232.76.173] (port=38291 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVX7U-0000ss-2Z for qemu-devel@nongnu.org; Thu, 14 Jan 2010 16:20:44 -0500 Received: from e32.co.us.ibm.com ([32.97.110.150]:52999) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NVX7S-0007fA-VX for qemu-devel@nongnu.org; Thu, 14 Jan 2010 16:20:43 -0500 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e32.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id o0ELENSK024447 for ; Thu, 14 Jan 2010 14:14:23 -0700 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id o0ELKCin133272 for ; Thu, 14 Jan 2010 14:20:16 -0700 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o0ELKC6i026764 for ; Thu, 14 Jan 2010 14:20:12 -0700 Received: from [9.10.86.208] (aglitke.rchland.ibm.com [9.10.86.208]) by d03av01.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o0ELKBNA026720; Thu, 14 Jan 2010 14:20:11 -0700 From: Adam Litke To: qemu-devel@nongnu.org Organization: IBM Date: Thu, 14 Jan 2010 15:20:10 -0600 Message-ID: <1263504010.2847.27.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: Luiz Capitulino Subject: [Qemu-devel] [PATCH] QMP: Save default control monitor for emitting async events 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). One solution is to save the default QMP session in another monitor pointer (ala cur_mon) and always direct asynchronous events to that monitor... Signed-off-by: Adam Litke diff --git a/monitor.c b/monitor.c index 134ed15..794f6ba 100644 --- a/monitor.c +++ b/monitor.c @@ -128,6 +128,7 @@ static const mon_cmd_t mon_cmds[]; static const mon_cmd_t info_cmds[]; Monitor *cur_mon = NULL; +Monitor *cur_mon_control = NULL; static void monitor_command_cb(Monitor *mon, const char *cmdline, void *opaque); @@ -334,11 +335,11 @@ void monitor_protocol_event(MonitorEvent event, QObject *data) { QDict *qmp; const char *event_name; - Monitor *mon = cur_mon; + Monitor *mon = cur_mon_control; assert(event < QEVENT_MAX); - if (!monitor_ctrl_mode(mon)) + if (!mon) return; switch (event) { @@ -4283,6 +4284,9 @@ void monitor_init(CharDriverState *chr, int flags) QLIST_INSERT_HEAD(&mon_list, mon, entry); if (!cur_mon || (flags & MONITOR_IS_DEFAULT)) cur_mon = mon; + if (!cur_mon_control || (flags & MONITOR_IS_DEFAULT)) + if (flags & MONITOR_USE_CONTROL) + cur_mon_control = mon; } static void bdrv_password_cb(Monitor *mon, const char *password, void *opaque) diff --git a/monitor.h b/monitor.h index 556239a..a343589 100644 --- a/monitor.h +++ b/monitor.h @@ -7,6 +7,7 @@ #include "block.h" extern Monitor *cur_mon; +extern Monitor *cur_mon_control; /* flags for monitor_init */ #define MONITOR_IS_DEFAULT 0x01 diff --git a/qemu-tool.c b/qemu-tool.c index 18b48af..cfe03d6 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -34,6 +34,7 @@ void qemu_service_io(void) } Monitor *cur_mon; +Monitor *cur_mon_control; void monitor_printf(Monitor *mon, const char *fmt, ...) {