From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:50825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKfjl-0004hO-Po for qemu-devel@nongnu.org; Sun, 30 Oct 2011 20:28:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RKfjk-0007T2-No for qemu-devel@nongnu.org; Sun, 30 Oct 2011 20:28:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKfjk-0007Sy-CE for qemu-devel@nongnu.org; Sun, 30 Oct 2011 20:28:24 -0400 From: Juan Quintela In-Reply-To: <20111028145952.4bb63294@doriath> (Luiz Capitulino's message of "Fri, 28 Oct 2011 14:59:52 -0200") References: <20111028145952.4bb63294@doriath> Date: Mon, 31 Oct 2011 01:27:07 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH v2] Fix segfault on migration completion Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: Paolo Bonzini , qemu-devel , Eduardo Habkost Luiz Capitulino wrote: > A simple migration reproduces it: > > 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 > > 4. The source VM will segfault as soon as migration completes (might not > happen in the first try) > > What is happening here is that qemu_file_put_notify() can end up closing > 's->file' (in which case it's also set to NULL). The call stack is rather > complex, but Eduardo helped tracking it to: > > select loop -> migrate_fd_put_notify() -> qemu_file_put_notify() -> > buffered_put_buffer() -> migrate_fd_put_ready() -> > migrate_fd_completed() -> migrate_fd_cleanup(). > > To be honest, it's not completely clear to me in which cases 's->file' > is not closed (on error maybe)? But I doubt this fix will make anything > worse. > > Reviewed-by: Paolo Bonzini > Acked-by: Eduardo Habkost > Signed-off-by: Luiz Capitulino > --- > > V2: better commit log Acked-by: Juan Quintela And people wonder why error handling on migration is difficult, sniff :-(