All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org
Subject: [PATCH 4/4] qemu-kvm: move qemu_eventfd to osdep.c
Date: Thu, 11 Feb 2010 00:09:16 +0100	[thread overview]
Message-ID: <1265843356-25765-5-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1265843356-25765-1-git-send-email-pbonzini@redhat.com>

Upstream has no compatfd.[ch], so move the code to the most similar
place.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 compatfd.c    |   26 --------------------------
 compatfd.h    |    2 --
 osdep.c       |   32 ++++++++++++++++++++++++++++++++
 qemu-common.h |    1 +
 4 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/compatfd.c b/compatfd.c
index 4a00d95..a7cebc4 100644
--- a/compatfd.c
+++ b/compatfd.c
@@ -115,29 +115,3 @@ int qemu_signalfd(const sigset_t *mask)
 
     return qemu_signalfd_compat(mask);
 }
-
-int qemu_eventfd(int *fds)
-{
-    int ret;
-
-#if defined(CONFIG_EVENTFD)
-    ret = syscall(SYS_eventfd, 0);
-    if (ret >= 0) {
-        fds[0] = ret;
-        qemu_set_cloexec(ret);
-        if ((fds[1] = dup(ret)) == -1) {
-            close(ret);
-            return -1;
-        }
-        qemu_set_cloexec(fds[1]);
-        return 0;
-    }
-#endif
-
-    ret = pipe(fds);
-    if (ret != -1) {
-        qemu_set_cloexec(fds[0]);
-        qemu_set_cloexec(fds[1]);
-    }
-    return ret;
-}
diff --git a/compatfd.h b/compatfd.h
index 06b0b6b..fc37915 100644
--- a/compatfd.h
+++ b/compatfd.h
@@ -40,6 +40,4 @@ struct qemu_signalfd_siginfo {
 
 int qemu_signalfd(const sigset_t *mask);
 
-int qemu_eventfd(int *fds);
-
 #endif
diff --git a/osdep.c b/osdep.c
index 616e821..1b1e593 100644
--- a/osdep.c
+++ b/osdep.c
@@ -37,6 +37,10 @@
 #include <sys/statvfs.h>
 #endif
 
+#ifdef CONFIG_EVENTFD
+#include <sys/eventfd.h>
+#endif
+
 #ifdef _WIN32
 #include <windows.h>
 #elif defined(CONFIG_BSD)
@@ -285,6 +289,34 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count)
 
 #ifndef _WIN32
 /*
+ * Creates an eventfd that looks like a pipe and has EFD_CLOEXEC set.
+ */
+int qemu_eventfd(int fds[2])
+{
+    int ret;
+
+#ifdef CONFIG_EVENTFD
+    ret = eventfd(0, 0);
+    if (ret >= 0) {
+        fds[0] = ret;
+        qemu_set_cloexec(ret);
+        if ((fds[1] = dup(ret)) == -1) {
+            close(ret);
+            return -1;
+        }
+        qemu_set_cloexec(fds[1]);
+        return 0;
+    }
+
+    if (errno != ENOSYS) {
+        return -1;
+    }
+#endif
+
+    return qemu_pipe(fds);
+}
+
+/*
  * Creates a pipe with FD_CLOEXEC set on both file descriptors
  */
 int qemu_pipe(int pipefd[2])
diff --git a/qemu-common.h b/qemu-common.h
index bf14a22..f59d5f5 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -170,6 +170,7 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count)
 void qemu_set_cloexec(int fd);
 
 #ifndef _WIN32
+int qemu_eventfd(int pipefd[2]);
 int qemu_pipe(int pipefd[2]);
 #endif
 
-- 
1.6.6


WARNING: multiple messages have this Message-ID (diff)
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH 4/4] qemu-kvm: move qemu_eventfd to osdep.c
Date: Thu, 11 Feb 2010 00:09:16 +0100	[thread overview]
Message-ID: <1265843356-25765-5-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1265843356-25765-1-git-send-email-pbonzini@redhat.com>

Upstream has no compatfd.[ch], so move the code to the most similar
place.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 compatfd.c    |   26 --------------------------
 compatfd.h    |    2 --
 osdep.c       |   32 ++++++++++++++++++++++++++++++++
 qemu-common.h |    1 +
 4 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/compatfd.c b/compatfd.c
index 4a00d95..a7cebc4 100644
--- a/compatfd.c
+++ b/compatfd.c
@@ -115,29 +115,3 @@ int qemu_signalfd(const sigset_t *mask)
 
     return qemu_signalfd_compat(mask);
 }
-
-int qemu_eventfd(int *fds)
-{
-    int ret;
-
-#if defined(CONFIG_EVENTFD)
-    ret = syscall(SYS_eventfd, 0);
-    if (ret >= 0) {
-        fds[0] = ret;
-        qemu_set_cloexec(ret);
-        if ((fds[1] = dup(ret)) == -1) {
-            close(ret);
-            return -1;
-        }
-        qemu_set_cloexec(fds[1]);
-        return 0;
-    }
-#endif
-
-    ret = pipe(fds);
-    if (ret != -1) {
-        qemu_set_cloexec(fds[0]);
-        qemu_set_cloexec(fds[1]);
-    }
-    return ret;
-}
diff --git a/compatfd.h b/compatfd.h
index 06b0b6b..fc37915 100644
--- a/compatfd.h
+++ b/compatfd.h
@@ -40,6 +40,4 @@ struct qemu_signalfd_siginfo {
 
 int qemu_signalfd(const sigset_t *mask);
 
-int qemu_eventfd(int *fds);
-
 #endif
diff --git a/osdep.c b/osdep.c
index 616e821..1b1e593 100644
--- a/osdep.c
+++ b/osdep.c
@@ -37,6 +37,10 @@
 #include <sys/statvfs.h>
 #endif
 
+#ifdef CONFIG_EVENTFD
+#include <sys/eventfd.h>
+#endif
+
 #ifdef _WIN32
 #include <windows.h>
 #elif defined(CONFIG_BSD)
@@ -285,6 +289,34 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count)
 
 #ifndef _WIN32
 /*
+ * Creates an eventfd that looks like a pipe and has EFD_CLOEXEC set.
+ */
+int qemu_eventfd(int fds[2])
+{
+    int ret;
+
+#ifdef CONFIG_EVENTFD
+    ret = eventfd(0, 0);
+    if (ret >= 0) {
+        fds[0] = ret;
+        qemu_set_cloexec(ret);
+        if ((fds[1] = dup(ret)) == -1) {
+            close(ret);
+            return -1;
+        }
+        qemu_set_cloexec(fds[1]);
+        return 0;
+    }
+
+    if (errno != ENOSYS) {
+        return -1;
+    }
+#endif
+
+    return qemu_pipe(fds);
+}
+
+/*
  * Creates a pipe with FD_CLOEXEC set on both file descriptors
  */
 int qemu_pipe(int pipefd[2])
diff --git a/qemu-common.h b/qemu-common.h
index bf14a22..f59d5f5 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -170,6 +170,7 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count)
 void qemu_set_cloexec(int fd);
 
 #ifndef _WIN32
+int qemu_eventfd(int pipefd[2]);
 int qemu_pipe(int pipefd[2]);
 #endif
 
-- 
1.6.6

  parent reply	other threads:[~2010-02-10 23:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-10 23:09 [PATCH 0/4] qemu-kvm: prepare for adding eventfd usage to upstream Paolo Bonzini
2010-02-10 23:09 ` [Qemu-devel] " Paolo Bonzini
2010-02-10 23:09 ` [PATCH 1/4] qemu-kvm: morph qemu_kvm_notify_work into qemu.git's qemu_event_increment Paolo Bonzini
2010-02-10 23:09   ` [Qemu-devel] " Paolo Bonzini
2010-02-10 23:09 ` [PATCH 2/4] qemu-kvm: morph io_thread_wakeup into qemu.git's qemu_event_read Paolo Bonzini
2010-02-10 23:09   ` [Qemu-devel] " Paolo Bonzini
2010-02-10 23:09 ` [PATCH 3/4] qemu-kvm: fix placement of config-host.h inclusion Paolo Bonzini
2010-02-10 23:09   ` [Qemu-devel] " Paolo Bonzini
2010-02-10 23:09 ` Paolo Bonzini [this message]
2010-02-10 23:09   ` [Qemu-devel] [PATCH 4/4] qemu-kvm: move qemu_eventfd to osdep.c Paolo Bonzini
2010-02-13 13:26 ` [PATCH 0/4] qemu-kvm: prepare for adding eventfd usage to upstream Marcelo Tosatti
2010-02-13 13:26   ` [Qemu-devel] " Marcelo Tosatti
2010-02-14 12:32   ` Avi Kivity
2010-02-14 12:32     ` [Qemu-devel] " Avi Kivity
2010-02-17 12:53 ` Avi Kivity
2010-02-17 12:53   ` [Qemu-devel] " Avi Kivity

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=1265843356-25765-5-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.