qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCHv2] Add compat eventfd header
@ 2011-06-30 15:57 Michael S. Tsirkin
  2011-06-30 15:58 ` Paolo Bonzini
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2011-06-30 15:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Blue Swirl, Paolo Bonzini, Stefan Hajnoczi, Aurelien Jarno,
	Alexander Graf

Support build on rhel 5.X where we have syscall for eventfd but not
userspace wrapper.

(cherry-picked from commit 9e3269181e9bc56feb43bcd4e8ce0b82cd543e65
 in qemu-kvm.git).

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

Changes from v1:
  checkpatch fix
  address comments by agraf
  verify we are on linux

 compat/sys/eventfd.h |   20 ++++++++++++++++++++
 configure            |    6 ++++--
 2 files changed, 24 insertions(+), 2 deletions(-)
 create mode 100644 compat/sys/eventfd.h

diff --git a/compat/sys/eventfd.h b/compat/sys/eventfd.h
new file mode 100644
index 0000000..1801a5f
--- /dev/null
+++ b/compat/sys/eventfd.h
@@ -0,0 +1,20 @@
+#ifndef _COMPAT_SYS_EVENTFD
+#define _COMPAT_SYS_EVENTFD
+
+#ifdef CONFIG_EVENTFD
+
+#ifndef __linux__
+#error __linux__ is not defined: eventfd is only supported on linux
+#endif
+
+#include <unistd.h>
+#include <syscall.h>
+
+static inline int eventfd(int count, int flags)
+{
+    return syscall(SYS_eventfd, count, flags);
+}
+
+#endif
+
+#endif
diff --git a/configure b/configure
index 856b41e..6f7dd74 100755
--- a/configure
+++ b/configure
@@ -822,7 +822,6 @@ esac
 
 [ -z "$guest_base" ] && guest_base="$host_guest_base"
 
-
 default_target_list=""
 
 # these targets are portable
@@ -891,6 +890,9 @@ sparc64-bsd-user \
 "
 fi
 
+#compat headers
+QEMU_CFLAGS="$QEMU_CFLAGS -idirafter $source_path/compat"
+
 if test x"$show_help" = x"yes" ; then
 cat << EOF
 
@@ -2122,7 +2124,7 @@ int main(void)
     return 0;
 }
 EOF
-if compile_prog "" "" ; then
+if compile_prog "-DCONFIG_EVENTFD" "" ; then
   eventfd=yes
 fi
 
-- 
1.7.5.53.gc233e

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCHv2] Add compat eventfd header
  2011-06-30 15:57 [Qemu-devel] [PATCHv2] Add compat eventfd header Michael S. Tsirkin
@ 2011-06-30 15:58 ` Paolo Bonzini
  2011-06-30 17:27 ` Peter Maydell
  2011-07-01 20:05 ` Blue Swirl
  2 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2011-06-30 15:58 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Blue Swirl, Alexander Graf, qemu-devel, Aurelien Jarno,
	Stefan Hajnoczi

