From patchwork Thu Feb 11 01:50:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 45100 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 3E492B6F11 for ; Thu, 11 Feb 2010 13:26:16 +1100 (EST) Received: from localhost ([127.0.0.1]:48175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NfOjl-0003Uw-Ur for incoming@patchwork.ozlabs.org; Wed, 10 Feb 2010 21:25:01 -0500 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 Received: from localhost (vpn-10-105.rdu.redhat.com [10.11.10.105]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1B1p51M014641; Wed, 10 Feb 2010 20:51:06 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: armbru@redhat.com Subject: [Qemu-devel] [PATCH 18/21] Monitor: Drop the print disabling mechanism 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 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); }