Files
Srilal Sachintha 0e4cf95759 machine: remove stale API socket before starting the host proxy
Since gvisor-tap-vsock v0.9.0 (containers/gvisor-tap-vsock#718),
gvproxy and win-sshproxy no longer delete a leftover unix socket before
listening on it; they only remove it on a clean exit. When the proxy is
killed instead (host shutdown or restart, crash, SIGKILL), the API
socket is left behind and the next proxy fails to bind it:

- WSL: win-sshproxy exits and takes the named pipes with it, while
  `machine start` still reports success.
- Hyper-V, macOS and Linux: gvproxy exits, which also breaks SSH
  forwarding, so `machine start` fails (or hangs on macOS).

Remove the API socket in startNetworking, after cleanupStaleHostForwarder
has handled any orphaned proxy. On WSL a failed delete only warns, since
win-sshproxy serves only the API and SSH goes through wslrelay.

On macOS and Linux, `machine stop` also failed after gvproxy was killed
("looking up PID ...: process does not exist"); treat a missing gvproxy
as already stopped, as the Windows code does.

The "client connect to machine socket" e2e test now also kills the proxy
by the PID from its pid/tid file, restarts the machine and checks the API
again, and runs on Windows too.

Fixes: #29971
Signed-off-by: Srilal Sachintha <SrilalSachintha@Gmail.com>
2026-10-22 16:31:19 -04:00
..
…

Running the machine tests

This document is a quick how-to run machine tests. Not all dependencies, like gvproxy are documented. You must install gvproxy in all cases described below.

General notes

Environment must be clean

You must not have any machines defined before running tests. Consider running podman machine reset prior to running tests.

Scoping tests

You can scope tests in the machine suite by adding various incantations of FOCUS=. For example, add FOCUS_FILE=basic_test.go to only run basic test. Or add FOCUS="simple init with start" to only run one test case. For windows, the syntax differs slightly. In windows, executing something like following achieves the same result:

./winmake localmachine "basic_test.go start_test.go"

To focus on one specific test on windows, run ginkgo manually:

$remotetags = "remote exclude_graphdriver_btrfs containers_image_openpgp"
$focus_file = "basic_test.go"
$focus_test = "podman build contexts"
./test/tools/build/ginkgo.exe `
     -v --tags "$remotetags" -timeout=90m --trace --no-color `
     --focus-file  $focus_file `
     --focus "$focus_test" `
     ./pkg/machine/e2e/.

Note that ginkgo.exe is built when running the command winmake.ps1 localmachine so make sure to run it before trying the command above.

Linux

QEMU

  1. make localmachine

Microsoft Windows

Hyper-V

  1. Open a powershell as admin
  2. .\winmake.ps1 podman-remote && .\winmake.ps1 win-gvproxy
  3. $env:CONTAINERS_HELPER_BINARY_DIR="$pwd\bin\windows"
  4. $env:CONTAINERS_MACHINE_PROVIDER="hyperv"
  5. .\winmake localmachine

WSL

  1. Open a powershell as a regular user
  2. .\winmake.ps1 podman-remote && .\winmake.ps1 win-gvproxy
  3. $env:CONTAINERS_HELPER_BINARY_DIR="$pwd\bin\windows"
  4. $env:CONTAINERS_MACHINE_PROVIDER="wsl"
  5. .\winmake localmachine

MacOS

Macs now support two different machine providers: applehv and libkrun. The libkrun provider is the default.

Note: On macOS, an error will occur if the path length of $TMPDIR is longer than 22 characters. Please set the appropriate path to $TMPDIR. Also, if $TMPDIR is empty, /private/tmp will be set.

Apple Hypervisor

  1. brew install vfkit
  2. make podman-remote
  3. export CONTAINERS_MACHINE_PROVIDER="applehv"
  4. make localmachine

Libkrun

  1. brew install krunkit
  2. make podman-remote
  3. make localmachine