From patchwork Thu Dec 3 18:21:21 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 40188 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 004B8B7BD9 for ; Fri, 4 Dec 2009 05:22:16 +1100 (EST) Received: from localhost ([127.0.0.1]:40983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGGJg-00015X-Sm for incoming@patchwork.ozlabs.org; Thu, 03 Dec 2009 13:22:12 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NGGJ7-00010y-0R for qemu-devel@nongnu.org; Thu, 03 Dec 2009 13:21:37 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NGGJ2-0000ro-8P for qemu-devel@nongnu.org; Thu, 03 Dec 2009 13:21:36 -0500 Received: from [199.232.76.173] (port=53534 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGGJ1-0000rc-Us for qemu-devel@nongnu.org; Thu, 03 Dec 2009 13:21:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3009) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NGGJ1-0003Yo-Jh for qemu-devel@nongnu.org; Thu, 03 Dec 2009 13:21:31 -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 nB3ILSFn018401 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 3 Dec 2009 13:21:29 -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 nB3ILO89001073 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 3 Dec 2009 13:21:27 -0500 Date: Thu, 3 Dec 2009 16:21:21 -0200 From: Luiz Capitulino To: jan.kiszka@siemens.com Message-ID: <20091203162121.67d9c120@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. Cc: qemu-devel@nongnu.org, lirans@il.ibm.com Subject: [Qemu-devel] [STAGING]: Block migration segfaults 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 Hi there, Got this while testing block migration in staging: """ Program terminated with signal 11, Segmentation fault. #0 0x0000000000410cf9 in monitor_vprintf (mon=0x0, fmt=0x5ae5e7 "Start full migration for %s\n", ap=0x7fff1f830a40) at /home/lcapitulino/src/aliguori-queue/monitor.c:192 192 if (mon->mc && !mon->mc->print_enabled) { """ The problem here is that init_blk_migration() calls monitor_printf() with a NULL 'mon' and the backtrace shows that this is true for the entire call chain. You probably didn't note it before because the lowest-level monitor print function would just return if the 'mon' parameter was NULL. A patch from me (4a29a in staging) changes a higher level monitor function to touch 'mon' before passing it down and here's the segfault. Now, the point is: I could give the old behavior back but I think we're hiding a bug there. Why would you call monitor_printf() with a NULL 'mon'? Anyways, the following patch adds the old behavior back just in case you want to see it working... commit 3575196202d4e54c1fc63a631ca5bd1a7778e30d Author: Luiz Capitulino Date: Thu Dec 3 15:49:16 2009 -0200 monitor: Fix block migration segfault 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 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)