From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LuoZk-0007qV-7w for qemu-devel@nongnu.org; Fri, 17 Apr 2009 09:57:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LuoZf-0007pe-Hc for qemu-devel@nongnu.org; Fri, 17 Apr 2009 09:57:51 -0400 Received: from [199.232.76.173] (port=41029 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LuoZf-0007pb-Ch for qemu-devel@nongnu.org; Fri, 17 Apr 2009 09:57:47 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:54734) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LuoZe-0004bw-U3 for qemu-devel@nongnu.org; Fri, 17 Apr 2009 09:57:47 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e7.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n3HDlaNT001572 for ; Fri, 17 Apr 2009 09:47:36 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n3HDvjDR197666 for ; Fri, 17 Apr 2009 09:57:45 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n3HDvj2o020459 for ; Fri, 17 Apr 2009 09:57:45 -0400 Message-ID: <49E88AD7.4050007@us.ibm.com> Date: Fri, 17 Apr 2009 08:57:43 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <20090407195126.467365249@localhost.localdomain> <20090407195443.004166674@localhost.localdomain> In-Reply-To: <20090407195443.004166674@localhost.localdomain> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [patch 04/11] qemu: introduce main_loop_break Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mtosatti@redhat.com, "qemu-devel@nongnu.org" mtosatti@redhat.com wrote: > Use a pipe to signal pending work for the iothread. > > Signed-off-by: Marcelo Tosatti > > Index: trunk/qemu-common.h > =================================================================== > --- trunk.orig/qemu-common.h > +++ trunk/qemu-common.h > @@ -186,6 +186,8 @@ int cpu_load(QEMUFile *f, void *opaque, > /* Force QEMU to stop what it's doing and service IO */ > void qemu_service_io(void); > > +void main_loop_break(void); > + > /* Force QEMU to process pending events */ > void qemu_notify_event(void); > > Index: trunk/vl.c > =================================================================== > --- trunk.orig/vl.c > +++ trunk/vl.c > @@ -276,6 +276,8 @@ static QEMUTimer *nographic_timer; > > uint8_t qemu_uuid[16]; > > +static int io_thread_fd = -1; > + > /***********************************************************/ > /* x86 ISA bus support */ > > @@ -3632,6 +3634,55 @@ void qemu_notify_event(void) > } > } > > +void main_loop_break(void) > +{ > + uint64_t value = 1; > + char buffer[8]; > + size_t offset = 0; > + > + if (io_thread_fd == -1) > + return; > + > + memcpy(buffer, &value, sizeof(value)); > + > + while (offset < 8) { > + ssize_t len; > + > + len = write(io_thread_fd, buffer + offset, 8 - offset); > + if (len == -1 && errno == EINTR) > + continue; > + > + if (len <= 0) > + break; > + > + offset += len; > + } > + > + if (offset != 8) > + fprintf(stderr, "failed to notify io thread\n"); > +} > I'd like to see a higher level abstraction here. This is trying to be eventfd compatible which is great, but we should have something like: qemu_event_increment(); qemu_event_read(); It'll simplify this code a lot. We can also switch some of the other existing code to use this too later. Regards, Anthony Liguori