[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V3 03/22] oslib: qemu_clr_cloexec
From: |
Steve Sistare |
Subject: |
[PATCH V3 03/22] oslib: qemu_clr_cloexec |
Date: |
Fri, 7 May 2021 05:25:01 -0700 |
Define qemu_clr_cloexec, analogous to qemu_set_cloexec.
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
include/qemu/osdep.h | 1 +
util/oslib-posix.c | 9 +++++++++
util/oslib-win32.c | 4 ++++
3 files changed, 14 insertions(+)
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index cb2a07e..de06e60 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -577,6 +577,7 @@ static inline void qemu_timersub(const struct timeval *val1,
#endif
void qemu_set_cloexec(int fd);
+void qemu_clr_cloexec(int fd);
/* Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
* instead of QEMU_VERSION, so setting hw_version on MachineClass
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 36820fe..ac9229d 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -317,6 +317,15 @@ void qemu_set_cloexec(int fd)
assert(f != -1);
}
+void qemu_clr_cloexec(int fd)
+{
+ int f;
+ f = fcntl(fd, F_GETFD);
+ assert(f != -1);
+ f = fcntl(fd, F_SETFD, f & ~FD_CLOEXEC);
+ assert(f != -1);
+}
+
/*
* Creates a pipe with FD_CLOEXEC set on both file descriptors
*/
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index f68b801..b5c53b3 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -251,6 +251,10 @@ void qemu_set_cloexec(int fd)
{
}
+void qemu_clr_cloexec(int fd)
+{
+}
+
/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
#define _W32_FT_OFFSET (116444736000000000ULL)
--
1.8.3.1
- [PATCH V3 00/22] Live Update, Steve Sistare, 2021/05/07
- [PATCH V3 03/22] oslib: qemu_clr_cloexec,
Steve Sistare <=
- [PATCH V3 05/22] machine: memfd-alloc option, Steve Sistare, 2021/05/07
- [PATCH V3 01/22] as_flat_walk, Steve Sistare, 2021/05/07
- [PATCH V3 02/22] qemu_ram_volatile, Steve Sistare, 2021/05/07
- [PATCH V3 07/22] cpr, Steve Sistare, 2021/05/07
[PATCH V3 11/22] vfio-pci: refactor for cpr, Steve Sistare, 2021/05/07