-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-92658: Add Hyper-V socket support #92755
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
Conversation
Every change to Python requires a NEWS entry. Please, add it using the blurb_it Web app or the blurb command-line tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On first glance the PR looks ok, with some minor issues.
That said, I'm not a Windows user and cannot test this PR myself.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I have made the requested changes; please review again |
Thanks for making the requested changes! @ronaldoussoren: please review the changes made to this pull request. |
@erlend-aasland sorry I can't seem to reply to your last review comment
Isn't |
No, that's correct. It's up to you to decide which APIs to use. |
Thanks for clarifying, I'll probably keep it with |
Co-authored-by: Steve Dower <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, as far as I can see :) Good job!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, just one more request. This is the first time I've actually read over the whole change, and it looks great!
Great work, nice patch! Would love to see a more extensive example of how to use this (blog post or conf talk or similar), but it's very early days for 3.12, so no hurry ;) |
Thanks for the reviews everyone, appreciate the time you've put in to help me get this in. While not using the changes here, this is what I used as POC to talk to a Hyper-V guest for PowerShell Direct https://gist.github.com/jborean93/61854124d7686621ce9c1ade8687dc7a. I'm hoping to have it integrated in my PowerShell Remoting library at some point soon but need to deal with some asyncio problems first. |
The change broke the FreeBSD buildbot: https://buildbot.python.org/all/#/builders/483/builds/2438 The closest thing that I found is this FreeBSD commit: https://reviews.freebsd.org/rS361275 which adds cc @emaste
|
The FreeBSD comment about SOCKADDR_HV:
Linux has a similar comment, but it seems it does not define AF_HYPERV. I guess this change should apply on Windows only? |
Hmm, seems like we should also add an |
Simple fix to only build AF_HYPERV support on Windows: #93192 |
While FreeBSD defines the AF_HYPERV macro, it doesn't define the HyperV socket structure:
The Python implementation requires to get access to members of this structure. One option would be to define the structure in Python, but I'm not volunteer to maintain such structure in Python. For now, the simplest option is to limit AF_HYPERV support to Windows which defines the structure. |
Partially fixes #92658.
There are 2 outstanding questions I have for the PR:
connect
andbind
accept as the addrCurrently the code accepts a tuple of 2 16 byte strings only. This could potentially be changed to somehow accept a
uuid.UUID
or even potentially a string of a UUID. My C skills are rusty so I just went with the simpler solution but if it is desired to change this or add support for other types I'm happy to do so at someones direction.AF_HYPERV
and# include <hvsocket.h>
Currently
AF_HYPERV
is defined at https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.16299.0/shared/ws2def.h#L145-L148 and is only included if_WIN32_WINNT > 0x0604
. Currently Python sets that at0x0602
for Windows 8 compatibility which is why the PR manually defines it. The header also importshvsocket.h
for some other definitions used in the code but I'm unsure if this should be done conditionally somehow. Any suggestions or improvements would be great.