From patchwork Wed Feb 10 23:09:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 78595 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1AN9gDk006142 for ; Wed, 10 Feb 2010 23:09:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756062Ab0BJXJd (ORCPT ); Wed, 10 Feb 2010 18:09:33 -0500 Received: from mail-fx0-f220.google.com ([209.85.220.220]:39277 "EHLO mail-fx0-f220.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755768Ab0BJXJc (ORCPT ); Wed, 10 Feb 2010 18:09:32 -0500 Received: by mail-fx0-f220.google.com with SMTP id 20so603555fxm.21 for ; Wed, 10 Feb 2010 15:09:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references; bh=X6jMRbunXYJrQVvEYhsVbbDgv2VoRK5oEXuNAnZveK8=; b=TyA5sm1Azva4rZHzwfhFObUICr26aG7oKp+Izr6kst2BjcyCXzHpA/EnFGjmYPjrMn 5NJ/IlVYFgcIzXCfIlYyznAib4bDln8Vmh5W7cE/FxwPPeoBk8PATF23LeT5Rx+jzH7s TFT7ska/5eWB/pnQWCiQVtx6sVHvh0vJPLJlc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=YMRyFKm3yMm8fn8fhKHiL6QKEZn8X1x38qTZ7joS0uux/VFT9yENvqKaCkY5cWg3TF nUgwcjff5WKwTuJLModKtrbGYOzUJ1R9BXYdy2EaFQRA5GddRDwn6Xvmyf6orEI2x8Eo Fln5UWpaPBVXwgZkdrvSyWABv/TdyUYhh80AE= Received: by 10.223.110.29 with SMTP id l29mr1142591fap.64.1265843370181; Wed, 10 Feb 2010 15:09:30 -0800 (PST) Received: from localhost.localdomain ([85.93.118.17]) by mx.google.com with ESMTPS id 18sm2839148fks.34.2010.02.10.15.09.29 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 10 Feb 2010 15:09:29 -0800 (PST) From: Paolo Bonzini 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 Message-Id: <1265843356-25765-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.6.6 In-Reply-To: <1265843356-25765-1-git-send-email-pbonzini@redhat.com> References: <1265843356-25765-1-git-send-email-pbonzini@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 10 Feb 2010 23:09:43 +0000 (UTC) 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