On 06/30/2011 05:57 PM, Michael S. Tsirkin wrote:
> Support build on rhel 5.X where we have syscall for eventfd but not
> userspace wrapper.
>
> (cherry-picked from commit 9e3269181e9bc56feb43bcd4e8ce0b82cd543e65
>   in qemu-kvm.git).
>
> Signed-off-by: Michael S. Tsirkin<mst@redhat.com>
> ---
>
> Changes from v1:
>    checkpatch fix
>    address comments by agraf
>    verify we are on linux
>
>   compat/sys/eventfd.h |   20 ++++++++++++++++++++
>   configure            |    6 ++++--
>   2 files changed, 24 insertions(+), 2 deletions(-)
>   create mode 100644 compat/sys/eventfd.h
>
> diff --git a/compat/sys/eventfd.h b/compat/sys/eventfd.h
> new file mode 100644
> index 0000000..1801a5f
> --- /dev/null
> +++ b/compat/sys/eventfd.h
> @@ -0,0 +1,20 @@
> +#ifndef _COMPAT_SYS_EVENTFD
> +#define _COMPAT_SYS_EVENTFD
> +
> +#ifdef CONFIG_EVENTFD
> +
> +#ifndef __linux__
> +#error __linux__ is not defined: eventfd is only supported on linux
> +#endif
> +
> +#include<unistd.h>
> +#include<syscall.h>
> +
> +static inline int eventfd(int count, int flags)
> +{
> +    return syscall(SYS_eventfd, count, flags);
> +}
> +
> +#endif
> +
> +#endif
> diff --git a/configure b/configure
> index 856b41e..6f7dd74 100755
> --- a/configure
> +++ b/configure
> @@ -822,7 +822,6 @@ esac
>
>   [ -z "$guest_base" ]&&  guest_base="$host_guest_base"
>
> -
>   default_target_list=""
>
>   # these targets are portable
> @@ -891,6 +890,9 @@ sparc64-bsd-user \
>   "
>   fi
>
> +#compat headers
> +QEMU_CFLAGS="$QEMU_CFLAGS -idirafter $source_path/compat"
> +
>   if test x"$show_help" = x"yes" ; then
>   cat<<  EOF
>
> @@ -2122,7 +2124,7 @@ int main(void)
>       return 0;
>   }
>   EOF
> -if compile_prog "" "" ; then
> +if compile_prog "-DCONFIG_EVENTFD" "" ; then
>     eventfd=yes
>   fi
>

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCHv2] Add compat eventfd header
  2011-06-30 15:57 [Qemu-devel] [PATCHv2] Add compat eventfd header Michael S. Tsirkin
  2011-06-30 15:58 ` Paolo Bonzini
@ 2011-06-30 17:27 ` Peter Maydell
  2011-06-30 17:54   ` Michael S. Tsirkin
  2011-07-01 20:05 ` Blue Swirl
  2 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2011-06-30 17:27 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Stefan Hajnoczi, Alexander Graf, qemu-devel, Blue Swirl,
	Paolo Bonzini, Aurelien Jarno

On 30 June 2011 16:57, Michael S. Tsirkin <mst@redhat.com> wrote:
> diff --git a/configure b/configure
> index 856b41e..6f7dd74 100755
> --- a/configure
> +++ b/configure
> @@ -822,7 +822,6 @@ esac
>
>  [ -z "$guest_base" ] && guest_base="$host_guest_base"
>
> -
>  default_target_list=""
>
>  # these targets are portable

This hunk looks like a stray unrelated whitespace change?

-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCHv2] Add compat eventfd header
  2011-06-30 17:27 ` Peter Maydell
@ 2011-06-30 17:54   ` Michael S. Tsirkin
  0 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2011-06-30 17:54 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Stefan Hajnoczi, Alexander Graf, qemu-devel, Blue Swirl,
	Paolo Bonzini, Aurelien Jarno

On Thu, Jun 30, 2011 at 06:27:13PM +0100, Peter Maydell wrote:
> On 30 June 2011 16:57, Michael S. Tsirkin <mst@redhat.com> wrote:
> > diff --git a/configure b/configure
> > index 856b41e..6f7dd74 100755
> > --- a/configure
> > +++ b/configure
> > @@ -822,7 +822,6 @@ esac
> >
> >  [ -z "$guest_base" ] && guest_base="$host_guest_base"
> >
> > -
> >  default_target_list=""
> >
> >  # these targets are portable
> 
> This hunk looks like a stray unrelated whitespace change?
> 
> -- PMM

It's unrelated but I don't believe it's stray.
Seems too trivial to split this to a separate patch.

-- 
MST

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCHv2] Add compat eventfd header
  2011-06-30 15:57 [Qemu-devel] [PATCHv2] Add compat eventfd header Michael S. Tsirkin
  2011-06-30 15:58 ` Paolo Bonzini
  2011-06-30 17:27 ` Peter Maydell
