From patchwork Tue Mar 3 10:27:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 445653 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 716081400EA for ; Tue, 3 Mar 2015 21:28:15 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=B17Q8t6X; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from localhost ([::1]:35689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSk3g-0002jI-NM for incoming@patchwork.ozlabs.org; Tue, 03 Mar 2015 05:28:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSk3P-0002Gi-EY for qemu-devel@nongnu.org; Tue, 03 Mar 2015 05:27:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YSk3M-0003Jy-Nh for qemu-devel@nongnu.org; Tue, 03 Mar 2015 05:27:55 -0500 Received: from mail-wg0-x234.google.com ([2a00:1450:400c:c00::234]:41194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSk3M-0003Ju-Ge for qemu-devel@nongnu.org; Tue, 03 Mar 2015 05:27:52 -0500 Received: by wghl18 with SMTP id l18so39001583wgh.8 for ; Tue, 03 Mar 2015 02:27:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=g9m0T2X9BS8jhZ7TA3HcOz9cIP4mG/gx42ZH6u6QzJI=; b=B17Q8t6X0FQ2ttw7LJR8wC6nPP8MHKVyyHrfeTP8ecZDFwfxP03qYJqFQh26FB+M+x M9f3cxSZPcNQRKY3ooHrNGEikWgLTND7VzxG8dVla0h0ZrFT322QYSgo6eT0qGp1wTLc i82tEMeQ0kKyTwdF1e79MIf7+v5bzzu0ARcZ4FrACIeRdwZ03Pd5z2pJd+4eE0Ml0Jku AK1PoqGqQD553CBTkrMlEweHnXbfunT7VIrXWIQJudpqkmA6upqMEoGGL5guE1iI3DJZ ZqrKKd6HFu+PPwdPyQCLkVAu+RKBjXb7Y4xjtbxmB08S+RTNGXdw+mun4K3gZfNxyn8z /ecw== X-Received: by 10.194.120.132 with SMTP id lc4mr69461510wjb.92.1425378471331; Tue, 03 Mar 2015 02:27:51 -0800 (PST) Received: from [192.168.10.150] (net-37-116-207-136.cust.vodafonedsl.it. [37.116.207.136]) by mx.google.com with ESMTPSA id t9sm19911464wia.15.2015.03.03.02.27.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Mar 2015 02:27:49 -0800 (PST) Message-ID: <54F58CA3.2090802@redhat.com> Date: Tue, 03 Mar 2015 11:27:47 +0100 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: "Gonglei (Arei)" , "qemu-devel@nongnu.org" References: <33183CC9F5247A488A2544077AF1902086E48F40@SZXEMA503-MBS.china.huawei.com> <54F588D7.6060804@redhat.com> In-Reply-To: <54F588D7.6060804@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::234 Subject: Re: [Qemu-devel] [Bug ?]Qemu segfault because of non-initial kvm_state variable 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 On 03/03/2015 11:11, Paolo Bonzini wrote: > > > On 03/03/2015 09:01, Gonglei (Arei) wrote: >> Hi, >> >> I encountered a Qemu segfault problem in my environment. >> >> # ./qemu-system-x86_64 -enable-kvm -m 4096 -smp 4 -name redhat6.2 -drive file=/home/win2008_ent_r2_64_01,\ >> if=none,id=drive-ide0-0-0 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -vnc :10 >> Segmentation fault ... and here's the right fix: ------------------- 8< --------------------------- From: Paolo Bonzini Subject: [PATCH] vl: take iothread lock very early If the iothread lock isn't taken by the main thread, the RCU callbacks might run concurrently with the main thread. QEMU's not ready for that. Signed-off-by: Paolo Bonzini diff --git a/vl.c b/vl.c index 09693f5..d743727 100644 --- a/vl.c +++ b/vl.c @@ -2763,6 +2763,9 @@ int main(int argc, char **argv, char **envp) FILE *vmstate_dump_file = NULL; Error *main_loop_err = NULL; + qemu_init_cpu_loop(); + qemu_mutex_lock_iothread(); + atexit(qemu_run_exit_notifiers); error_set_progname(argv[0]); qemu_init_exec_dir(argv[0]); @@ -4098,9 +4101,6 @@ int main(int argc, char **argv, char **envp) os_set_line_buffering(); - qemu_init_cpu_loop(); - qemu_mutex_lock_iothread(); - #ifdef CONFIG_SPICE /* spice needs the timers to be initialized by this point */ qemu_spice_init();