qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/2] Introduce #define QEMU_ASYNC_EVENTLOOP to s


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 2/2] Introduce #define QEMU_ASYNC_EVENTLOOP to simplify #ifdefs
Date: Thu, 28 Aug 2008 15:18:07 -0500
User-agent: Thunderbird 2.0.0.16 (X11/20080723)

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 <address@hidden>
---
 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]