net/9p: add vsock transport
Subsystems (3)
PATCH v3 1/1 net/9p: add vsock transport
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 implemented 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
---
Changes in v3:
- Add port= option to vsock mount example in documentation
- Drop unrelated typo fix in documentation
- Add TODO comment for vsock privport binding
- Clarify privport error message as "currently not implemented"
Link to v2: https://lore.kernel.org/v9fs/[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 | 10 ++++ include/net/9p/client.h | 10 +++- net/9p/Kconfig | 10 ++++ net/9p/trans_fd.c | 98 +++++++++++++++++++++++++++++++- 4 files changed, 124 insertions(+), 4 deletions(-)
Documentation/filesystems/9p.rst +10 -0
@@ -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[,port=<port>] <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 ==========
@@ -117,6 +125,8 @@ Options tcp specifying a normal TCP/IP connection fd used passed file descriptors for connection (see rfdno and wfdno) + vsock connect over VM sockets (vsock) using + CID as the mount source virtio connect to the next virtio channel available (from QEMU with trans_virtio module) rdma connect to a specified RDMA channel
include/net/9p/client.h +7 -3
@@ -122,8 +122,12 @@ struct p9_client {struct {u16 port;bool privport; - } tcp; +#if IS_ENABLED (CONFIG_NET_9P_VSOCK ) +struct { +u32 port; + } vsock; +#endif } trans_opts;struct idr fids;
@@ -151,13 +155,13 @@ struct p9_client_opts {* struct p9_fd_opts - per-transport options for fd transport * @rfd: file descriptor for reading (trans=fd) * @wfd: file descriptor for writing (trans=fd) -* @port: port to connect to (trans=tcp) +* @port: port to connect to (trans=tcp, trans=vsock) * @privport: port is privileged */ struct p9_fd_opts {int rfd;int wfd; -u16 port; +u32 port;bool privport; };
net/9p/Kconfig +10 -0
@@ -32,6 +32,16 @@ config NET_9P_VIRTIO This builds support for a transports between guest partitions and a host partition. +config NET_9P_VSOCK + depends on NET_9P_FD + depends on VSOCKETS + bool "9P VSOCK Transport" + help + This builds support for a transport for 9pfs over + virtual sockets (vsock). This is useful for communication + between virtual machines and their host without requiring + TCP/IP networking configuration or additional userspace software. + config NET_9P_XEN depends on XEN select XEN_XENBUS_FRONTEND
net/9p/trans_fd.c +97 -1
146 lines not on this page · raw message
Signature · 1 line
2.47.1
Dominique Martinet
maintainer[email protected] wrote on Thu, Jul 09, 2026 at 06:17:41PM +0200:
Quoted 21 lines
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.cwith vsock support, reusing the existing socket infrastructure. A newp9_fd_create_vsock()function handles vsock connection setup by parsing the CID from the mount source, creating anAF_VSOCKsocket, 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 implemented for vsock and returns
-EOPNOTSUPPif specified.Add
CONFIG_NET_9P_VSOCKoption that conditionally compiles vsock support into 9pnet_fd.ko. This follows the pattern where socket-based transports (TCP, Unix, vsock) sharetrans_fd.c, while specialized hardware transports (virtio, xen, rdma) have dedicated files.
Quoted 6 lines
Usage:
mount -t 9p -o trans=vsock[,port=<port>] <CID>/mnt/pointSigned-off-by Matus Skvarla <[email protected]>Reviewed-by Stefan Hajnoczi <[email protected]>
Thanks for the v3
I'm mostly happy with the code, but I have a few high level questions before sending this to Linus (I'll probably take the patch for -next next week anyway):
- I've looked at v1/v2 threads and I don't actually see any rationale
explained: what's the benefit of this over e.g. virito or xen transports?
Do you have/use an hypervisor that cannot do virito 9p (or virtfs) but has vsock or something like that?
- On a similar topic, do you have an actual server that works with vsock?
I've seen I can test with diod+socat[1], but I expect to see a real user ready if this is merged, not just "this can work"
[1] https://github.com/chaos/diod/issues/148
Thanks,
Signature · 1 line
Dominique Martinet | Asmadeus
Quoted 6 lines · On Sun, Sep 13, 2026 at 14:09 +0000, [email protected] wrote:
I've looked at v1/v2 threads and I don't actually see any rationale
explained: what's the benefit of this over e.g. virito or xen transports?Do you have/use an hypervisor that cannot do virito 9p (or virtfs) but has vsock or something like that?
virtio-9p is only supported by Qemu/KVM. Vsock transport works on any hypervisor with vsock support and allows using userspace 9P servers.
The motivation behind this patch is primarily driven by podman machine's use-case, which is file sharing on Windows [1] [2].
The hypervisor there is Hyper-V/WSL, which supports vsock for host-guest data transfers [3], but not virtio-9p or virtfs. Having vsock transport in the driver would simplify the codebase and make the use-case more flexible.
Quoted 1 line
On a similar topic, do you have an actual server that works with vsock?
Podman implements its own 9P server in Go using the p9 library [4] with vsock support via virtsock [5], but it runs as part of podman machine. For standalone 9p servers, I only know of diod and example implementations of various 9p server libraries (i.e. [6]), but none of them support vsock.
As far as I know, there is one 9p FUSE client with native vsock support (my contribution) [7].
[1] https://github.com/podman-container-tools/podman/blob/main/cmd/podman/machine/server9p.go
[2] https://github.com/podman-container-tools/podman/blob/main/cmd/podman/machine/client9p.go
[3] https://learn.microsoft.com/en-us/windows-server/virtualization/hyper-v/make-integration-service
[4] https://github.com/hugelgupf/p9
[5] https://github.com/linuxkit/virtsock
[6] https://github.com/hugelgupf/p9/blob/main/cmd/p9ufs/p9ufs.go
[7] https://github.com/ftrvxmtrx/9pfs
--
Matus
Dominique Martinet
maintainer[email protected] wrote on Mon, Sep 14, 2026 at 07:51:56PM +0200:
Quoted 10 lines
Quoted 2 lines
Do you have/use an hypervisor that cannot do virito 9p (or virtfs) but has vsock or something like that?
virtio-9p is only supported by Qemu/KVM. Vsock transport works on any hypervisor with vsock support and allows using userspace 9P servers.
The motivation behind this patch is primarily driven by podman machine's use-case, which is file sharing on Windows [1] [2].
The hypervisor there is Hyper-V/WSL, which supports vsock for host-guest data transfers [3], but not virtio-9p or virtfs. Having vsock transport in the driver would simplify the codebase and make the use-case more flexible.
Okay, thank you for the explanation -- I'll add a blurb to the commit message with your links for reference.
Quoted 6 lines
Quoted 1 line
On a similar topic, do you have an actual server that works with vsock?
Podman implements its own 9P server in Go using the p9 library [4] with vsock support via virtsock [5], but it runs as part of podman machine. For standalone 9p servers, I only know of diod and example implementations of various 9p server libraries (i.e. [6]), but none of them support vsock.
Right, diod has an open issue[1] for vsock but since there were no obvious client available either it was never done.
I don't think it's difficult to do (probably more work to add the option parsing than the actual vsock support), but for now I was able to verify this works with diod + socat as described in the issue, so this can come later if/when there is interest for other hypervisors.
[1] https://github.com/chaos/diod/issues/148
Signature · 1 line
Dominique Martinet | Asmadeus
Quoted 4 lines · On Mon, Sep 14, 2026 at 23:44 +0000, [email protected] wrote:
Right, diod has an open issue[1] for vsock but since there were no obvious client available either it was never done.
I don't think it's difficult to do (probably more work to add the option parsing than the actual vsock support)
Definitely agree. I think with this in the client, it could encourage more servers to add vsock support too.
Thank you Dominique and all involved!
--
Matus
Dominique Martinet
maintainer[email protected] wrote on Wed, Sep 16, 2026 at 09:42:04PM +0200:
Quoted 8 lines · On Mon, Sep 14, 2026 at 23:44 +0000, [email protected] wrote:
Quoted 4 lines
Right, diod has an open issue[1] for vsock but since there were no obvious client available either it was never done.
I don't think it's difficult to do (probably more work to add the option parsing than the actual vsock support)Definitely agree. I think with this in the client, it could encourage more servers to add vsock support too.
Just had a quick look at diod code and their handling of the listen option is purely string based, passed to getaddrinfo() to figure out if the user requested ipv4/ipv6 -- I'm pretty sure getaddrinfo() doesn't want to have anything to do with vsock, but I don't suppose there's a canonical string representation for vsock is there? (something like cid:<cid>:<port> instead of the usual <cid>:<port> couple printed?)
I didn't want to add a new option such as --vsock-listen, but I'd hate to disambiguate vsock from ipv4/v6 as a string even more... :)
FWIW commit message ended up like this (everything ellipsed is exactly as you sent), so just extending the sentence a bit to mention Hyper-V and podman machine:
```
net/9p: add vsock transport
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, which can be useful with
hypervisors other than Qemu/KVM, for example Hyper-V/WSL which is used
by podman machine on Windows[1][2].
[implementation details]
Usage:
mount -t 9p -o trans=vsock[,port=<port>] <CID> /mnt/point
Link: https://github.com/podman-container-tools/podman/blob/main/cmd/podman/machine/server9p.go [1]
Link: https://github.com/podman-container-tools/podman/blob/main/cmd/podman/machine/client9p.go [2]
[sign-offs/reviews]
```Thanks,
Signature · 1 line
Dominique Martinet | Asmadeus
Hi Dominique,
I noticed the batch you applied to 9p-test on Sep 22 (including the vsock transport) hasn't made it to 9p-next yet, so I just wanted to check whether it's still planned for the 7.4 merge window or if it's waiting on something.
If I can help with anything, e.g. testing, just let me know.
--
Matus
Dominique Martinet
maintainer[email protected] wrote on Tue, Oct 27, 2026 at 09:05:22PM +0100:
Quoted 4 lines
I noticed the batch you applied to 9p-test on Sep 22 (including the vsock transport) hasn't made it to 9p-next yet, so I just wanted to check whether it's still planned for the 7.4 merge window or if it's waiting on something.
Sorry it's just waiting on me to have time to do something.. There's still a bit over 1 week this merge window (it's exceptionally 3 weeks) so I think I'll make it, I've just pushed to next
Thanks for the ping
Signature · 1 line
Dominique Martinet | Asmadeus