Re: [PATCH v2] net/9p: add vsock transport

Stefano Garzarella <[email protected]> Fri, 3 Jul 2026 11:12:39 +0200
Newsgroups dev.linux.lists.v9fs,org.kernel.vger.linux-kernel
Message-ID <akd7QliTAWpkmE0Q@sgarzare-redhat>
On Wed, Jul 01, 2026 at 05:59:22PM +0200, [email protected] wrote:
>From: Matus Skvarla <[email protected]>
>
>Add vsock as a transport option for 9P client connections. This
>allows mounting 9P filesystems over VM sockets without requiring TCP/IP
>networking or additional userspace tools.
>
>The implementation extends trans_fd.c with vsock support, reusing the
>existing socket infrastructure. A new p9_fd_create_vsock() function
>handles vsock connection setup by parsing the CID from the mount source,
>creating an AF_VSOCK socket, and connecting to the specified endpoint.
>All other transport operations (close, request, cancel) use the shared
>fd transport implementation.
>
>The privport mount option is not currently supported for vsock and
>returns -EOPNOTSUPP if specified.

Why not?

I'm no expert on 9p; it's just out of curiosity.

>
>Add CONFIG_NET_9P_VSOCK option that conditionally compiles vsock support
>into 9pnet_fd.ko. This follows the pattern where socket-based transports
>(TCP, Unix, vsock) share trans_fd.c, while specialized hardware transports
>(virtio, xen, rdma) have dedicated files.
>
>Usage:
>  mount -t 9p -o trans=vsock[,port=<port>] <CID> /mnt/point
>
>Signed-off-by: Matus Skvarla <[email protected]>
>---
>Changes in v2:
>  - Add depends on NET_9P_FD to Kconfig
>  - Use #include <uapi/linux/vm_sockets.h>
>  - Reject privport option with -EOPNOTSUPP
>  - Use fc->net_ns instead of current->nsproxy->net_ns
>  - Widen vsock port to u32 to match sockaddr_vm.svm_port
>  - Widen p9_fd_opts.port to u32 and port_str buffer accordingly (in p9_fd_create_tcp())
>  - Add vsock to Documentation/filesystems/9p.rst
>Link to v1: https://lore.kernel.org/v9fs/[email protected]/
>---
> Documentation/filesystems/9p.rst | 12 +++-
> include/net/9p/client.h          | 10 +++-
> net/9p/Kconfig                   | 10 ++++
> net/9p/trans_fd.c                | 97 +++++++++++++++++++++++++++++++-
> 4 files changed, 124 insertions(+), 5 deletions(-)
>
>diff --git a/Documentation/filesystems/9p.rst b/Documentation/filesystems/9p.rst
>index 3f65db648db0..d1bac30b3c9d 100644
>--- a/Documentation/filesystems/9p.rst
>+++ b/Documentation/filesystems/9p.rst
>@@ -50,6 +50,14 @@ mount points. Each 9P export is seen by the client as a virtio device with an
> associated "mount_tag" property. Available mount tags can be
> seen by reading /sys/bus/virtio/drivers/9pnet_virtio/virtio<n>/mount_tag files.
>
>+For server accessible over vsock (VM sockets)::
>+
>+	mount -t 9p -o trans=vsock <CID> /mnt/9
>+
>+where CID is the vsock Context ID of the remote endpoint (2 for host from
>+a guest VM, 3+ for guest VMs from the host). The port to connect to can be
>+specified with the port option (default: 564).
>+
> USBG Usage
> ==========
>
>@@ -115,8 +123,10 @@ Options
> 			========  ============================================
> 			unix 	  specifying a named pipe mount point
> 			tcp	  specifying a normal TCP/IP connection
>-			fd   	  used passed file descriptors for connection
>+			fd   	  uses passed file descriptors for connection

nit: unrelated change?

The rest LGTM, so for vsock point of view:

Acked-by: Stefano Garzarella <[email protected]>