[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL v2 12/34] osdep: Introduce qemu_dup
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL v2 12/34] osdep: Introduce qemu_dup |
Date: |
Wed, 13 Jul 2016 14:50:19 +0200 |
From: Fam Zheng <address@hidden>
And use it in qemu_dup_flags.
Signed-off-by: Fam Zheng <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: John Snow <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
include/qemu/osdep.h | 3 +++
util/osdep.c | 23 +++++++++++++++--------
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index e63da28..7361006 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -278,6 +278,9 @@ int qemu_madvise(void *addr, size_t len, int advice);
int qemu_open(const char *name, int flags, ...);
int qemu_close(int fd);
+#ifndef _WIN32
+int qemu_dup(int fd);
+#endif
#if defined(__HAIKU__) && defined(__i386__)
#define FMT_pid "%ld"
diff --git a/util/osdep.c b/util/osdep.c
index ff004e8..06fb1cf 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -83,14 +83,7 @@ static int qemu_dup_flags(int fd, int flags)
int serrno;
int dup_flags;
-#ifdef F_DUPFD_CLOEXEC
- ret = fcntl(fd, F_DUPFD_CLOEXEC, 0);
-#else
- ret = dup(fd);
- if (ret != -1) {
- qemu_set_cloexec(ret);
- }
-#endif
+ ret = qemu_dup(fd);
if (ret == -1) {
goto fail;
}
@@ -129,6 +122,20 @@ fail:
return -1;
}
+int qemu_dup(int fd)
+{
+ int ret;
+#ifdef F_DUPFD_CLOEXEC
+ ret = fcntl(fd, F_DUPFD_CLOEXEC, 0);
+#else
+ ret = dup(fd);
+ if (ret != -1) {
+ qemu_set_cloexec(ret);
+ }
+#endif
+ return ret;
+}
+
static int qemu_parse_fdset(const char *param)
{
return qemu_parse_fd(param);
--
1.8.3.1
- [Qemu-block] [PULL v2 06/34] mirror: Add 'job-id' parameter to 'blockdev-mirror' and 'drive-mirror', (continued)
- [Qemu-block] [PULL v2 06/34] mirror: Add 'job-id' parameter to 'blockdev-mirror' and 'drive-mirror', Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 07/34] backup: Add 'job-id' parameter to 'blockdev-backup' and 'drive-backup', Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 08/34] stream: Add 'job-id' parameter to 'block-stream', Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 05/34] blockjob: Add 'job_id' parameter to block_job_create(), Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 10/34] qemu-img: Set the ID of the block job in img_commit(), Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 09/34] commit: Add 'job-id' parameter to 'block-commit', Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 11/34] blockjob: Update description of the 'device' field in the QMP API, Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 13/34] raw-posix: Use qemu_dup, Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 15/34] test-coroutine: prepare for the next patch, Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 12/34] osdep: Introduce qemu_dup,
Kevin Wolf <=
- [Qemu-block] [PULL v2 18/34] block/qdev: Allow configuring WCE with qdev properties, Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 17/34] block/qdev: Allow node name for drive properties, Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 19/34] commit: Fix use of error handling policy, Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 14/34] coroutine: use QSIMPLEQ instead of QTAILQ, Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 22/34] block: Remove BB options from blockdev-add, Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 16/34] coroutine: move entry argument to qemu_coroutine_create, Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 24/34] qcow2: Avoid making the L1 table too big, Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 20/34] block/qdev: Allow configuring rerror/werror with qdev properties, Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 21/34] qemu-iotests: Test setting WCE with qdev, Kevin Wolf, 2016/07/13
- [Qemu-block] [PULL v2 23/34] qemu-img: Use strerror() for generic resize error, Kevin Wolf, 2016/07/13