From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LhRNV-0008Pp-EE for qemu-devel@nongnu.org; Wed, 11 Mar 2009 12:33:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LhRNU-0008OA-Mq for qemu-devel@nongnu.org; Wed, 11 Mar 2009 12:33:56 -0400 Received: from [199.232.76.173] (port=46775 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LhRNU-0008Nm-7J for qemu-devel@nongnu.org; Wed, 11 Mar 2009 12:33:56 -0400 Received: from e2.ny.us.ibm.com ([32.97.182.142]:57602) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LhRNT-0005gI-UX for qemu-devel@nongnu.org; Wed, 11 Mar 2009 12:33:56 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e2.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n2BGVGbh025551 for ; Wed, 11 Mar 2009 12:31:16 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n2BGXqvM181578 for ; Wed, 11 Mar 2009 12:33:52 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n2BGXqUX020310 for ; Wed, 11 Mar 2009 12:33:52 -0400 Message-ID: <49B7E7EE.4020702@us.ibm.com> Date: Wed, 11 Mar 2009 11:33:50 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <20090311161645.344003675@localhost.localdomain> <20090311161942.482576079@localhost.localdomain> In-Reply-To: <20090311161942.482576079@localhost.localdomain> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [patch 1/2] qemu: sem/thread helpers Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcelo Tosatti Cc: qemu-devel@nongnu.org Marcelo Tosatti wrote: > Index: qemu/Makefile.target > =================================================================== > --- qemu.orig/Makefile.target > +++ qemu/Makefile.target > @@ -500,7 +500,7 @@ endif #CONFIG_BSD_USER > # System emulator target > ifndef CONFIG_USER_ONLY > > -OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o > +OBJS=vl.o qemu-thread.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o > # virtio has to be here due to weird dependency between PCI and virtio-net. > # need to fix this properly > OBJS+=virtio.o virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o > Index: qemu/vl.c > =================================================================== > --- qemu.orig/vl.c > +++ qemu/vl.c > @@ -36,6 +36,7 @@ > #include "gdbstub.h" > #include "qemu-timer.h" > #include "qemu-char.h" > +#include "qemu-thread.h" > #include "cache-utils.h" > #include "block.h" > #include "audio/audio.h" > @@ -263,6 +264,8 @@ static QEMUTimer *nographic_timer; > > uint8_t qemu_uuid[16]; > > +QemuSem qemu_sem; > + > /***********************************************************/ > /* x86 ISA bus support */ > > @@ -3650,7 +3653,10 @@ void main_loop_wait(int timeout) > slirp_select_fill(&nfds, &rfds, &wfds, &xfds); > } > #endif > + > + qemu_sem_unlock(&qemu_sem); > ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv); > + qemu_sem_lock(&qemu_sem); > I've looked at this a number of times, so I feel comfortable with this, but I think it's subtle enough that it deserves a comment. main_loop_wait() *must* not assume any global state is consistent across select() invocations. We should make that very clear as it's a detail that can be easily missed. Regards, Anthony Liguori