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

92 lines
3.9 KiB
Plaintext

# devvm 0.1.0's state (testdata/v0.1.0/GOOS, which 0.1.0 itself made:
# see fixture_v010.txtar) after a boot that numbered the disks' devices
# anew, as macOS does: app's folder and .git are the ones 0.1.0
# recorded, on another device. Its VM starts, with nothing refused or
# called replaced, and its state records them on the device they're on
# now, with the folder's volume, which 0.1.0 didn't record
# (DEVVM_VOLUME stands in for diskutil). Then the folder moves, and the
# disks are numbered anew again: devvm in the folder at its new path
# finds app's VM by its volume, inode and birth time, and makes no
# second VM.
[!darwin] [!linux] skip 'a fixture for macOS and Linux only'
env GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@t GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@t
mkdir $HOME/src/db $HOME/src/app $HOME/src/web $HOME/src/scratch
cd $HOME/src/app
exec git init -q -b main
exec git commit -q --allow-empty -m one
fixture v0.1.0
vm_name APP app
renumber $APP_dir/vm.json
! grep folder_volume $APP_dir/vm.json
env DEVVM_VOLUME=uuid:EC5E5014-21A3-4154-ACE8-0C8C1C254852
stub_reset
exec devvm
stdout '^==> starting what=devvm-app-[0-9a-f]{14}$'
! stderr 'unreadable|corrupt|layout_|moved|replaced|refused|failed|other_folder|folder_changed'
stub_calls
stdout '^limactl start --tty=false devvm-app-[0-9a-f]{14}$'
stdout '^limactl shell --start=false --workdir \S*/home/src/app devvm-app-[0-9a-f]{14}$'
vm_state $APP_dir/vm.json
stdout '^folder='$FOLDER_ID'$'
stdout '^folder_volume=uuid:EC5E5014-21A3-4154-ACE8-0C8C1C254852:[0-9]+:[0-9]+\.[0-9]+$'
[darwin] stdout '^git\.made\.git_id='$GIT_ID'$'
[darwin] stdout '^git\.mode=on$'
# Renumbered at its own path, but on another volume than the one
# recorded, such as a copy of the disk mounted there: another folder,
# refused, and nothing recorded. On its own volume it's the folder again.
exec devvm stop
renumber $APP_dir/vm.json
cp $APP_dir/vm.json $WORK/renumbered.json
env DEVVM_VOLUME=uuid:11111111-1111-1111-1111-111111111111
stub_reset
! exec devvm --no-input
stderr '^devvm: vm_other_folder vm=devvm-app-[0-9a-f]{14} was=\S*/home/src/app$'
cmp $APP_dir/vm.json $WORK/renumbered.json
env DEVVM_VOLUME=uuid:EC5E5014-21A3-4154-ACE8-0C8C1C254852
exec devvm stop
# Renumbered while its volume can't be read: it starts, its new device
# recorded unchecked. Read on another volume then, it's another folder,
# refused, and nothing recorded; read on its own, the mark goes.
renumber $APP_dir/vm.json
env DEVVM_VOLUME=fail
exec devvm
! stderr 'other_folder|folder_changed|refused|failed'
vm_state $APP_dir/vm.json
stdout '^folder_unchecked=true$'
exec devvm stop
cp $APP_dir/vm.json $WORK/unchecked.json
env DEVVM_VOLUME=uuid:11111111-1111-1111-1111-111111111111
! exec devvm --no-input
stderr '^devvm: vm_other_folder vm=devvm-app-[0-9a-f]{14} was=\S*/home/src/app$'
cmp $APP_dir/vm.json $WORK/unchecked.json
env DEVVM_VOLUME=uuid:EC5E5014-21A3-4154-ACE8-0C8C1C254852
exec devvm
vm_state $APP_dir/vm.json
! stdout folder_unchecked
stdout '^folder_volume=uuid:EC5E5014-21A3-4154-ACE8-0C8C1C254852:[0-9]+:[0-9]+\.[0-9]+$'
exec devvm stop
# Moved, and renumbered again: devvm ls calls its old folder gone, by the
# volume the state records, and it's found by its volume, and offered,
# never a second VM. Without a terminal devvm refuses, naming devvm adopt.
[darwin] exec chflags -R nouchg $HOME/src/app/.git
exec mv $HOME/src/app $HOME/src/app-moved
renumber $APP_dir/vm.json
cd $HOME/src/app-moved
exec devvm ls --json
stdout '"folder": "\S*/home/src/app",\n\s*"folder_state": "gone"'
stub_reset
! exec devvm --no-input
stderr '^devvm: vm_moved_here vm=devvm-app-[0-9a-f]{14} was=\S*/home/src/app$'
stub_calls
! stdout 'limactl (create|clone)'
# On another volume it's another folder: it gets a VM of its own.
env DEVVM_VOLUME=uuid:00000000-0000-0000-0000-000000000000
stub_reset
exec devvm --no-input
! stderr vm_moved_here
stdout '^==> creating_from image=base vm=devvm-app-moved-[0-9a-f]{14}$'