[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 8/8] vhost-user: Call qemu_socketpair() instead of socketpair()
From: |
marcandre . lureau |
Subject: |
[PULL 8/8] vhost-user: Call qemu_socketpair() instead of socketpair() |
Date: |
Thu, 29 Sep 2022 15:05:08 +0400 |
From: Guoyi Tu <tugy@chinatelecom.cn>
As the close-on-exec flags is not set on the file descriptors returned
by socketpair() at default, the fds will survive across exec' function.
In the case that exec' function get invoked, such as the live-update feature
which is been developing, it will cause fd leaks.
To address this problem, we should call qemu_socketpair() to create an pair of
connected sockets with the close-on-exec flag set.
Signed-off-by: Guoyi Tu <tugy@chinatelecom.cn>
Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id:
<7002b12a5fb0a30cd878e14e07da61c36da72913.1661240709.git.tugy@chinatelecom.cn>
---
hw/display/vhost-user-gpu.c | 3 ++-
hw/virtio/vhost-user.c | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c
index 3340ef9e5f..19c0e20103 100644
--- a/hw/display/vhost-user-gpu.c
+++ b/hw/display/vhost-user-gpu.c
@@ -11,6 +11,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/sockets.h"
#include "hw/qdev-properties.h"
#include "hw/virtio/virtio-gpu.h"
#include "chardev/char-fe.h"
@@ -375,7 +376,7 @@ vhost_user_gpu_do_set_socket(VhostUserGPU *g, Error **errp)
Chardev *chr;
int sv[2];
- if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) {
+ if (qemu_socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) {
error_setg_errno(errp, errno, "socketpair() failed");
return false;
}
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index bd24741be8..70748e61e0 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1726,7 +1726,7 @@ static int vhost_setup_slave_channel(struct vhost_dev
*dev)
return 0;
}
- if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) {
+ if (qemu_socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) {
int saved_errno = errno;
error_report("socketpair() failed");
return -saved_errno;
--
2.37.3
- [PULL 0/8] chardev patches, marcandre . lureau, 2022/09/29
- [PULL 1/8] msmouse: Handle mouse reset, marcandre . lureau, 2022/09/29
- [PULL 2/8] chardev: src buffer const for write functions, marcandre . lureau, 2022/09/29
- [PULL 3/8] msmouse: Use fifo8 instead of array, marcandre . lureau, 2022/09/29
- [PULL 4/8] msmouse: Add pnp data, marcandre . lureau, 2022/09/29
- [PULL 6/8] chardev: fix segfault in finalize, marcandre . lureau, 2022/09/29
- [PULL 5/8] serial: Allow unaligned i/o access, marcandre . lureau, 2022/09/29
- [PULL 8/8] vhost-user: Call qemu_socketpair() instead of socketpair(),
marcandre . lureau <=
- [PULL 7/8] oslib-posix: Introduce qemu_socketpair(), marcandre . lureau, 2022/09/29