[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V7 09/29] oslib: qemu_clear_cloexec
From: |
Steve Sistare |
Subject: |
[PATCH V7 09/29] oslib: qemu_clear_cloexec |
Date: |
Wed, 22 Dec 2021 11:05:14 -0800 |
Define qemu_clear_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 60718fc..1ad7714 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -637,6 +637,7 @@ static inline void qemu_timersub(const struct timeval *val1,
#endif
void qemu_set_cloexec(int fd);
+void qemu_clear_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 e8bdb02..7913334 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -309,6 +309,15 @@ void qemu_set_cloexec(int fd)
assert(f != -1);
}
+void qemu_clear_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 af559ef..acc3e06 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -265,6 +265,10 @@ void qemu_set_cloexec(int fd)
{
}
+void qemu_clear_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 V7 00/29] Live Update, Steve Sistare, 2021/12/22
- [PATCH V7 02/29] migration: fix populate_vfio_info, Steve Sistare, 2021/12/22
- [PATCH V7 06/29] cpr: reboot mode, Steve Sistare, 2021/12/22
- [PATCH V7 11/29] qapi: list utility functions, Steve Sistare, 2021/12/22
- [PATCH V7 09/29] oslib: qemu_clear_cloexec,
Steve Sistare <=
- [PATCH V7 12/29] vl: helper to request re-exec, Steve Sistare, 2021/12/22
- [PATCH V7 03/29] migration: qemu file wrappers, Steve Sistare, 2021/12/22
- [PATCH V7 07/29] cpr: reboot HMP interfaces, Steve Sistare, 2021/12/22
- [PATCH V7 05/29] vl: start on wakeup request, Steve Sistare, 2021/12/22
- [PATCH V7 01/29] memory: qemu_check_ram_volatile, Steve Sistare, 2021/12/22
- [PATCH V7 04/29] migration: simplify savevm, Steve Sistare, 2021/12/22
- [PATCH V7 13/29] cpr: preserve extra state, Steve Sistare, 2021/12/22
- [PATCH V7 15/29] cpr: restart HMP interfaces, Steve Sistare, 2021/12/22
- [PATCH V7 17/29] pci: export functions for cpr, Steve Sistare, 2021/12/22