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

From: Stefan Hajnoczi

Date: Fri Jul 03 2026 - 01:41:53 EST


On Wed, Jul 01, 2026 at 05:59:22PM +0200, skvarlamatus@xxxxxxxxx wrote:
> From: Matus Skvarla <skvarlamatus@xxxxxxxxx>
>
> 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.
>
> 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 <skvarlamatus@xxxxxxxxx>
> ---
> 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/20260527073447.86538-1-skvarlamatus@xxxxxxxxx/
> ---
> 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

If you respin this patch, please add the port= option because it is
absent from this example and it could be missed if one doesn't read the
paragraph below carefully:

mount -t 9p -o trans=vsock[,port=<port>] <CID> /mnt/9

Other than that:

Reviewed-by: Stefan Hajnoczi <stefanha@xxxxxxxxxx>

Attachment: signature.asc
Description: PGP signature