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]>
206 lines
10 KiB
Plaintext
206 lines
10 KiB
Plaintext
# The shared tools: their versions resolved on first use (the stub mise
|
|
# resolves the fixture lock), built in a throwaway VM from base, moved into
|
|
# the share with their hashes, listed in a VM's state and sent to it.
|
|
env SHARE=$XDG_DATA_HOME/devvm/tools
|
|
project web
|
|
cp $WORK/package.json package.json
|
|
|
|
# An agent chosen in a node project goes with node: the VM's image is
|
|
# base, and its shared tools are a list in its state.
|
|
exec devvm --network open --no-git-protect --agents claude
|
|
stdout '^new_vm_toolchain_for file=package.json tool=node\nnew_vm_agent_from agent=claude from=--agents\nnew_vm_layers_none\n'
|
|
stdout '^==> resolving_tools$'
|
|
stdout '^==> building_tools tools=node 24\.21\.0, pnpm 12\.10\.1, bun 1\.4\.2, claude 2\.1\.295$'
|
|
stdout '^==> creating_from image=base vm=devvm-web-[0-9a-f]{14}$'
|
|
cmp $DATA/mise.lock $MISE_STUB_LOCK
|
|
exists $DATA/mise.lock.toml
|
|
exists $DATA/mise.lock.checked
|
|
stub_calls
|
|
stdout '^mise lock --platform linux-(arm64|x64),linux-(arm64|x64)-musl$'
|
|
# Each tool's build VM is a clone of base whose only mount is a folder of
|
|
# its own, never the share, uncached; it gets its one tool and version,
|
|
# and goes before the next tool's is made.
|
|
stdout '^limactl clone --tty=false --mount-none --set \.mounts = \[\{"location":"\S*/data/devvm/tools-build\.[0-9]+","mountPoint":"/mnt/devvm-tools","writable":true,"9p":\{"cache":"none"\}\}\] devvm-img-[0-9a-f]{12} devvm-tools-build$'
|
|
! stdout '"location":"\S*/data/devvm/tools","mountPoint":"/mnt/devvm-tools","writable":true'
|
|
stdout '^limactl shell --start=false --workdir / devvm-tools-build bash -s -- node 24\.21\.0 node-24\.21\.0-[0-9a-f]{12}\.erofs\n(.*\n)*limactl delete -f devvm-tools-build\n(.*\n)*limactl clone .* devvm-tools-build\n(.*\n)*limactl shell --start=false --workdir / devvm-tools-build bash -s -- pnpm \S+ pnpm-\S+\.erofs\n(.*\n)*limactl shell --start=false --workdir / devvm-tools-build bash -s -- bun 1\.4\.2 bun-1\.4\.2-[0-9a-f]{12}\.erofs\n(.*\n)*limactl shell --start=false --workdir / devvm-tools-build bash -s -- claude 2\.1\.295 claude-2\.1\.295-[0-9a-f]{12}\.erofs\n(.*\n)*limactl delete -f devvm-tools-build$'
|
|
exec sh -c 'grep -c "^limactl clone .* devvm-tools-build$" "$STUB_LOG"'
|
|
stdout '^4$'
|
|
stub_calls
|
|
# The VM is made from base's image, with the share read-only.
|
|
stdout '^limactl clone --tty=false devvm-img-[0-9a-f]{12} devvm-web-[0-9a-f]{14} --mount-none --set \.mounts = \[.*\{"location":"\S*/data/devvm/tools","mountPoint":"/mnt/devvm-tools","writable":false\}\]'
|
|
vm_name WEB web
|
|
vm_state $WEB_dir/vm.json
|
|
stdout '^image=base$'
|
|
stdout '^tools.names=node claude$'
|
|
stdout '^tools.made.libc=gnu$'
|
|
stdout '^backend_at=[0-9a-f]{16}$'
|
|
stdout '^tools.made.files=node-24\.21\.0-[0-9a-f]{12}\.erofs pnpm-\S+ bun-1\.4\.2-[0-9a-f]{12}\.erofs claude-2\.1\.295-[0-9a-f]{12}\.erofs$'
|
|
# Each image in the share with its record: its hash, what it's built for,
|
|
# the backend that built it, when, and the devvm that built it; nothing
|
|
# left of the build.
|
|
exec sh -c 'cd "$SHARE" && for f in *.erofs; do grep -qxF " \"sha256\": \"$({ sha256sum 2>/dev/null || shasum -a 256; } < "$f" | cut -c1-64)\"," "$f.json" || echo "bad $f"; grep -qxF " \"libc\": \"gnu\"," "$f.json" && grep -qxF " \"format\": \"\"," "$f.json" && grep -qxF " \"backend\": \"lima\"," "$f.json" || echo "bad target $f"; grep -qE "^ \"built\": \"[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9:]{8}Z\",$" "$f.json" || echo "bad time $f"; grep -qE "^ \"made_by\": \"[^\"]+\"$" "$f.json" || echo "bad made_by $f"; done; ls | wc -l'
|
|
! stdout bad
|
|
stdout '^ *8$'
|
|
! exists $SHARE/.lock
|
|
exec sh -c 'ls -d "$DATA"/tools-build.* 2>/dev/null || true'
|
|
! stdout .
|
|
# What the VM was sent: assets/guest/'s sync.sh and tools.sh, and its tool list.
|
|
exec tar -xOf $STUB_DIR/sync.tar tools
|
|
stdout '^node-24\.21\.0-[0-9a-f]{12}\.erofs node 24\.21\.0$'
|
|
stdout '^claude-2\.1\.295-[0-9a-f]{12}\.erofs claude 2\.1\.295$'
|
|
stdout -count=4 '\.erofs '
|
|
exec tar -tf $STUB_DIR/sync.tar
|
|
stdout '^sync\.sh$'
|
|
stdout '^tools\.sh$'
|
|
# The build's steps are numbered: clone, configure (its new ssh port),
|
|
# start, build.sh, delete, all five for each tool, in order, and each
|
|
# names the tool it builds, never the build VM's own name, which every
|
|
# tool's build shares.
|
|
catg $DATA/logs/runs/*.log
|
|
stdout '^# \[1/5\] cloning_for_tools tool=node 24\.21\.0\n(.*\n)*# \[2/5\] configuring what=the build VM for node 24\.21\.0\n(.*\n)*# \[3/5\] starting what=the build VM for node 24\.21\.0\n(.*\n)*# \[4/5\] building_tool tool=node 24\.21\.0\n(.*\n)*# \[5/5\] deleting what=the build VM for node 24\.21\.0\n(.*\n)*# \[1/5\] cloning_for_tools tool=pnpm '
|
|
stdout -count=4 '^# \[1/5\] cloning_for_tools tool=\S+ \S+$'
|
|
stdout -count=4 '^# \[2/5\] configuring what=the build VM for \S+ \S+$'
|
|
stdout -count=4 '^# \[3/5\] starting what=the build VM for \S+ \S+$'
|
|
stdout -count=4 '^# \[4/5\] building_tool tool=\S+ \S+$'
|
|
stdout -count=4 '^# \[5/5\] deleting what=the build VM for \S+ \S+$'
|
|
stdout '^# \[4/5\] building_tool tool=claude 2\.1\.295$'
|
|
! stdout '^# .*devvm-tools-build'
|
|
|
|
# Without a terminal, devvm tools lists the VM's tools; add and rm change
|
|
# its list and its tool files, built ones not built again.
|
|
stub_reset
|
|
exec devvm tools
|
|
stdout '^TOOL +VERSION +NEWER +BUILT$'
|
|
stdout '^claude +2\.1\.295 '
|
|
exec devvm tools rm claude
|
|
stdout '^==> vm_tools_now tools=node vm=devvm-web-[0-9a-f]{14}$'
|
|
vm_state $WEB_dir/vm.json
|
|
stdout '^tools.names=node$'
|
|
! stdout 'claude-'
|
|
exec devvm tools add claude
|
|
! stdout 'building_tools|resolving_tools'
|
|
stdout '^==> vm_tools_now tools=node claude vm=devvm-web-[0-9a-f]{14}$'
|
|
vm_state $WEB_dir/vm.json
|
|
stdout '^tools.names=node claude$'
|
|
stdout '^tools.made.files=.*claude-2\.1\.295-[0-9a-f]{12}\.erofs'
|
|
stub_calls
|
|
! stdout 'devvm-tools-build|mise'
|
|
|
|
# The daily check: a new VM with tools checks first when it's due.
|
|
exec touch -t 202001010000 $DATA/mise.lock.checked
|
|
project api
|
|
exec devvm --network open --no-git-protect --tools go
|
|
stdout '^==> checking_tools$'
|
|
stdout '^==> building_tools tools=go 1\.27\.2$'
|
|
# Not again today.
|
|
project cli
|
|
exec devvm --network open --no-git-protect --tools go --agents claude
|
|
! stdout 'checking_tools|building_tools'
|
|
|
|
# A .NET project's file calls for dotnet, named in the summary. Its build
|
|
# gets the lock's download for this VM's platform and its SHA-512 after
|
|
# its tool, version and file, which build.sh checks the SDK's archive
|
|
# against (mise's own installer for it checks nothing).
|
|
project shop
|
|
cp $WORK/Shop.csproj Shop.csproj
|
|
stub_reset
|
|
exec devvm --network open --no-git-protect
|
|
stdout '^new_vm_toolchain_for file=Shop\.csproj tool=dotnet$'
|
|
stdout '^==> building_tools tools=dotnet 10\.0\.401$'
|
|
vm_name SHOP shop
|
|
vm_state $SHOP_dir/vm.json
|
|
stdout '^tools.names=dotnet$'
|
|
stdout '^tools.made.files=dotnet-10\.0\.401-[0-9a-f]{12}\.erofs$'
|
|
stub_calls
|
|
stdout '^limactl shell --start=false --workdir / devvm-tools-build bash -s -- dotnet 10\.0\.401 dotnet-10\.0\.401-[0-9a-f]{12}\.erofs https://builds\.dotnet\.microsoft\.com/dotnet/Sdk/10\.0\.401/dotnet-sdk-10\.0\.401-linux-(arm64|x64)\.tar\.gz [0-9a-f]{128}$'
|
|
# global.json alone calls for it too.
|
|
project sdk
|
|
cp $WORK/global.json global.json
|
|
exec devvm --network open --no-git-protect
|
|
stdout '^new_vm_toolchain_for file=global\.json tool=dotnet$'
|
|
! stdout 'building_tools'
|
|
|
|
# The shared tools aren't images: build and rebuild refuse them.
|
|
! exec devvm rebuild node
|
|
stderr '^devvm: tool_not_layer tool=node$'
|
|
|
|
# The daily check's job, run by hand: a failure leaves the lock.
|
|
env MISE_STUB_FAIL=1
|
|
! exec devvm _refresh-tools
|
|
stderr 'failed to fetch versions: offline'
|
|
stderr '^devvm: tools_resolve_failed$'
|
|
cmp $DATA/mise.lock $MISE_STUB_LOCK
|
|
env MISE_STUB_FAIL=
|
|
exec devvm _refresh-tools
|
|
exec devvm --help
|
|
! stdout _refresh-tools
|
|
|
|
# Offline with no lock yet: what's needed, and mise's error from the log.
|
|
rm $DATA/mise.lock
|
|
env MISE_STUB_FAIL=1
|
|
project py
|
|
! exec devvm --network open --no-git-protect --tools python
|
|
stdout '^==> resolving_tools$'
|
|
stderr 'failed to fetch versions: offline'
|
|
stderr '^devvm: tools_need_resolve$'
|
|
! exists $DATA/mise.lock
|
|
env MISE_STUB_FAIL=
|
|
|
|
# A build that leaves a symlink instead of an image is refused; one that
|
|
# plants FILE.json as a symlink can't make devvm write through it.
|
|
exec sh -c 'echo victim > "$STUB_DIR/tools-symlink"'
|
|
! exec devvm --network open --no-git-protect --tools python
|
|
stderr '^devvm: tool_bad_output file=python-\S+\.erofs$'
|
|
exec sh -c 'ls "$SHARE"'
|
|
! stdout python
|
|
exec sh -c 'rm "$STUB_DIR/tools-symlink" && echo victim > "$STUB_DIR/tools-hash-symlink"'
|
|
exec devvm --network open --no-git-protect --tools python
|
|
exec cat $STUB_DIR/tools-hash-symlink
|
|
stdout '^victim$'
|
|
exec sh -c 'cd "$SHARE" && for f in python-*.erofs uv-*.erofs; do [ -L "$f.json" ] && echo link; done; true'
|
|
! stdout link
|
|
|
|
# build.sh's wait for its output folder (assets/shared-tools/build.sh's
|
|
# wait_share): there at once, it goes on without mounting; mounted late, it
|
|
# mounts it again from fstab and goes on; never there, it fails after 60
|
|
# tries, naming the folder and mount's error.
|
|
cd $WORK
|
|
exec bash wait-share-test.sh $DEVVM_REPO/assets/shared-tools/build.sh
|
|
cmp stdout wait-share.want
|
|
stderr '^build\.sh: devvm''s output folder isn''t mounted at \S+/share \(no \.build/mise\.lock after 60 s\): mount: \S+/share: unknown filesystem type ''9p''\.$'
|
|
|
|
-- wait-share-test.sh --
|
|
awk '/^wait_share\(\) \{/ { on = 1 } on { print } on && /^\}$/ { exit }' "$1" > wait.sh
|
|
[[ -s wait.sh ]] || { echo "no wait_share in $1" >&2; exit 1; }
|
|
. wait.sh
|
|
share=$PWD/share tries=0
|
|
mkdir -p "$share/.build"
|
|
mountpoint() { return 1; }
|
|
sleep() { tries=$((tries + 1)); }
|
|
sudo() {
|
|
echo "$*" >> calls
|
|
[[ -e late ]] || { echo "mount: $share: unknown filesystem type '9p'." >&2; return 32; }
|
|
touch "$share/.build/mise.lock"
|
|
}
|
|
touch "$share/.build/mise.lock" calls
|
|
wait_share && echo "there: $tries, $(wc -l < calls | tr -d ' ') mounts"
|
|
rm "$share/.build/mise.lock"; touch late
|
|
wait_share && echo "late: $tries, $(sed "s|$PWD|.|" calls)"
|
|
rm "$share/.build/mise.lock" late calls; tries=0
|
|
wait_share || echo "never: $tries, $(wc -l < calls | tr -d ' ') mounts"
|
|
-- wait-share.want --
|
|
there: 0, 0 mounts
|
|
late: 1, mount ./share
|
|
never: 60, 60 mounts
|
|
-- package.json --
|
|
{}
|
|
-- Shop.csproj --
|
|
<Project Sdk="Microsoft.NET.Sdk">
|
|
<PropertyGroup>
|
|
<OutputType>Exe</OutputType>
|
|
<TargetFramework>net10.0</TargetFramework>
|
|
</PropertyGroup>
|
|
</Project>
|
|
-- global.json --
|
|
{ "sdk": { "version": "10.0.401" } }
|