Files
devvm/testdata/script/nested_replaced.txtar
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

66 lines
2.7 KiB
Plaintext

# A nested project folder, a repo of its own inside a folder with a VM,
# replaced with a link after devvm found its VM, as the parent folder's
# VM could do through its mount: devvm never starts the nested VM on the
# link. Replaced once devvm restart's stop ends, devvm refuses before the
# start, its .git checks never run on the link's folder; replaced as Lima
# starts the VM, devvm stops it again and refuses. Put back, it starts.
# Each launch of the nested VM, its creation included, warns once that
# the parent folder's VM mounts it, running or not; the parent's own
# launch and devvm restart don't, and --clone there is refused, naming
# the parent's VM, without that warning.
env GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@t GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@t
mkdir $WORK/app/inner
mkdir $WORK/app/cloned
mkdir $WORK/decoy
cd $WORK/app
exec git init -q
exec devvm --network open
! stderr project_in_vm_folder
exec devvm stop
cd $WORK/app/inner
exec git init -q
exec devvm --network open
stdout '^==> creating_from image=base vm=devvm-inner-[0-9a-f]{14}$'
stderr -count=1 '^devvm: project_in_vm_folder dir=/\S*/app/inner vm=devvm-app-[0-9a-f]{14}$'
exec devvm
stderr -count=1 '^devvm: project_in_vm_folder dir=/\S*/app/inner vm=devvm-app-[0-9a-f]{14}$'
cd $WORK/app/cloned
exec git init -q
exec git commit -q --allow-empty -m init
! exec devvm --clone --network open
stderr '^devvm: clone_folder_mounted dir=/\S*/app/cloned vm=devvm-app-[0-9a-f]{14}$'
! stderr project_in_vm_folder
cd $WORK/app/inner
# Replaced once its stop ends: refused before the start.
exec sh -c 'echo "$WORK/app/inner $WORK/decoy" > "$STUB_DIR/stop-links"'
stub_reset
! exec devvm restart
stderr '^devvm: project_folder_changed dir=/\S*/app/inner vm=devvm-inner-[0-9a-f]{14}$'
! stderr project_in_vm_folder
stub_calls
stdout '^limactl stop devvm-inner-[0-9a-f]{14}$'
! stdout 'limactl start'
! stdout 'limactl shell'
! exists $WORK/decoy/.git
# Put back, then replaced as Lima starts it: stopped again, refused.
exec sh -c 'rm "$WORK/app/inner" && mv "$WORK/app/inner.real" "$WORK/app/inner"'
cd $WORK/app/inner
exec sh -c 'echo "$WORK/app/inner $WORK/decoy" > "$STUB_DIR/start-links"'
stub_reset
! exec devvm
stderr '^devvm: project_folder_changed_stopped dir=/\S*/app/inner vm=devvm-inner-[0-9a-f]{14}$'
stub_calls
stdout '^limactl start .*devvm-inner-[0-9a-f]{14}\n(limactl list --json\n)*limactl stop devvm-inner-[0-9a-f]{14}$'
! stdout 'limactl shell'
# Put back: it starts, and opens its shell.
exec sh -c 'rm "$WORK/app/inner" && mv "$WORK/app/inner.real" "$WORK/app/inner"'
cd $WORK/app/inner
stub_reset
exec devvm
stub_calls
stdout '^limactl start .*devvm-inner-[0-9a-f]{14}$'
stdout '^limactl shell --start=false --workdir /\S*/app/inner devvm-inner-[0-9a-f]{14}$'