Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: How to use AF_VSOCK in a Windows VM? #534

Open
elmarco opened this issue Jan 13, 2021 · 5 comments
Open

Q: How to use AF_VSOCK in a Windows VM? #534

elmarco opened this issue Jan 13, 2021 · 5 comments

Comments

@elmarco
Copy link

elmarco commented Jan 13, 2021

Not being very familiar with Windows in general, I thought I could simply add a virtio-vsock device, install the latest drivers (from https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso?) and follow https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/make-integration-service to connect to the host via VSOCK.

Alas, winsock2.h still doesn't define AF_VSOCK, and there seems to be a mix of concern in that documentation page. Then I looked at this repository and found viosocklib-test.c.

What are the steps to get socket(AF_VSOCK, SOCK_STREAM, 0) working from a Windows VM. Is there some virtio-win specific documentation available?

cc @irudakov77
thanks

@YanVugenfirer
Copy link
Collaborator

Hi @elmarco,

As far as I understand the driver installation is not installing (yet) the viosocklib.dll that registers Virtio Socket Provider.
The viosocklib-test has a command-line option /i to install the protocol:

I think @irudakov77 can provide more info on the subject.

Best regards,
Yan.

@irudakov77
Copy link

Hi @elmarco,

  1. Unfortunately the latest virtio-win.iso still does not contain socket driver. Maybe because the driver is not fully tested and has no any performance optimizations yet. I would not recommend to release socket driver in its current state. Driver improvement work has been suspended until April. If you suddenly want to build and check the driver, any feedback would be appreciated and I'll try to fix bugs ASAP.

  2. The mentioned article about Hyper-V sockets, and AF_VSOCK is used by Linux guests to create such a socket and is not defined for Windows guests which use AF_HYPERV instead. Please include https://github.com/virtio-win/kvm-guest-drivers-windows/blob/master/viosock/inc/vio_sockets.h to use AF_VSOCK for virtio sockets on Windows.

  3. fb849ee introduced optional co-installer to register socket provider during driver installation. Co-installer is enabled for RHEL (default) vendor and there is no need to run viosocklib-test /i to install provider dll.

Best regards,
Ilya

@elmarco
Copy link
Author

elmarco commented Jan 13, 2021

2\. The mentioned article about Hyper-V sockets, and AF_VSOCK is used by Linux guests to create such a socket and is not defined for Windows guests which use AF_HYPERV instead. Please include https://github.com/virtio-win/kvm-guest-drivers-windows/blob/master/viosock/inc/vio_sockets.h to use AF_VSOCK for virtio sockets on Windows.

The value of AF_VSOCK will never conflict with other Windows values? Iow, is the value registered with Microsoft, or are they following a numbering? It would be nice if they included it in their winsock2.h..

@irudakov77
Copy link

The value of AF_VSOCK will never conflict with other Windows values? Iow, is the value registered with Microsoft, or are they following a numbering? It would be nice if they included it in their winsock2.h..

Of course it will, but not today or even tomorrow. I get this value from Linux and use it at the time of development because it is grater than the current AF_MAX. It can easily conflict with other third-party socket provider AFs. Conflict can be avoided by requesting AF value from the viosock driver, it was planned to implement at the very end of development, but I can do it now. I liked the idea to "register" AF_VSOCK with Microsoft, thanks. But this will not be quick and the result is not guaranteed.

Regards,
Ilya

@fw8899
Copy link

fw8899 commented Apr 25, 2024

In the latest release virtio-win-0.1.248-1, there is still no viosock driver. Any plan in 2024? @YanVugenfirer @irudakov77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants