Files
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

121 lines
4.6 KiB
Plaintext

# devvm update: the folder's VM moved to newer shared tools without a
# question, then made again from its own image's new build, after
# asking, when that image changed since the VM was made, keeping its
# settings and its home folder; a current VM is said to be so, and
# nothing runs. Each launch's outdated and newer-tools warnings name
# devvm update.
env LAYERS=$XDG_CONFIG_HOME/devvm/layers
# No VM.
project web
! exec devvm update --force
stderr '^devvm: no_vm dir=/\S*/web$'
# A VM of a layer of the user's, with ports, a rule and files in its
# project folder and its home.
exec devvm layer new foo
exec devvm --network open --no-git-protect --agents claude --layers foo --ports 3000
vm_name WEB web
exec devvm network allow example.com
exec sh -c 'echo kept > notes && mkdir -p "$STUB_DIR/vmhome-$WEB" && echo ls > "$STUB_DIR/vmhome-$WEB/.bash_history"'
vm_state $WEB_dir/vm.json
stdout '^image=foo$'
# Current: said, and nothing runs.
stub_reset
exec devvm update
stdout '^==> vm_current image=foo vm=devvm-web-[0-9a-f]{14}$'
stub_calls
! stdout 'limactl (stop|rename|clone|delete)'
# Only newer shared tools: each launch warns, naming devvm update, which
# moves the VM to them and opens a shell, asking nothing, even without a
# terminal.
json_set $WEB_dir/vm.json tools.made.files:=["claude-1.0.0-0123456789ab.erofs"]
exec devvm
stderr '^devvm: newer_tools tools=claude \S+$'
stub_reset
exec devvm update
stdout '^==> tools_switch vm=devvm-web-[0-9a-f]{14}$'
! stdout 'vm_current|vm_changed'
! stderr remake_confirm
stub_calls
! stdout 'limactl (stop|rename|clone|delete)'
stdout 'limactl shell --start=false --workdir /\S*/web devvm-web-[0-9a-f]{14}\n'
vm_state $WEB_dir/vm.json
! stdout 'claude-1\.0\.0'
# Its layer's script edited: each launch warns, naming devvm update.
exec sh -c 'echo "echo again" >> "$LAYERS/foo.sh"'
exec devvm
stderr 'vm_outdated changed=foo$'
# Without a terminal it refuses unless --force, before its tools change;
# in one it asks, and no keeps the VM.
json_set $WEB_dir/vm.json tools.made.files:=["claude-1.0.0-0123456789ab.erofs"]
stub_reset
! exec devvm update
stdout '^==> vm_changed changed=foo vm=devvm-web-[0-9a-f]{14}$'
stderr '^devvm: no_input answer=--force$'
! stdout tools_switch
vm_state $WEB_dir/vm.json
stdout 'claude-1\.0\.0'
# No keeps it with its newer tools, and opens a shell.
ttyin -stdin $WORK/no.txt
exec devvm update
stdout '^==> tools_switch vm=devvm-web-[0-9a-f]{14}$'
stderr '^remake_confirm image=foo vm=devvm-web-[0-9a-f]{14} \[y/N\] '
stdout '==> kept vm=devvm-web-[0-9a-f]{14}$'
stub_calls
! stdout 'limactl (stop|rename|clone|delete)'
stdout 'limactl shell --start=false --workdir /\S*/web devvm-web-[0-9a-f]{14}\n'
vm_state $WEB_dir/vm.json
! stdout 'claude-1\.0\.0'
# --force: in order, the new build, the history exported, home saved, the
# VM stopped and set aside, made again from the same image name and
# started, home put back, the old machine deleted, then a shell.
stub_reset
exec devvm update --force
stdout '^==> building_image image=foo '
stdout '==> exported '
stdout '==> saving_home vm=devvm-web-[0-9a-f]{14}$'
stdout '==> creating_from image=foo vm=devvm-web-[0-9a-f]{14}$'
stdout '==> remade image=foo vm=devvm-web-[0-9a-f]{14}$'
stub_calls
stdout 'tar -czf - --one-file-system.*\n(.*\n)*limactl stop devvm-web-[0-9a-f]{14}\n(.*\n)*limactl rename --tty=false devvm-web-[0-9a-f]{14} devvm-[0-9a-f]{14}-old\n(.*\n)*limactl clone --tty=false devvm-img-[0-9a-f]+ devvm-web-[0-9a-f]{14} .*\n(.*\n)*limactl start --tty=false devvm-web-[0-9a-f]{14}\n(.*\n)*.*tar -xzf - --skip-old-files.*\n(.*\n)*limactl delete -f devvm-[0-9a-f]{14}-old\n(.*\n)*limactl shell --start=false --workdir /\S*/web devvm-web-[0-9a-f]{14}\n'
vm_state $WEB_dir/vm.json
stdout '^image=foo$'
stdout '^ports.forward=3000$'
stdout '^net.tier=open$'
stdout '^tools.names=claude$'
! stdout '^remake'
grep '^example\.com$' $WEB_dir/policy
grep '^kept$' notes
exec tar -tzf $STUB_DIR/home-in.tgz
stdout '^\.bash_history$'
# Current again: no warning, and devvm update does nothing.
exec devvm
! stderr vm_outdated
stub_reset
exec devvm update --force
stdout '^==> vm_current image=foo vm=devvm-web-[0-9a-f]{14}$'
stub_calls
! stdout 'limactl (stop|rename|clone|delete)'
# Refused like devvm layer add: a --clone VM, and a parent folder's VM
# without a terminal.
exec sh -c 'echo "echo once more" >> "$LAYERS/foo.sh"'
json_set $WEB_dir/vm.json 'clone:={"on":true}'
! exec devvm update --force
stderr '^devvm: remake_clone vm=devvm-web-[0-9a-f]{14}$'
json_set $WEB_dir/vm.json 'clone:={}'
mkdir sub
cd sub
! exec devvm update --force
stderr '^devvm: remake_parent_vm command=devvm update dir=/\S*/web vm=devvm-web-[0-9a-f]{14}$'
-- no.txt --
n