From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NfOD0-0007Rs-CS for qemu-devel@nongnu.org; Wed, 10 Feb 2010 20:51:10 -0500 Received: from [199.232.76.173] (port=57762 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NfOD0-0007R7-09 for qemu-devel@nongnu.org; Wed, 10 Feb 2010 20:51:10 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NfOCy-0001LE-QY for qemu-devel@nongnu.org; Wed, 10 Feb 2010 20:51:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54098) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NfOCy-0001LA-ES for qemu-devel@nongnu.org; Wed, 10 Feb 2010 20:51:08 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1B1p7nF019020 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 10 Feb 2010 20:51:07 -0500 From: Luiz Capitulino Date: Wed, 10 Feb 2010 23:50:04 -0200 Message-Id: <1265853007-27300-19-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1265853007-27300-1-git-send-email-lcapitulino@redhat.com> References: <1265853007-27300-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 18/21] Monitor: Drop the print disabling mechanism List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: armbru@redhat.com We can ignore calls to monitor_vprintf() in QMP mode and use monitor_puts() directly in monitor_json_emitter(). This allows us to drop this ugly hack. Signed-off-by: Luiz Capitulino --- monitor.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/monitor.c b/monitor.c index 2a14e81..d5b406c 100644 --- a/monitor.c +++ b/monitor.c @@ -120,7 +120,6 @@ struct mon_fd_t { typedef struct MonitorControl { QObject *id; - int print_enabled; JSONMessageParser parser; int command_mode; } MonitorControl; @@ -226,16 +225,18 @@ static void monitor_puts(Monitor *mon, const char *str) void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { + char buf[4096]; + if (!mon) return; - if (mon->mc && !mon->mc->print_enabled) { + if (monitor_ctrl_mode(mon)) { qemu_error_new(QERR_UNDEFINED_ERROR); - } else { - char buf[4096]; - vsnprintf(buf, sizeof(buf), fmt, ap); - monitor_puts(mon, buf); + return; } + + vsnprintf(buf, sizeof(buf), fmt, ap); + monitor_puts(mon, buf); } void monitor_printf(Monitor *mon, const char *fmt, ...) @@ -306,9 +307,8 @@ static void monitor_json_emitter(Monitor *mon, const QObject *data) json = qobject_to_json(data); assert(json != NULL); - mon->mc->print_enabled = 1; - monitor_printf(mon, "%s\n", qstring_get_str(json)); - mon->mc->print_enabled = 0; + qstring_append_chr(json, '\n'); + monitor_puts(mon, qstring_get_str(json)); QDECREF(json); } -- 1.6.6