From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] Don't race while creating a VCPU Date: Wed, 30 Apr 2008 02:29:56 +0300 Message-ID: <4817AF74.9030504@qumranet.com> References: <1209421836-21074-1-git-send-email-aliguori@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel@lists.sourceforge.net To: Anthony Liguori Return-path: In-Reply-To: <1209421836-21074-1-git-send-email-aliguori@us.ibm.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org Anthony Liguori wrote: > We hold qemu_mutex while machine->init() executes, which issues a VCPU create. > We need to make sure to not return from the VCPU creation until the VCPU > file descriptor is valid to ensure that APIC creation succeeds. > > However, we also need to make sure that the VCPU thread doesn't start running > until the machine->init() is complete. This is addressed today because the > VCPU thread tries to grab the qemu_mutex before doing anything interesting. > If we release qemu_mutex to wait for VCPU creation, then we open a window for > a race to occur. > > This patch introduces two wait conditions. The first lets the VCPU create > code that runs in the IO thread to wait for a VCPU to initialize. The second > condition lets the VCPU thread wait for the machine to fully initialize before > running. > > Applied, thanks. > An added benefit of this patch is it makes the dependencies now explicit. > > Indeed. -- Any sufficiently difficult bug is indistinguishable from a feature. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone