From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KYnxM-0006zX-4V for qemu-devel@nongnu.org; Thu, 28 Aug 2008 16:19:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KYnxK-0006zJ-My for qemu-devel@nongnu.org; Thu, 28 Aug 2008 16:18:59 -0400 Received: from [199.232.76.173] (port=38069 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KYnxK-0006zG-Bt for qemu-devel@nongnu.org; Thu, 28 Aug 2008 16:18:58 -0400 Received: from an-out-0708.google.com ([209.85.132.250]:14099) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KYnxJ-0006Dc-Bp for qemu-devel@nongnu.org; Thu, 28 Aug 2008 16:18:58 -0400 Received: by an-out-0708.google.com with SMTP id d18so87545and.130 for ; Thu, 28 Aug 2008 13:18:55 -0700 (PDT) Message-ID: <48B707FF.3030600@codemonkey.ws> Date: Thu, 28 Aug 2008 15:18:07 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/2] Introduce #define QEMU_ASYNC_EVENTLOOP to simplify #ifdefs References: <69b245c5aebe9d170b7641a266d5700f9c9420c0.1219763627.git.Ian.Jackson@eu.citrix.com> <3a9dd4a19653dfe2f1c32f85482c06566a70eb32.1219763627.git.Ian.Jackson@eu.citrix.com> In-Reply-To: <3a9dd4a19653dfe2f1c32f85482c06566a70eb32.1219763627.git.Ian.Jackson@eu.citrix.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Laurent Vivier , ian.jackson@eu.citrix.com Ian Jackson wrote: > In various places we have > #if !defined(QEMU_IMG) && !defined(QEMU_NBD) > because those standalone tools do not have the whole qemu event loop > and asynchronous IO machinery. To reduce the number of places where > these facts are encoded, and to make it easier to introduce any new > helper program, we replace this with > #ifdef QEMU_ASYNC_EVENTLOOP > which is defined in qemu-common.h. > I don't understand why we need two defines in the first place. I noticed in the Makefile that we have rules to build qemu-nbd- objects and qemu-img- objects, but I don't see why that should be necessary. Regards, Anthony Liguori > Signed-off-by: Ian Jackson > --- > block-raw-posix.c | 14 +++++++------- > qemu-common.h | 5 +++++ > 2 files changed, 12 insertions(+), 7 deletions(-) > > diff --git a/block-raw-posix.c b/block-raw-posix.c > index 94928c0..ef1c993 100644 > --- a/block-raw-posix.c > +++ b/block-raw-posix.c > @@ -22,7 +22,7 @@ > * THE SOFTWARE. > */ > #include "qemu-common.h" > -#if !defined(QEMU_IMG) && !defined(QEMU_NBD) > +#ifdef QEMU_ASYNC_EVENTLOOP > #include "qemu-char.h" > #include "qemu_socket.h" > #include "qemu-timer.h" > @@ -447,7 +447,7 @@ static int aio_sig_pipe[2]; > > static void aio_signal_handler(int signum) > { > -#if !defined(QEMU_IMG) && !defined(QEMU_NBD) > +#ifdef QEMU_ASYNC_EVENTLOOP > int e; > e = errno; > write(aio_sig_pipe[1],"",1); /* ignore errors as they should be EAGAIN */ > @@ -465,7 +465,7 @@ static void aio_signal_handler(int signum) > #endif > } > > -#if !defined(QEMU_IMG) && !defined(QEMU_NBD) > +#ifdef QEMU_ASYNC_EVENTLOOP > static void qemu_aio_sig_pipe_read(void *opaque_ignored) { > qemu_aio_poll(); > } > @@ -481,7 +481,7 @@ void qemu_aio_init(void) > fcntl(aio_sig_pipe[0], F_SETFL, O_NONBLOCK); > fcntl(aio_sig_pipe[1], F_SETFL, O_NONBLOCK); > > -#if !defined(QEMU_IMG) && !defined(QEMU_NBD) > +#ifdef QEMU_ASYNC_EVENTLOOP > ret = qemu_set_fd_handler2(aio_sig_pipe[0], NULL, > qemu_aio_sig_pipe_read, NULL, NULL); > if (ret) { > @@ -581,7 +581,7 @@ void qemu_aio_wait(void) > { > fd_set check; > > -#if !defined(QEMU_IMG) && !defined(QEMU_NBD) > +#ifdef QEMU_ASYNC_EVENTLOOP > if (qemu_bh_poll()) > return; > #endif > @@ -622,7 +622,7 @@ static RawAIOCB *raw_aio_setup(BlockDriverState *bs, > return acb; > } > > -#if !defined(QEMU_IMG) && !defined(QEMU_NBD) > +#ifdef QEMU_ASYNC_EVENTLOOP > static void raw_aio_em_cb(void* opaque) > { > RawAIOCB *acb = opaque; > @@ -744,7 +744,7 @@ void qemu_aio_wait_start(void) > > void qemu_aio_wait(void) > { > -#if !defined(QEMU_IMG) && !defined(QEMU_NBD) > +#ifdef QEMU_ASYNC_EVENTLOOP > qemu_bh_poll(); > #endif > } > diff --git a/qemu-common.h b/qemu-common.h > index 23d1444..04c38fd 100644 > --- a/qemu-common.h > +++ b/qemu-common.h > @@ -49,6 +49,11 @@ static inline char *realpath(const char *path, char *resolved_path) > #define PRIo64 "I64o" > #endif > > +#if !defined(QEMU_IMG) && !defined(QEMU_NBD) > +# define QEMU_ASYNC_EVENTLOOP > + /* The standalone utilities do not use or support asynchronous IO */ > +#endif > + > /* FIXME: Remove NEED_CPU_H. */ > #ifndef NEED_CPU_H > >