diff mbox series

[2/2] vhost-user: Call qemu_socketpair() instead of socketpair()

Message ID 3e370aa5326809d63f7eef573be558da987d27f5.1660303075.git.tugy@chinatelecom.cn
State New
Headers show
Series introduce qemu_socketpiar() | expand

Commit Message

Guoyi Tu Aug. 12, 2022, 11:44 a.m. UTC
From: Guoyi Tu <tugy@chinatelecom.cn>

set close-on-exec flag on the new opened file descriptors at default

Signed-off-by: Guoyi Tu <tugy@chinatelecom.cn>
---
 hw/display/vhost-user-gpu.c | 3 ++-
 hw/virtio/vhost-user.c      | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Peter Maydell Aug. 12, 2022, 11:50 a.m. UTC | #1
On Fri, 12 Aug 2022 at 12:44, <tugy@chinatelecom.cn> wrote:
>
> From: Guoyi Tu <tugy@chinatelecom.cn>
>
> set close-on-exec flag on the new opened file descriptors at default

What goes wrong if we don't do this? The commit message
is a good place to explain what bug the commit is fixing,
and its consequences.

thanks
-- PMM
Guoyi Tu Aug. 18, 2022, 11:51 a.m. UTC | #2
On 8/12/22 19:50, Peter Maydell wrote:
> On Fri, 12 Aug 2022 at 12:44, <tugy@chinatelecom.cn> wrote:
>>
>> From: Guoyi Tu <tugy@chinatelecom.cn>
>>
>> set close-on-exec flag on the new opened file descriptors at default
> 
> What goes wrong if we don't do this? The commit message
> is a good place to explain what bug the commit is fixing,
> and its consequences.
> 
> thanks
> -- PMM
> 
OK, will do and send another version

Thanks.
diff mbox series

Patch

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 75b8df21a4..4d2b227028 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;