@ 2011-07-01 20:05 ` Blue Swirl
  2011-07-03  8:17   ` Michael S. Tsirkin
  2 siblings, 1 reply; 6+ messages in thread
From: Blue Swirl @ 2011-07-01 20:05 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Paolo Bonzini, Alexander Graf, qemu-devel, Aurelien Jarno,
	Stefan Hajnoczi

On Thu, Jun 30, 2011 at 6:57 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> Support build on rhel 5.X where we have syscall for eventfd but not
> userspace wrapper.
>
> (cherry-picked from commit 9e3269181e9bc56feb43bcd4e8ce0b82cd543e65
>  in qemu-kvm.git).
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> Changes from v1:
>  checkpatch fix
>  address comments by agraf
>  verify we are on linux
>
>  compat/sys/eventfd.h |   20 ++++++++++++++++++++
>  configure            |    6 ++++--
>  2 files changed, 24 insertions(+), 2 deletions(-)
>  create mode 100644 compat/sys/eventfd.h
>
> diff --git a/compat/sys/eventfd.h b/compat/sys/eventfd.h
> new file mode 100644
> index 0000000..1801a5f
> --- /dev/null
> +++ b/compat/sys/eventfd.h

Since we have linux-headers directory now, the directory should be
compat-headers. I'd also add 'linux' directory below that to avoid
collisions, so the full path would be
compat-headers/linux/sys/eventfd.h.

> @@ -0,0 +1,20 @@
> +#ifndef _COMPAT_SYS_EVENTFD
> +#define _COMPAT_SYS_EVENTFD
> +
> +#ifdef CONFIG_EVENTFD
> +
> +#ifndef __linux__
> +#error __linux__ is not defined: eventfd is only supported on linux
> +#endif

With the linux directory, this check wouldn't be needed. It's not
incorrect and we could add more specific checks later (for example if
SYS_eventfd is not defined).

> +
> +#include <unistd.h>
> +#include <syscall.h>
> +
> +static inline int eventfd(int count, int flags)
> +{
> +    return syscall(SYS_eventfd, count, flags);
> +}
> +
> +#endif
> +
> +#endif
> diff --git a/configure b/configure
> index 856b41e..6f7dd74 100755
> --- a/configure
> +++ b/configure
> @@ -822,7 +822,6 @@ esac
>
>  [ -z "$guest_base" ] && guest_base="$host_guest_base"
>
> -
>  default_target_list=""
>
>  # these targets are portable
> @@ -891,6 +890,9 @@ sparc64-bsd-user \
>  "
>  fi
>
> +#compat headers
> +QEMU_CFLAGS="$QEMU_CFLAGS -idirafter $source_path/compat"

Please use $source_path/compat-headers/$targetos/.

> +
>  if test x"$show_help" = x"yes" ; then
>  cat << EOF
>
> @@ -2122,7 +2124,7 @@ int main(void)
>     return 0;
>  }
>  EOF
> -if compile_prog "" "" ; then
> +if compile_prog "-DCONFIG_EVENTFD" "" ; then
>   eventfd=yes
>  fi
>
> --
> 1.7.5.53.gc233e
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCHv2] Add compat eventfd header
  2011-07-01 20:05 ` Blue Swirl
@ 2011-07-03  8:17   ` Michael S. Tsirkin
  0 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2011-07-03  8:17 UTC (permalink / raw)
  To: Blue Swirl
  Cc: Paolo Bonzini, Alexander Graf, qemu-devel, Aurelien Jarno,
	Stefan Hajnoczi

