All of lore.kernel.org
 help / color / mirror / Atom feed
* [Virtio-fs] [PATCH] virtiofsd: Prevent multiply running with same vhost_user_socket
@ 2019-08-01 15:13 Masayoshi Mizuma
  2019-08-02 15:39 ` Stefan Hajnoczi
  0 siblings, 1 reply; 6+ messages in thread
From: Masayoshi Mizuma @ 2019-08-01 15:13 UTC (permalink / raw)
  To: virtio-fs; +Cc: Masayoshi Mizuma

From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>

virtiofsd can run multiply even if the vhost_user_socket is
same path.

  ]# ./virtiofsd -o vhost_user_socket=/tmp/vhostqemu -o source=/tmp/share &
  [1] 244965
  virtio_session_mount: Waiting for vhost-user socket connection...
  ]# ./virtiofsd -o vhost_user_socket=/tmp/vhostqemu -o source=/tmp/share &
  [2] 244966
  virtio_session_mount: Waiting for vhost-user socket connection...
  ]#

The file access from the guest works because the second virtiofsd
handles that, however, the user will get confused the situation
and may be the cause of unexpected problem. So it's better to
prevent the multiple running.

Change unlink() of the socket to the exit of virtiofsd so that the
latter virtiofsd can fail on bind() as EADDRINUSE.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
---
 contrib/virtiofsd/fuse_lowlevel.c | 1 +
 contrib/virtiofsd/fuse_virtio.c   | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/virtiofsd/fuse_lowlevel.c b/contrib/virtiofsd/fuse_lowlevel.c
index 8adc4b1ab8..0624d26ffc 100644
--- a/contrib/virtiofsd/fuse_lowlevel.c
+++ b/contrib/virtiofsd/fuse_lowlevel.c
@@ -2584,6 +2584,7 @@ void fuse_session_destroy(struct fuse_session *se)
 		virtio_session_close(se);
 	}
 
+	unlink(se->vu_socket_path);
 	free(se->vu_socket_path);
 	se->vu_socket_path = NULL;
 
diff --git a/contrib/virtiofsd/fuse_virtio.c b/contrib/virtiofsd/fuse_virtio.c
index 083e4fc317..54ba7cbbcb 100644
--- a/contrib/virtiofsd/fuse_virtio.c
+++ b/contrib/virtiofsd/fuse_virtio.c
@@ -879,7 +879,6 @@ static int fv_create_listen_socket(struct fuse_session *se)
         /* Create the Unix socket to communicate with qemu
          * based on QEMU's vhost-user-bridge
          */
-        unlink(se->vu_socket_path);
         strcpy(un.sun_path, se->vu_socket_path);
         size_t addr_len = sizeof(un.sun_family) + strlen(se->vu_socket_path);
 
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-08-06  2:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-01 15:13 [Virtio-fs] [PATCH] virtiofsd: Prevent multiply running with same vhost_user_socket Masayoshi Mizuma
2019-08-02 15:39 ` Stefan Hajnoczi
2019-08-02 16:22   ` Masayoshi Mizuma
2019-08-04  2:48     ` piaojun
2019-08-06  2:08       ` Masayoshi Mizuma
2019-08-06  2:11         ` piaojun

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.