Skip to content

qemu: fall back to TCP host forwarding when vsock is unavailable#4212

Open
gourryinverse wants to merge 1 commit intosystemd:mainfrom
gourryinverse:mkosi_ssh
Open

qemu: fall back to TCP host forwarding when vsock is unavailable#4212
gourryinverse wants to merge 1 commit intosystemd:mainfrom
gourryinverse:mkosi_ssh

Conversation

@gourryinverse
Copy link
Copy Markdown

When vsock is not available (VSock=no or no /dev/vsock), dynamically allocate a host port and configure QEMU user-mode networking with hostfwd to forward SSH traffic over TCP loopback.

Changes:

  • finalize_state() and register_machine() accept explicit proxy_command and ssh_address parameters, falling back to vsock defaults when a CID is present
  • Dynamic port allocation via socket.bind(("127.0.0.1", 0)) avoids collisions when multiple VMs run concurrently
  • Use socat TCP4 (not TCP) to avoid AI_ADDRCONFIG getaddrinfo failures inside the mkosi bubblewrap sandbox.
  • Update run_ssh() hint to no longer require Vsock=yes

when paired with: systemd/systemd#41013 -- this allows for ssh machine/* syntax

@gourryinverse gourryinverse force-pushed the mkosi_ssh branch 2 times, most recently from a96e540 to 39145a1 Compare March 10, 2026 03:59
When vsock is not available (VSock=no or no /dev/vsock), dynamically
allocate a host port and configure QEMU user-mode networking with
hostfwd to forward SSH traffic over TCP loopback.

Changes:
- finalize_state() and register_machine() accept explicit proxy_command
  and ssh_address parameters, falling back to vsock defaults when a CID
  is present
- Dynamic port allocation via socket.bind(("127.0.0.1", 0)) avoids
  collisions when multiple VMs run concurrently
- Use socat TCP4 (not TCP) to avoid AI_ADDRCONFIG getaddrinfo failures
  inside the mkosi bubblewrap sandbox.
- Update run_ssh() hint to no longer require Vsock=yes

Signed-off-by: Gregory Price <gourry@gourry.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant