From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NfLge-0000IG-D3 for qemu-devel@nongnu.org; Wed, 10 Feb 2010 18:09:36 -0500 Received: from [199.232.76.173] (port=47490 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NfLgc-0000HW-Pg for qemu-devel@nongnu.org; Wed, 10 Feb 2010 18:09:34 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NfLgb-0002WP-W0 for qemu-devel@nongnu.org; Wed, 10 Feb 2010 18:09:34 -0500 Received: from mail-fx0-f223.google.com ([209.85.220.223]:38678) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NfLga-0002VG-BM for qemu-devel@nongnu.org; Wed, 10 Feb 2010 18:09:32 -0500 Received: by mail-fx0-f223.google.com with SMTP id 23so592387fxm.2 for ; Wed, 10 Feb 2010 15:09:31 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 11 Feb 2010 00:09:16 +0100 Message-Id: <1265843356-25765-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1265843356-25765-1-git-send-email-pbonzini@redhat.com> References: <1265843356-25765-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 4/4] qemu-kvm: move qemu_eventfd to osdep.c List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org Upstream has no compatfd.[ch], so move the code to the most similar place. Signed-off-by: Paolo Bonzini --- 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 #endif +#ifdef CONFIG_EVENTFD +#include +#endif + #ifdef _WIN32 #include #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