oslib: qemu_clear_cloexec
PATCH v2 1/1 oslib: qemu_clear_cloexec
Define qemu_clear_cloexec, analogous to qemu_set_cloexec. This will be used to preserve selected descriptors during cpr.
Signed-off-by Steve Sistare <[email protected]>
Reviewed-by Dr. David Alan Gilbert <[email protected]>
Reviewed-by Marc-André Lureau <[email protected]>
--- include/qemu/osdep.h | 9 +++++++++ util/oslib-posix.c | 9 +++++++++ util/oslib-win32.c | 4 ++++ 3 files changed, 22 insertions(+)
include/qemu/osdep.h +9 -0
@@ -618,6 +618,15 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count)void qemu_set_cloexec (int fd); +/* +* Clear FD_CLOEXEC for a descriptor. +* +* The caller must guarantee that no other fork+exec's occur before the +* exec that is intended to inherit this descriptor, eg by suspending CPUs +* and blocking monitor commands. +*/ +void qemu_clear_cloexec (int fd); +/* Return a dynamically allocated directory path that is appropriate for storing * local state. *
util/oslib-posix.c +9 -0
@@ -273,6 +273,15 @@ int qemu_socketpair(int domain, int type, int protocol, int sv[2])return ret; } +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 ); +} +char *qemu_get_local_state_dir (void ) {
util/oslib-win32.c +4 -0
@@ -222,6 +222,10 @@ void qemu_set_cloexec(int fd) { } +void qemu_clear_cloexec (int fd) +{ +} +int qemu_get_thread_id (void ) {return GetCurrentThreadId ();
Signature · 1 line
1.8.3.1
Hi Paolo,
Can I get an RB from you on this patch, since you maintain posix?
This is needed for live update, to preserve vfio device descriptors and character device descriptors across the exec of the new qemu binary. If yes, I will rebase to the tip and repost a V3.
- Steve
Quoted 67 lines · Steve Sistare
Define
qemu_clear_cloexec, analogous toqemu_set_cloexec. This will be used to preserve selected descriptors during cpr.Signed-off-by Steve Sistare <[email protected]>Reviewed-by Dr. David Alan Gilbert <[email protected]>Reviewed-by Marc-André Lureau <[email protected]>--- include/qemu/osdep.h | 9 +++++++++ util/oslib-posix.c | 9 +++++++++ util/oslib-win32.c | 4 ++++ 3 files changed, 22 insertions(+)include/qemu/osdep.h +9
-0@@ -618,6 +618,15 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count)void qemu_set_cloexec (int fd); +/* +* Clear FD_CLOEXEC for a descriptor. +* +* The caller must guarantee that no other fork+exec's occur before the +* exec that is intended to inherit this descriptor, eg by suspending CPUs +* and blocking monitor commands. +*/ +void qemu_clear_cloexec (int fd); +/* Return a dynamically allocated directory path that is appropriate for storing * local state. * util/oslib-posix.c +9
-0@@ -273,6 +273,15 @@ int qemu_socketpair(int domain, int type, int protocol, int sv[2])return ret; } +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 ); +} +char *qemu_get_local_state_dir (void ) {util/oslib-win32.c +4
-0@@ -222,6 +222,10 @@ void qemu_set_cloexec(int fd) { } +void qemu_clear_cloexec (int fd) +{ +} +int qemu_get_thread_id (void ) {return GetCurrentThreadId ();