Received: from eggs.gnu.org ([2001:4830:134:3::10]:55031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8kns-0006xi-Ak for qemu-devel@nongnu.org; Fri, 03 Jun 2016 04:50:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8knm-0001t7-9j for qemu-devel@nongnu.org; Fri, 03 Jun 2016 04:50:03 -0400 From: Fam Zheng Date: Fri, 3 Jun 2016 16:49:00 +0800 Message-Id: <1464943756-14143-7-git-send-email-famz@redhat.com> In-Reply-To: <1464943756-14143-1-git-send-email-famz@redhat.com> References: <1464943756-14143-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v6 06/22] osdep: Introduce qemu_dup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Max Reitz , Jeff Cody , Markus Armbruster , Eric Blake , qemu-block@nongnu.org, rjones@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, John Snow , berrange@redhat.com, den@openvz.org This takes care of both the CLOEXEC flag and fd-path mapping for image locking. Signed-off-by: Fam Zheng --- include/qemu/osdep.h | 3 +++ util/osdep.c | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 749214a..89c63c7 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -281,6 +281,9 @@ int qemu_madvise(void *addr, size_t len, int advice); int qemu_open(const char *name, int flags, ...); int qemu_close(int fd); int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive); +#ifndef _WIN32 +int qemu_dup(int fd); +#endif int qemu_unlock_fd(int fd, int64_t start, int64_t len); #if defined(__HAIKU__) && defined(__i386__) diff --git a/util/osdep.c b/util/osdep.c index 085ed52..1c87c1e 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -133,6 +133,15 @@ fail: return -1; } +int qemu_dup(int fd) +{ + int r = qemu_dup_flags(fd, 0); + if (r == -1) { + return -errno; + } + return r; +} + static int qemu_parse_fdset(const char *param) { return qemu_parse_fd(param); -- 2.8.2