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]>
146 lines
5.2 KiB
Plaintext
146 lines
5.2 KiB
Plaintext
# devvm in a subfolder of a folder with a VM: it opens that VM in the
|
|
# subfolder, saying so; --here and --clone make the subfolder its own;
|
|
# stop acts on the parent's VM, naming it first; rm refuses it without a
|
|
# terminal. adopt doesn't look upward, and nothing does from a repo of
|
|
# its own below the parent's folder unless --parent. Commands that give
|
|
# the parent's VM more access are refused without a terminal.
|
|
mkdir $WORK/app/src/lib
|
|
cd $WORK/app
|
|
exec git init -q
|
|
exec devvm --network open
|
|
|
|
# The parent's VM, its shell in the subfolder.
|
|
cd $WORK/app/src/lib
|
|
stub_reset
|
|
exec devvm
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
! stdout creating
|
|
stub_calls
|
|
! stdout 'limactl (clone|create)'
|
|
stdout '^limactl shell --start=false --workdir /\S*/app/src/lib devvm-app-[0-9a-f]{14}\n\z'
|
|
exec sh -c 'ls "$VMS" | wc -l'
|
|
stdout '^ *1$'
|
|
|
|
# adopt is for this path's VM only.
|
|
! exec devvm adopt
|
|
stderr '^devvm: no_vm dir=/\S*/app/src/lib$'
|
|
|
|
# stop: the parent's, named first.
|
|
stub_reset
|
|
exec devvm stop
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}\n==> stopped vm=devvm-app-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^limactl stop devvm-app-[0-9a-f]{14}$'
|
|
|
|
# --here: a new VM for the subfolder, nothing asked; then it's the
|
|
# subfolder's own.
|
|
cd $WORK/app/src
|
|
exec devvm --here --network open
|
|
stdout '^==> creating_from image=base vm=devvm-src-[0-9a-f]{14}$'
|
|
! stdout using_parent_vm
|
|
stub_reset
|
|
exec devvm
|
|
! stdout using_parent_vm
|
|
stub_calls
|
|
stdout '^limactl shell --start=false --workdir /\S*/app/src devvm-src-[0-9a-f]{14}\n\z'
|
|
|
|
# The nearest folder with a VM wins.
|
|
cd $WORK/app/src/lib
|
|
exec devvm stop
|
|
stdout '^==> using_parent_vm dir=/\S*/app/src vm=devvm-src-[0-9a-f]{14}$'
|
|
|
|
# A repo of its own below the parent's folder: other commands find no VM,
|
|
# and devvm makes the subfolder's own. --parent takes the parent's
|
|
# across the repo.
|
|
mkdir $WORK/app/tool/bin
|
|
cd $WORK/app/tool
|
|
exec git init -q
|
|
cd $WORK/app/tool/bin
|
|
! exec devvm stop
|
|
stderr '^devvm: no_vm dir=/\S*/app/tool/bin$'
|
|
! stdout using_parent_vm
|
|
stub_reset
|
|
exec devvm --parent
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^limactl shell --start=false --workdir /\S*/app/tool/bin devvm-app-[0-9a-f]{14}\n\z'
|
|
exec devvm stop --parent
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}\n==> stopped vm=devvm-app-[0-9a-f]{14}$'
|
|
exec devvm --network open
|
|
stdout '^==> creating_from image=base vm=devvm-bin-[0-9a-f]{14}$'
|
|
! stdout using_parent_vm
|
|
|
|
# Once it has its own: --parent passes over it, --here keeps to it, and
|
|
# the two don't go together.
|
|
exec devvm stop --parent
|
|
stdout '^==> already_stopped vm=devvm-app-[0-9a-f]{14}$'
|
|
exec devvm stop --here
|
|
! stdout using_parent_vm
|
|
stdout '^==> stopped vm=devvm-bin-[0-9a-f]{14}$'
|
|
! exec devvm stop --here --parent
|
|
stderr '^devvm: flags_exclusive flag=--here other=--parent$'
|
|
! exec devvm --clone --parent
|
|
stderr '^devvm: flags_exclusive flag=--clone other=--parent$'
|
|
! exec devvm rm devvm-bin-0123456789abcd --here
|
|
stderr '^devvm: rm_vm_folder_flag flag=--here$'
|
|
exec devvm rm --force --no-export
|
|
|
|
# --parent where no folder above has a VM.
|
|
cd $WORK/app
|
|
! exec devvm stop --parent
|
|
stderr '^devvm: no_parent_vm dir=/\S*/app$'
|
|
|
|
# --clone: the subfolder's own repo's VM, as --here, never the parent's.
|
|
mkdir $WORK/app/repo
|
|
cd $WORK/app/repo
|
|
env GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@t GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@t
|
|
exec git init -q -b main
|
|
exec git commit -q --allow-empty -m one
|
|
# The parent's VM mounts the repo, so its seed's host git could be swapped
|
|
# from there: refused before anything is made, naming that VM.
|
|
! exec devvm --clone --network open
|
|
stderr '^devvm: clone_folder_mounted dir=/\S*/app/repo vm=devvm-app-[0-9a-f]{14}$'
|
|
! stdout 'using_parent_vm|creating_from'
|
|
|
|
# rm: never a parent's without asking. Without a terminal it's refused,
|
|
# --force or not, and nothing is deleted; in the parent's folder it goes.
|
|
cd $WORK/app/src
|
|
exec devvm rm --force
|
|
cd $WORK/app/src/lib
|
|
|
|
# Commands that give a parent's VM more access are refused without a
|
|
# terminal, naming the VM and its folder, and change nothing.
|
|
! exec devvm secret use github
|
|
stderr '^devvm: widen_parent_vm_refused cmd=devvm secret use dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
! exec devvm ssh-agent on
|
|
stderr '^devvm: widen_parent_vm_refused cmd=devvm ssh-agent on dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
exec devvm ssh-agent
|
|
stdout '^off$'
|
|
! exec devvm network allow example.com
|
|
stderr '^devvm: widen_parent_vm_refused cmd=devvm network allow dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
exec devvm network deny bad.example.com
|
|
stdout 'rule_added'
|
|
! exec devvm network rm '!bad.example.com'
|
|
stderr '^devvm: widen_parent_vm_refused cmd=devvm network rm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
vm_name APP app
|
|
exec cat $APP_dir/policy
|
|
stdout '!bad.example.com'
|
|
! stdout '^example.com'
|
|
|
|
stub_reset
|
|
! exec devvm rm --force --no-export
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
stderr '^devvm: rm_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl delete'
|
|
exec sh -c 'ls "$VMS" | grep -v "\.policy$" | wc -l'
|
|
stdout '^ *1$'
|
|
cd $WORK/app
|
|
exec devvm rm --force
|
|
stdout '^==> deleted vm=devvm-app-[0-9a-f]{14}$'
|
|
exec ls $VMS
|
|
! stdout .
|
|
cd $WORK/app/src/lib
|
|
! exec devvm rm --force
|
|
stderr '^devvm: no_vm dir=/\S*/app/src/lib$'
|