4 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 e4b44b5994 fix(lima): limactl shell never starts a stopped VM past devvm's checks
In a terminal, limactl shell of a stopped VM asks whether to start it, yes by default (Lima 2.3.0, reproduced under a pty), and that start is Lima's own: no proxy or sandbox-exec profile (no QEMU wrapper on Linux), no pins, and no folderChanged, so the project folder's mount, by path on Linux's 9p, follows a link put at the path or makes a folder that's gone again. devvm opens a shell (Shell) and runs an agent's login (Exec) on the terminal after bringUp, so a guest that powered itself off between the two got that question. This is the start path the self-check's restart was suspected of: that restart goes through startOnce, but limactl shell didn't.

The limactl builder, which every limactl command of devvm's goes through, now gives limactl shell --start=false, which Lima has had since 2.0.0-rc.0 (devvm's oldest is 2.2): a stopped VM's shell or command fails at once ("instance is stopped"), without asking, and devvm's next launch starts it with every check. devvm limactl, which passes its arguments on as given, is unchanged.

TestShellNeverStarts checks Exec's, Shell's and the builder's limactl shell, and fails without the change; the lima package's and the CLI scripts' expected limactl shell calls name the flag, their negative patterns too, so none turns vacuous. Docs: How it works' Lima page's A stopped VM's shell; the changelog's Security hardening gets the line, its summary widened to cover both of its lines, and the release page its section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 07:43:53 -07:00
w3cjandClaude Opus 5.5 b6954e1e11 refactor(vmname): a VM's name is a vmname.VM, parsed where it's read
vmname.VM is the name of every machine devvm runs on a backend: a
project VM, an image's machine (devvm-img-<key>), a build VM and a
remake's aside. Fields, parameters, results and map keys that held a VM's
name as a string now hold a VM, from the backend interface down to the
CLI's --json structs, whose output is byte for byte the same.

Boundary parsers, the only places a string becomes a VM:
- vmname.Parse: a project VM's name (state's vm.json name, export file
  names, devvm _links's argument, the forwarder's -vm, project.Nth)
- vmname.ParseListed: one path element, for what a backend lists
- VM.UnmarshalText: JSON (Lima's list, proxy config and events, links'
  targets in state, link lists); empty stays no VM
- vmname.Image(key), VM.Aside(), and typed constants for Lima's build VMs
- msg.M.VM: the VM a message's function took, read back

vmname's functions on names became methods (Hash, Slug, Short, Aside,
AsideHash, ImageKey, IsProject); Lima's image prefix moved to vmname;
vmname.Join joins VM lists. Messages' vm and vm_name fields are typed
by the generator. Seven messages whose field took something else became
what= (backend_lacks, backend_unreviewed, backend_unreviewed_used,
starting, deleting, configuring, running_script) and rm_vm_failed's
name=: the text is unchanged, the names-mode scripts follow.
Review.RequireFor names an image or the tools being built.

Typed sites per package (added lines with vmname.VM, non-test): msg 347
(generated), vm 124, lima 48, backendtest 32, vmssh 31, netpolicy 22,
backend 16, gitprotect 14, proxy 11, cli 11, project 10, state 8,
ports 6, paths 3, sshagent 2, sshconfig 2, tools 2.

The structure test's owners rule now fails on a field, parameter or
result named for a VM (vm, vms, otherVM, vmName) typed string, []string
or map[string]…, and on converting anything but a literal to vmname.VM
outside the files it lists; internal/stubtest is free. depguard holds
internal/vmname to the standard library, and the proxy may import it.

ParseListed and UnmarshalText refuse a name starting with -, which would read as a flag in limactl's argv, and vmname.Image refuses a key that's empty, holds a / or NUL, or makes a project VM's name, so Lima's ImageSize and DeleteImage no longer check it themselves. The check also fails on a *string VM name and an alias of vmname.VM, and says what it doesn't see.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:28 -07:00
w3cjandClaude Opus 5.5 b30229ca19 test(fixture): a fixture's host ports are ones free here
fixture_v010.txtar launched app, scratch and web on the host ports
0.1.0 recorded on the machine that made the fixture. When any of them
was taken here, by a program or by another run of the same tests (two
checkouts' gates on one machine), the launch rightly chose another port
and edited the VM's Lima config, failing the script's check that a
launch makes no limactl edit.

fixture VERSION now maps each VM's ports.host to a port free here,
wherever the number stands on its own (vm.json, the stub's state,
lima.yaml's proxy URL, the proxy's config and status, the sandbox
profile), never inside a hash. The other fixture_v010 scripts' own
free_port and json_set of ports are no longer needed and go.

- freePorts: free_port's helper, shared with fixture
- fixtureRewrite: the paths' replacer plus the ports
- TestFixtureRewritePorts

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 17:27:34 -07:00
w3cjandClaude Opus 5.5 eb45ad4e18 test(state): run devvm mount-cache and devvm network transparent on 0.1.0's state
The 9p cache and transparent-mode branches each added a vm.json
setting without running its command on the frozen 0.1.0 fixture, which
the fixture policy asks of a change to state.

- fixture_v010_mount_cache.txtar (Linux): 0.1.0's app VM shows mmap
  with the warning; devvm mount-cache none is pending while stopped, the
  next start makes it in one limactl edit with 9p's cache none and
  mounts the folder again, and the start after that edits nothing.
- fixture_v010_network.txtar: app, with no transparent mode of its own,
  follows the default, on, and its launch gives the setup the stand-in
  address; devvm network transparent off and on go in its state and
  apply from its next launch.
- checkV010Others: no 0.1.0 VM has a cache mode or a transparent mode
  of its own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-09 07:28:44 -07:00