mdlayher / vsock

Package vsock provides access to Linux VM sockets (AF_VSOCK) for communication between a hypervisor and its virtual machines. MIT Licensed.
MIT License
336 stars 65 forks source link

vhost-user-vsock #49

Open aep opened 2 years ago

aep commented 2 years ago

vhost-user-vsock implements vsocks as uds on the host.

i wonder what it takes to implement that in this package. there appears to be a rust impl

https://github.com/rust-vmm/vhost-device/pull/7/files

but i'm not sure if thats the correct layer

mdlayher commented 2 years ago

Hey there, I have very little context as to what this actually is or what sort of use cases it solves. It's my understanding that the virtio-vsock device with qemu is the defacto solution but would this be for communicating between local processes on the same machine? If so then more recent versions of the vsock kernel modules support loopback communication on the same host.

I just ask because I am a bit removed from the space and would like to understand the use cases for the feature here, and what sort of APIs you'd expect to see. Thanks!

aep commented 2 years ago

ah, sorry!

normally vsock is implemented by using the host kernel vsock implementation. i.e. the host just opens a socket with AF_VSOCK. However, that's not safe in multi tenancy situations where you don't trust the VMs, so that's what vhost-user-vsock is for.

It implements the host side as vhost-user unix domain socket. the pull request i linked contains an example implementation in rust. Unfortunately i dont know much more either. it looks like vhost-user is fairly complex and i couldnt find a golang implementation of it. It's likely not worth it implementing it in go-vsock if the base vhost-user impl doesnt exist

mdlayher commented 2 years ago

No worries! We can leave this open for tracking but yeah it seems like a lot more plumbing would be required.