Repository navigation
bug(vm): gateway compute-driver.sock path can exceed macOS sun_path limit #5015
Description
User Story
As a developer running the VM compute driver on macOS, I want the gateway's compute-driver socket path to fit within the OS sun_path limit so that the gateway starts no matter where I keep VM driver state.
Problem Statement
The gateway places the VM driver's control socket at {state_dir}/run/compute-driver.sock. On macOS, struct sockaddr_un.sun_path is 104 bytes (103 usable). The fixed /run/compute-driver.sock suffix takes 24 bytes, so any state_dir longer than 79 bytes makes the driver fail to bind, and the gateway does not start.
For example, with a state_dir inside a checkout:
/Users/bmahabir/src/github.com/NVIDIA/OpenShell/.cache/gateway-vm/vm-driver-state/run/compute-driver.sock
└──────────────────────────────────────── 105 bytes ───────────────────────────────────────────────┘
Path length breakdown:
/Users/bmahabir/src/github.com/NVIDIA/OpenShell/.cache/gateway-vm/vm-driver-state (81)
/run/compute-driver.sock (24)
total = 105 bytes
macOS usable limit = 103 bytes
over by 2 bytes
#3452 hit the same limit for the per-sandbox control.sock and ssh.sock. #3544 fixed those by moving them to a short, randomly named directory under /tmp, but explicitly left run/compute-driver.sock unchanged. This is the remaining socket.
Impact / Why This Matters
The gateway fails at startup with path must be shorter than SUN_LEN, which doesn't name the path or the setting that controls it (see #4178).
The current workaround is to set a short state_dir such as /tmp/os-vm. This is non-obvious and moves persistent VM state (overlays, image cache, logs) into /tmp, which is cleared on reboot. The repo's own dev scripts (tasks/scripts/gateway-vm.sh, e2e/rust/e2e-vm.sh) already put state under /tmp for this reason.
Linux is less affected (108-byte limit) but not immune with deep state directories.
Acceptance Criteria
- The gateway starts with the VM driver on macOS for any reasonable
state_dir, following the same approach as fix(vm): relocate per-sandbox Unix sockets to /tmp to fit macOS sun_path #3544 - VM state still persists under the configured
state_dir - The socket and its directory are cleaned up when the gateway shuts down
- If the socket path still can't fit, the error names the path, its length, and the limit (resolves bug(vm-driver): driver startup fails with a bare "path must be shorter than SUN_LEN" and does not name the path #4178)
Reproduction Steps
- On macOS, set
state_dirunder[openshell.drivers.vm]to a path longer than 79 bytes - Start the gateway with
compute_driver = "vm" - Observe the driver exits before the gateway becomes ready
Environment
- OpenShell: development build (current main branch)
- OS: macOS (Apple Silicon) —
sun_pathis 104 bytes - Runtime: VM compute driver (libkrun)
Logs
Same output as reported in #4178:
Error: × path must be shorter than SUN_LEN
Error: × execution error: vm compute driver exited before becoming ready with
│ status exit status: 1
Activity
fix(vm): move compute-driver socket to a short /tmp path (fixes NVIDI…