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

Implement vsock support for FreeBSD #2798

Merged
merged 5 commits into from
Sep 27, 2023

Conversation

ziggythehamster
Copy link
Contributor

FreeBSD supports something very nearly the same as Linux's vsock with Hyper-V, and this patch adds support for it to xrdp.

Practically speaking, this allows you to use enhanced session mode in Hyper-V, if you run Set-VM -EnhancedSessionTransportType HvSocket on the VM in PowerShell. That said, the performance is bad because it is fully software rendered, because the Hyper-V enhanced DRM/DRI driver hasn't been ported to FreeBSD yet (there's a pending change to implement the enhanced framebuffer, but I doubt that makes xorgxrdp able to use hardware accelerated rendering).

One bug is that when g_sck_close tries to run getsockname, EINVAL is returned and the socket is closed normally, but looking at the code, I think that also happens with Linux because sock_info.sa rather than sock_info.sa_vm or sock_info.sa_hvs are passed in, and sa is not the correct structure for the open vsock/hv_sock socket. Fixing this feels like it's probably out of scope for this change, since both Unix sockets and Linux vsocks would suffer from the same problem.

Here's a screenshot showing it in action, forgive the Windows DPI being messed up (I need to reboot, I think, to fix it):

image

@metalefty
Copy link
Member

Awesome! Could you fix the formatting and cppcheck?

@ziggythehamster
Copy link
Contributor Author

I believe I've resolved both issues. I also changed the configure script to check for AF_HYPERV, since it looks like this is only available in FreeBSD 13+, and someone may try this in an older FreeBSD.

Copy link
Member

@matt335672 matt335672 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks clean to me. I can't test, but I'd be happy to merge.

@metalefty
Copy link
Member

I will merge after some other PRs.

@metalefty metalefty merged commit 89ceaf0 into neutrinolabs:devel Sep 27, 2023
13 checks passed
@metalefty
Copy link
Member

@ziggythehamster I have updated FreeBSD net/xrdp-devel port and defaulted --enable-vsock.

@ziggythehamster
Copy link
Contributor Author

@metalefty oh, awesome. I was expecting to have to hunt down the port maintainer to get them to change the Makefile :D

@metalefty
Copy link
Member

I am the maintainer 👍

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

Successfully merging this pull request may close these issues.

3 participants