mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
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]>
85 lines
2.9 KiB
Plaintext
85 lines
2.9 KiB
Plaintext
# A moved or renamed project folder keeps its VM, only after a yes in a
|
|
# terminal or devvm adopt --force: without either every command on the
|
|
# folder's VM refuses, naming devvm adopt. Once moved, the VM is found by
|
|
# the folder its state records, from the new path alone, and its next
|
|
# start mounts the folder there. devvm adopt VM moves a VM whose folder
|
|
# is gone to a copy of it, which is never offered on its own.
|
|
project web
|
|
exec devvm --network open
|
|
vm_name WEB web
|
|
exec devvm stop
|
|
cd $WORK
|
|
mv web site
|
|
cd site
|
|
|
|
# Without a terminal: refused, nothing changed.
|
|
stub_reset
|
|
! exec devvm
|
|
stderr '^devvm: vm_moved_here vm=devvm-web-[0-9a-f]{14} was=/\S*/web$'
|
|
! exec devvm stop
|
|
stderr '^devvm: vm_moved_here vm=devvm-web-[0-9a-f]{14} was=/\S*/web$'
|
|
stub_calls
|
|
! stdout 'limactl (start|stop|edit|clone|delete)'
|
|
vm_state $WEB_dir/vm.json
|
|
stdout '^dir=/\S*/web$'
|
|
|
|
# A no in a terminal: the folder has no VM.
|
|
ttyin -stdin $WORK/no.txt
|
|
! exec devvm stop
|
|
stderr '^move_vm vm=devvm-web-[0-9a-f]{14} was=/\S*/web \[y/N\] devvm: no_vm dir=/\S*/site$'
|
|
vm_state $WEB_dir/vm.json
|
|
stdout '^dir=/\S*/web$'
|
|
|
|
# A yes: the VM's state records this folder.
|
|
ttyin -stdin $WORK/yes.txt
|
|
exec devvm stop
|
|
stdout '==> vm_adopted dir=/\S*/site vm=devvm-web-[0-9a-f]{14}$'
|
|
stdout '==> already_stopped vm=devvm-web-[0-9a-f]{14}$'
|
|
vm_state $WEB_dir/vm.json
|
|
stdout '^dir=/\S*/site$'
|
|
grep '"moved": \{\s*"from": "/\S*/web"\s*\}' $WEB_dir/vm.json
|
|
|
|
# Found by that folder from then on, asking nothing; its start mounts the
|
|
# folder where it is now, in the one edit, and its setup moves the agents'
|
|
# state from the old path, clearing the record.
|
|
stub_reset
|
|
exec devvm
|
|
! stderr 'vm_moved_here|move_vm'
|
|
stub_calls
|
|
[darwin] stdout '^limactl edit --tty=false devvm-web-[0-9a-f]{14} --set \.mounts = \[\{"location":"/\S*/site","writable":true\}'
|
|
[linux] stdout '^limactl edit --tty=false devvm-web-[0-9a-f]{14} --set \.mounts = \[\{"location":"/\S*/site","writable":true,"9p":\{"cache":"none"\}\}'
|
|
stdout '^limactl shell --start=false --workdir /\S*/site devvm-web-[0-9a-f]{14}\n\z'
|
|
exec tar -xOf $STUB_DIR/sync.tar moved
|
|
stdout '^moved_from=''/\S*/web''\nmoved_to=''/\S*/site''\nclaude_from=''-\S*-web''\nclaude_to=''-\S*-site''\n\z'
|
|
! grep '"moved"' $WEB_dir/vm.json
|
|
exec devvm ls --json
|
|
stdout '"folder": "/\S*/site",'
|
|
|
|
# A new folder at the old path gets a VM of its own, by another name.
|
|
cd $WORK
|
|
mkdir web
|
|
cd web
|
|
exec devvm --network open
|
|
exec devvm ls
|
|
stdout -count=2 '^devvm-web-[0-9a-f]{14} '
|
|
|
|
# devvm adopt VM: a copy of the folder, as on another disk, is another
|
|
# folder, never offered; adopt moves the VM there once its folder is gone.
|
|
cd $WORK
|
|
exec cp -R site copy
|
|
cd copy
|
|
! exec devvm stop
|
|
stderr '^devvm: no_vm dir=/\S*/copy$'
|
|
! exec devvm adopt $WEB --force
|
|
stderr '^devvm: adopt_folder_there dir=/\S*/site vm=devvm-web-[0-9a-f]{14}$'
|
|
rm $WORK/site
|
|
exec devvm adopt $WEB --force
|
|
stdout '==> vm_adopted dir=/\S*/copy vm=devvm-web-[0-9a-f]{14}$'
|
|
vm_state $WEB_dir/vm.json
|
|
stdout '^dir=/\S*/copy$'
|
|
|
|
-- yes.txt --
|
|
y
|
|
-- no.txt --
|
|
n
|