public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] Add support for eventfd() (v3)
@ 2008-05-07 16:55 Anthony Liguori
  2008-05-07 16:55 ` [PATCH 2/6] Replace SIGUSR1 in io-thread with " Anthony Liguori
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Anthony Liguori @ 2008-05-07 16:55 UTC (permalink / raw)
  To: kvm-devel; +Cc: Anthony Liguori, Marcelo Tosatti, Avi Kivity

This patch adds compatibility code so that we can make use of eventfd() within
QEMU.  eventfd() is a pretty useful mechanism as it allows multiple
notifications to be batched in a single system call.

We emulate eventfd() using a standard pipe().

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

diff --git a/qemu/Makefile.target b/qemu/Makefile.target
index bb4b9a3..46654f3 100644
--- a/qemu/Makefile.target
+++ b/qemu/Makefile.target
@@ -208,7 +208,7 @@ CPPFLAGS+=-I$(SRC_PATH)/tcg/sparc
 endif
 
 ifeq ($(USE_KVM), 1)
-LIBOBJS+=qemu-kvm.o
+LIBOBJS+=qemu-kvm.o kvm-compatfd.o
 endif
 ifdef CONFIG_SOFTFLOAT
 LIBOBJS+=fpu/softfloat.o
diff --git a/qemu/kvm-compatfd.c b/qemu/kvm-compatfd.c
new file mode 100644
index 0000000..1b030ba
--- /dev/null
+++ b/qemu/kvm-compatfd.c
@@ -0,0 +1,33 @@
+/*
+ * signalfd/eventfd compatibility
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <aliguori@us.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu-common.h"
+#include "qemu-kvm.h"
+
+#include <sys/syscall.h>
+
+int kvm_eventfd(int *fds)
+{
+#if defined(SYS_eventfd)
+    int ret;
+
+    ret = syscall(SYS_eventfd, 0);
+    if (ret >= 0) {
+	fds[0] = fds[1] = ret;
+	return 0;
+    } else if (!(ret == -1 && errno == ENOSYS))
+	return ret;
+#endif
+
+    return pipe(fds);
+}
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
index 024a653..8fa3c1b 100644
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -79,6 +79,8 @@ int handle_powerpc_dcr_read(int vcpu, uint32_t dcrn, uint32_t *data);
 int handle_powerpc_dcr_write(int vcpu,uint32_t dcrn, uint32_t data);
 #endif
 
+int kvm_eventfd(int *fds);
+
 #define ALIGN(x, y)  (((x)+(y)-1) & ~((y)-1))
 #define BITMAP_SIZE(m) (ALIGN(((m)>>TARGET_PAGE_BITS), HOST_LONG_BITS) / 8)
 

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

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

end of thread, other threads:[~2008-05-08 17:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-07 16:55 [PATCH 1/6] Add support for eventfd() (v3) Anthony Liguori
2008-05-07 16:55 ` [PATCH 2/6] Replace SIGUSR1 in io-thread with " Anthony Liguori
2008-05-07 16:55 ` [PATCH 3/6] Add support for signalfd() (v3) Anthony Liguori
2008-05-07 16:55 ` [PATCH 4/6] Use signalfd() in io-thread (v3) Anthony Liguori
2008-05-07 16:55 ` [PATCH 5/6] Interrupt io thread in qemu_set_fd_handler2 (v3) Anthony Liguori
2008-05-07 16:55 ` [PATCH 6/6] Only select once per-main_loop iteration (v3) Anthony Liguori
2008-05-08 17:16 ` [PATCH 1/6] Add support for eventfd() (v3) Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox