From patchwork Fri Oct 28 14:58:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 122416 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B1D9FB6F69 for ; Sat, 29 Oct 2011 01:58:29 +1100 (EST) Received: from localhost ([::1]:52280 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJnsx-0000FK-UQ for incoming@patchwork.ozlabs.org; Fri, 28 Oct 2011 10:58:19 -0400 Received: from eggs.gnu.org ([140.186.70.92]:38446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJnss-0000FF-KW for qemu-devel@nongnu.org; Fri, 28 Oct 2011 10:58:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJnso-0003Fu-DX for qemu-devel@nongnu.org; Fri, 28 Oct 2011 10:58:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJnso-0003Fq-50 for qemu-devel@nongnu.org; Fri, 28 Oct 2011 10:58:10 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9SEw7Qd005098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 28 Oct 2011 10:58:08 -0400 Received: from doriath ([10.3.113.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p9SEw5qw026398; Fri, 28 Oct 2011 10:58:06 -0400 Date: Fri, 28 Oct 2011 12:58:04 -0200 From: Luiz Capitulino To: qemu-devel Message-ID: <20111028125804.751c99de@doriath> Organization: Red Hat Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , Eduardo Habkost , Juan Jose Quintela Carreira Subject: [Qemu-devel] [PATCH] Fix segfault after migration completes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org To reproduce: 1. Start the source VM with: # qemu [...] -S 2. Start the destination VM with: # qemu -incoming tcp:0:4444 3. In the source VM: (qemu) migrate -d tcp:0:4444 3. The source VM will segfault as soon as migration completes (might not happen in the first try) Here's the backtrace: #0 0x0000000000516f39 in qemu_file_get_error (f=0x0) at /home/lcapitulino/src/qmp-unstable/savevm.c:431 431 return f->last_error; #0 0x0000000000516f39 in qemu_file_get_error (f=0x0) at /home/lcapitulino/src/qmp-unstable/savevm.c:431 #1 0x00000000004e7a9a in migrate_fd_put_notify (opaque=0x987640) at /home/lcapitulino/src/qmp-unstable/migration.c:255 #2 0x000000000046d59a in qemu_iohandler_poll (readfds=0x7fff45ccfe50, writefds=0x7fff45ccfdd0, xfds=0x7fff45ccfd50, ret=1) at /home/lcapitulino/src/qmp-unstable/iohandler.c:124 #3 0x00000000004e6033 in main_loop_wait (nonblocking=0) at /home/lcapitulino/src/qmp-unstable/main-loop.c:463 #4 0x00000000004db5b0 in main_loop () at /home/lcapitulino/src/qmp-unstable/vl.c:1478 #5 0x00000000004dffed in main (argc=16, argv=0x7fff45cd0318, envp=0x7fff45cd03a0) at /home/lcapitulino/src/qmp-unstable/vl.c:3449 So, 's->file' is NULL in migrate_fd_put_notify(). The interesting thing is that it's valid in the qemu_file_put_notify() call, which makes me think that either: there's a race somewhere or qemu_file_put_notify() is itself clearing 's->file'. In both cases the fix below could just be hiding the real issue, but let's get started... Signed-off-by: Luiz Capitulino Reviewed-by: Paolo Bonzini Acked-by: Eduardo Habkost --- migration.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/migration.c b/migration.c index bdca72e..f6e6208 100644 --- a/migration.c +++ b/migration.c @@ -252,7 +252,7 @@ static void migrate_fd_put_notify(void *opaque) qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); qemu_file_put_notify(s->file); - if (qemu_file_get_error(s->file)) { + if (s->file && qemu_file_get_error(s->file)) { migrate_fd_error(s); } }