Skip to content

[3.12] gh-145548: Use VMADDR_CID_LOCAL in VSOCK socket tests (GH-145589)#145809

Open
encukou wants to merge 2 commits intopython:3.12from
encukou:backport-16dbbe5-3.12
Open

[3.12] gh-145548: Use VMADDR_CID_LOCAL in VSOCK socket tests (GH-145589)#145809
encukou wants to merge 2 commits intopython:3.12from
encukou:backport-16dbbe5-3.12

Conversation

@encukou
Copy link
Member

@encukou encukou commented Mar 11, 2026

Prefer VMADDR_CID_LOCAL instead of VMADDR_CID_ANY for bind() in the
server. Skip the test if bind() fails with EADDRNOTAVAIL.

Log vsock CID in test.pythoninfo.
(cherry picked from commit 6c8c72f)

Includes fix-up from 26326a0 (GH-145735)

Co-authored-by: Victor Stinner vstinner@python.org

miss-islington and others added 2 commits March 11, 2026 13:40
…ythonGH-145589) (pythonGH-145594)

pythongh-145548: Use VMADDR_CID_LOCAL in VSOCK socket tests (pythonGH-145589)

Prefer VMADDR_CID_LOCAL instead of VMADDR_CID_ANY for bind() in the
server. Skip the test if bind() fails with EADDRNOTAVAIL.

Log vsock CID in test.pythoninfo.
(cherry picked from commit 6c8c72f)
(cherry picked from commit 16dbbe5)

Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
…honGH-145735)

VMADDR_CID_LOCAL was added to `socekt` in 3.14. The test needs a
local constant in setUp(), as in clientSetUp().
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. I tested the change manually on Fedora Stable x86-64, ./python -m test test_socket -m ThreadedVSOCKSocketStreamTest -v pass successfully, and ./python -m test.pythoninfo works as expected (it logs test_socket.get_cid: 4294967295).

@vstinner
Copy link
Member

The test also exists on 3.10 and 3.11, we might need to backport the change there as well.

@encukou
Copy link
Member Author

encukou commented Mar 11, 2026

The test also exists on 3.10 and 3.11, we might need to backport the change there as well.

Yes. I set the labels here, so that miss-islington includes the fix-up.

@Shrey-N
Copy link
Contributor

Shrey-N commented Mar 11, 2026

Hiya @encukou
Here the socket prefix is missing, I think if it is a constant from the socket module, it should be namespaced. Otherwise, it couldn't safely fall back in case older systems do not have it defined.

@vstinner
Copy link
Member

Here the socket prefix is missing, I think if it is a constant from the socket module, it should be namespaced.

I added socket.VMADDR_CID_LOCAL constant in Python 3.14. On Python 3.13 and older, the VMADDR_CID_LOCAL constant is only defined in test_socket.py.

@Shrey-N
Copy link
Contributor

Shrey-N commented Mar 11, 2026

Ah, Thank you for the clarification :) I just realised that I didn't see the 3.12 tag

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants