qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <Laurent.Vivier@bull.net>, ian.jackson@eu.citrix.com
Subject: Re: [Qemu-devel] [PATCH 2/2] Introduce #define QEMU_ASYNC_EVENTLOOP to simplify #ifdefs
Date: Thu, 28 Aug 2008 15:18:07 -0500	[thread overview]
Message-ID: <48B707FF.3030600@codemonkey.ws> (raw)
In-Reply-To: <3a9dd4a19653dfe2f1c32f85482c06566a70eb32.1219763627.git.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 <Ian.Jackson@eu.citrix.com>
> ---
>  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	other threads:[~2008-08-28 20:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-26 14:21 [Qemu-devel] [PATCH 1/2] Use fd signal trick to break us out of select; do not sigwait Ian Jackson
2008-08-26 14:42 ` [Qemu-devel] [PATCH 2/2] Introduce #define QEMU_ASYNC_EVENTLOOP to simplify #ifdefs Ian Jackson
2008-08-28 20:18   ` Anthony Liguori [this message]
2008-08-29  9:31     ` Ian Jackson
2008-09-07  2:45       ` Anthony Liguori
2008-08-28 20:16 ` [Qemu-devel] [PATCH 1/2] Use fd signal trick to break us out of select; do not sigwait Anthony Liguori
2008-08-29  9:25   ` Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48B707FF.3030600@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=Laurent.Vivier@bull.net \
    --cc=ian.jackson@eu.citrix.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).