mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
A listed port's forward (Lima's hostagent, smolvm's -p) listens on 127.0.0.1/::1 with SO_REUSEADDR, so on macOS it took a port a host program held on *:PORT, and that program's localhost connections with it (checked on both backends). Now each start checks the VM's listed ports first and leaves out those in use, warned; the VM starts all the same, and the next start that finds a port free forwards it again. - platform: ListenLoopback (moved from smolvm's forwarder), PortFree and PortInUse, which listen on 127.0.0.1 and ::1 without SO_REUSEADDR (a port held only by ended connections counts as free; one that can't be bound for another reason, such as below 1024 on Linux, isn't in use). - vm: start checks the backend's listed ports (ports_set) with Env.PortInUse, warns ports_taken, and passes the rest in the new Confinement.Ports; every port and none pass nil. - Lima: Start parses portForwards from limactl list and sets them only where devvm's rules differ (guestIP compared for ignore rules alone), so a start edits, and the VM gets new host keys, only when a port is left out or comes back. - smolvm: Start updates -p where the machine's ports differ (listedPorts); the ssh port choice (freePort, PortFree) and Lima's confined ssh port use platform.PortFree. - Lima's forwards of every port aren't checked (Lima makes them as guest servers start): documented as a limit. Message: ports_taken. Docs: images.md (ports), lima.md, smolvm.md, security.md, design.md, limits.md, contributing.md. Tests: platform TestListenLoopback, vm TestSplitPorts and TestStartPorts, lima TestStartSetsPorts, smolvm TestStartListedPorts; ports.txtar and smolvm.txtar with a host listener (listen_any); the limactl stub keeps the portForwards clone and edit set. e2e: a host program on *:PORT keeps its port while the VM lists it, and the port is forwarded again once freed (project and smolvm sections). Co-Authored-By: Claude Opus 5.5 <[email protected]>