On Fri, Jul 01, 2011 at 11:05:28PM +0300, Blue Swirl wrote:
> On Thu, Jun 30, 2011 at 6:57 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> > Support build on rhel 5.X where we have syscall for eventfd but not
> > userspace wrapper.
> >
> > (cherry-picked from commit 9e3269181e9bc56feb43bcd4e8ce0b82cd543e65
> >  in qemu-kvm.git).
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >
> > Changes from v1:
> >  checkpatch fix
> >  address comments by agraf
> >  verify we are on linux
> >
> >  compat/sys/eventfd.h |   20 ++++++++++++++++++++
> >  configure            |    6 ++++--
> >  2 files changed, 24 insertions(+), 2 deletions(-)
> >  create mode 100644 compat/sys/eventfd.h
> >
> > diff --git a/compat/sys/eventfd.h b/compat/sys/eventfd.h
> > new file mode 100644
> > index 0000000..1801a5f
> > --- /dev/null
> > +++ b/compat/sys/eventfd.h
> 
> Since we have linux-headers directory now, the directory should be
> compat-headers. I'd also add 'linux' directory below that to avoid
> collisions, so the full path would be
> compat-headers/linux/sys/eventfd.h.
> 

I'll make it compat-headers/sys/eventfd.h.

Actually this header is useful for non-linux as well:
CONFIG_EVENTFD is not defined there which in theory
makes it possible to include sys/eventfd.h
without ifdefs.

> > @@ -0,0 +1,20 @@
> > +#ifndef _COMPAT_SYS_EVENTFD
> > +#define _COMPAT_SYS_EVENTFD
> > +
> > +#ifdef CONFIG_EVENTFD
> > +
> > +#ifndef __linux__
> > +#error __linux__ is not defined: eventfd is only supported on linux
> > +#endif
> 
> With the linux directory, this check wouldn't be needed. It's not
> incorrect and we could add more specific checks later (for example if
> SYS_eventfd is not defined).

Yes, it's not incorrect because it is nested within CONFIG_EVENTFD.
If CONFIG_EVENTFD is set and SYS_eventfd is not defined then
there's a bug in the configure script.


> > +
> > +#include <unistd.h>
> > +#include <syscall.h>
> > +
> > +static inline int eventfd(int count, int flags)
> > +{
> > +    return syscall(SYS_eventfd, count, flags);
> > +}
> > +
> > +#endif
> > +
> > +#endif
> > diff --git a/configure b/configure
> > index 856b41e..6f7dd74 100755
> > --- a/configure
> > +++ b/configure
> > @@ -822,7 +822,6 @@ esac
> >
> >  [ -z "$guest_base" ] && guest_base="$host_guest_base"
> >
> > -
> >  default_target_list=""
> >
> >  # these targets are portable
> > @@ -891,6 +890,9 @@ sparc64-bsd-user \
> >  "
> >  fi
> >
> > +#compat headers
> > +QEMU_CFLAGS="$QEMU_CFLAGS -idirafter $source_path/compat"
> 
> Please use $source_path/compat-headers/$targetos/.

I think it's best to keep it simple. When we have many
compat headers we will see how to split them best.
If most of the code turns out to be common we will want to avoid
duplicating it.

> > +
> >  if test x"$show_help" = x"yes" ; then
> >  cat << EOF
> >
> > @@ -2122,7 +2124,7 @@ int main(void)
> >     return 0;
> >  }
> >  EOF
> > -if compile_prog "" "" ; then
> > +if compile_prog "-DCONFIG_EVENTFD" "" ; then
> >   eventfd=yes
> >  fi
> >
> > --
> > 1.7.5.53.gc233e
> >

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-03  8:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-30 15:57 [Qemu-devel] [PATCHv2] Add compat eventfd header Michael S. Tsirkin
2011-06-30 15:58 ` Paolo Bonzini
2011-06-30 17:27 ` Peter Maydell
2011-06-30 17:54   ` Michael S. Tsirkin
2011-07-01 20:05 ` Blue Swirl
2011-07-03  8:17   ` Michael S. Tsirkin

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).