From patchwork Thu Dec 3 19:02:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 40217 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 55D06B6EEF for ; Fri, 4 Dec 2009 06:05:03 +1100 (EST) Received: from localhost ([127.0.0.1]:41087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGGz6-0003vD-QB for incoming@patchwork.ozlabs.org; Thu, 03 Dec 2009 14:05:00 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NGGx4-00034Z-Jd for qemu-devel@nongnu.org; Thu, 03 Dec 2009 14:02:54 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NGGwz-00031j-Ki for qemu-devel@nongnu.org; Thu, 03 Dec 2009 14:02:54 -0500 Received: from [199.232.76.173] (port=36319 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGGwz-00031b-CY for qemu-devel@nongnu.org; Thu, 03 Dec 2009 14:02:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39248) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NGGwy-00083b-Tf for qemu-devel@nongnu.org; Thu, 03 Dec 2009 14:02:49 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nB3J2lRN018996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 3 Dec 2009 14:02:47 -0500 Received: from doriath (vpn-8-53.rdu.redhat.com [10.11.8.53]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nB3J2imL012379 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Thu, 3 Dec 2009 14:02:46 -0500 Date: Thu, 3 Dec 2009 17:02:41 -0200 From: Luiz Capitulino To: qemu-devel@nongnu.org Message-ID: <20091203170241.6a8f0451@doriath> Organization: Red Hat Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [FOR 0.12] monitor: Catch printing to non-existent monitor 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 The monitor_vprintf() function now touches the 'mon' variable before calling monitor_puts(), this causes block migration to segfault as its functions call monitor_printf() with a NULL 'mon'. This is probably hiding the real bug, but for some reason this has been the behavior for a long time. We also change monitor_print_object() to use monitor_print(), so that monitor_puts() is only called by monitor_vprintf(). Signed-off-by: Luiz Capitulino --- monitor.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/monitor.c b/monitor.c index b035e0b..6d0b1dd 100644 --- a/monitor.c +++ b/monitor.c @@ -171,9 +171,6 @@ static void monitor_puts(Monitor *mon, const char *str) { char c; - if (!mon) - return; - for(;;) { c = *str++; if (c == '\0') @@ -189,6 +186,9 @@ static void monitor_puts(Monitor *mon, const char *str) void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { + if (!mon) + return; + if (mon->mc && !mon->mc->print_enabled) { qemu_error_new(QERR_UNDEFINED_ERROR); } else { @@ -269,7 +269,7 @@ static void monitor_print_qobject(Monitor *mon, const QObject *data) break; } - monitor_puts(mon, "\n"); + monitor_printf(mon, "\n"); } static void monitor_json_emitter(Monitor *mon, const QObject *data)