rust-lang / libs-team

The home of the library team
Apache License 2.0
127 stars 19 forks source link

Add support for AF_VSOCK #185

Closed emielvanseveren closed 1 year ago

emielvanseveren commented 1 year ago

Proposal

Add support for AF_VSOCK which facilitates communication between virtual machines and the host they are running on. see vsock(7). The implementation should be very similar to AF_NETLINK.

More information on vsock programming can be found at: pubs.vmware.com/vsphere-60/topic/com.vmware.ICbase/PDF/ws9_esx60_vmci_sockets.pdf

Problem statement

There is no implementation available in std.

Motivation, use-cases

Solution sketches

Links and related work

the8472 commented 1 year ago

There is no implementation available in std.

Well, does it have to be in std? It seems kind of niche, so wouldn't having it in a crate be enough?

emielvanseveren commented 1 year ago

There is no implementation available in std.

Well, does it have to be in std? It seems kind of niche, so wouldn't having it in a crate be enough?

I'm not sure if would consider it niche. Every application running inside a vm that wants to communicate with its host can do this over vsock. This could be very similar to everything that takes tcp sockets. E.g. a http server inside the guest that takes connections over vsock.

the8472 commented 1 year ago

Every application running inside a vm that wants to communicate with its host

Which in my experience isn't all that common? At work we have a ton of services running in VMs, very few of them need to talk with the host. The only things that come to mind are wsl2, docker on windows and some vmware guest tools.

Running software in microvms and only there, to the extent that they need specialized communication channels, is not exactly mainstream software, is it?

This could be very similar to everything that takes tcp sockets. E.g. a http server inside the guest that takes connections over vsock.

Alas, sockets in the standard library are not a general BSD socket type. Instead everything is distinct struct type for each socket family + type. Hell, TCP sockets are even split into TcpListener and TcpStream.

This might be more appropriate for the socket2 crate, and even that focuses more on tcp/udp/unix sockets than other ones. E.g. netlink, icmp or raw sockets don't have any explicit support there and must be constructed manually.

emielvanseveren commented 1 year ago

You're right, I'm closing this for now.