refactor(backend): remove the smolvm backend

Lima is devvm's only backend. The backend architecture stays (Backend,
Caps, Features, Review/Require, the registry, backendtest.Fake), so
another backend is an addition.

State from a smolvm VM reads as an unknown backend (backend_unknown_vm,
gc_orphans_unknown); nothing migrates it. The image keys of
layers/docker.sh, layers/nix.sh and features/desktop.sh change, so images
rebuild once.

Lima's port forwarder moves off smolvm's files first: newForwarderCmd and
forwarderMain from internal/cli/smolvmports.go to limaports.go, and
assets/container/ports.sh to assets/guest/ports.sh (sent by the forwarder
at run time, so no image key changes).

Removed:
- internal/backend/smolvm (4,070 lines with tests), _smolvm-ports, its
  registry entry, registry.Experimental and backend_experimental.
- The decider: backend.Decider/UsesDecider, Confinement.Decider and
  DeciderToken, internal/proxy/decider.go and its test, the proxy's
  -decider, -decider-to and -decider-token-file, netpolicy's
  KeyDeciderPort, KeyDeciderToken and deciderToken, the decider port in
  vm's forwarding and UsedPorts.
- backend.AgentStarter/AgentUnchosen, vm's checkAgentStart and
  agent_unchosen_stop.
- vmssh/key.go (EnsureKey, Public, HostKey, ServicesArgs, Capped).
- paths.Smolvm/SmolvmImage and space's smolvm folders; paths.VM's
  Record, Key, KnownHosts and ProxyURL; project.Detect, which nothing
  called (a test helper now).
- ubuntu.ContainerRepo/ContainerDigest/ContainerRef/ContainerOrigin and
  bump.sh's ubuntu_image, with its part of bump.txtar.
- assets/smolvm/ and assets/container/; the no-init-system branches of
  layers/docker.sh, layers/nix.sh and guest/sync.sh, and the notes in
  features/desktop.sh and guest/ca.sh.
- Messages: smolvm_* (14), vm_no_ssh, vm_no_sshd, ports_no_ssh,
  creating_from_image, packing_image, pack_failed, backend_experimental,
  agent_unchosen_stop; descriptions naming smolvm reworded.
- Tests: smolvm.txtar, the smolvm stub, registry, decider, netpolicy and
  sshagent cases; gc_backend, gc_skipped, gc_orphans and space test a
  failing or hanging Lima listing instead (the limactl stub's list-fails
  and list-hangs); the --backend smolvm examples; e2e's --backend smolvm
  and its section (about 1,130 lines), the smol_* helpers and the
  link section's backend switch.
- Coverage: internal/backend/smolvm's lines in both baselines.
- Docs: backends/smolvm.md, internals/smolvm.md, design.md's smolvm
  notes (Ports on Lima now holds the forwarder's description), the
  backends table's smolvm column, every page naming smolvm, the README,
  the home page's backends art, and AGENTS.md's smolvm rows and gotchas
  (and the Docker bind-mount gotcha, which nothing refers to).

Kept: the docker layer, on Lima; --from's local Docker; --backend, the
BACKEND column and setup's backend choice, which the next commit removes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
w3cjandClaude Opus 5.5 committed 2026-11-03 11:34:05 -07:00
1 parent 50b4e796b7
commit f4fd373439
162 files changed
+590 -8375

No files matched your search

-1
View File
@@ -5,7 +5,6 @@ internal/backend 95.9
internal/backend/backendtest 46.3
internal/backend/lima 88.5
internal/backend/registry 92.0
internal/backend/smolvm 73.9
internal/backend/vmssh 87.5
internal/build 87.5
internal/cli 88.4
-1
View File
@@ -5,7 +5,6 @@ internal/backend 95.7
internal/backend/backendtest 46.3
internal/backend/lima 87.6
internal/backend/registry 90.5
internal/backend/smolvm 73.2
internal/backend/vmssh 87.5
internal/build 87.3
internal/cli 88.2
+5 -44
View File
@@ -19,17 +19,13 @@ cmp stdout mise-base.want
exec grep -E 'miseVersion =|"(macos|linux)-' repo/internal/tools/mise.go
cmp stdout mise-go.want
# apt moves base's snapshot to today, Ubuntu's container image to the
# digest of the index the registry sent, built before the snapshot, and
# Ubuntu's cloud image to the newest dated release before the snapshot, with
# the checksums of its SHA256SUMS, checked with gpgv against Ubuntu's key.
# apt moves base's snapshot to today, and Ubuntu's cloud image to the
# newest dated release before the snapshot, with the checksums of its
# SHA256SUMS, checked with gpgv against Ubuntu's key.
exec repo/scripts/bump.sh apt
stdout '^ ubuntu +19fcd1bf268f +-> 8186ab583383$'
stdout '^ ubuntu-cloud +release-[0-9]{8} +-> release-20000101$'
exec grep '^apt_snapshot=' repo/assets/layers/base.sh
stdout '^apt_snapshot=[0-9]{8}T000000Z$'
exec grep '^const ContainerDigest = ' repo/internal/ubuntu/ubuntu.go
stdout '^const ContainerDigest = "sha256:8186ab5833835533fd62c92e6a51bb4e3a194c74406f64f10befc8a7cd388c91"$'
exec grep '^const Cloud' repo/internal/ubuntu/ubuntu.go
cmp stdout cloud.want
stub_calls
@@ -62,23 +58,6 @@ stderr '^bump: upstream gave cloud_sha256_amd64 an unexpected value: '''''
cmp repo/internal/ubuntu/ubuntu.go ubuntu.before
! exists pwned
# An image built after the snapshot, or one whose build time isn't one, is
# refused, and nothing is edited.
exec bash repo.sh
cp repo/assets/layers/base.sh base.before
cp repo/internal/ubuntu/ubuntu.go ubuntu.before
cp ubuntu-future up/ubuntu-amd64
! exec repo/scripts/bump.sh apt
stderr '^bump: Ubuntu''s image was built at 29990101T000000Z, after today''s snapshot '
cmp repo/assets/layers/base.sh base.before
cmp repo/internal/ubuntu/ubuntu.go ubuntu.before
cp ubuntu-hostile up/ubuntu-amd64
! exec repo/scripts/bump.sh apt
stderr '^bump: upstream gave ubuntu_built an unexpected value: '
cmp repo/assets/layers/base.sh base.before
cmp repo/internal/ubuntu/ubuntu.go ubuntu.before
! exists pwned
# Upstream values that aren't a version or a checksum are refused, and
# nothing is edited: a command for a checksum, one in a version, and a
# missing asset (an empty checksum).
@@ -133,25 +112,17 @@ cp latest-good up/crane-latest
cp sums-good up/crane-sums
cp mise-latest up/mise-latest
cp mise-sums up/mise-sums
cp ubuntu-index up/ubuntu-index
cp ubuntu-arm64 up/ubuntu-arm64
cp ubuntu-amd64 up/ubuntu-amd64
cp cloud-listing up/cloud-listing
cp cloud-sums up/cloud-sums
-- bin/curl --
#!/bin/bash
# Answers crane's and mise's releases and Ubuntu's container image and
# cloud image release (release-20000101 only) from $WORK/up/; anything else
# fails.
# Answers crane's and mise's releases and Ubuntu's cloud image release
# (release-20000101 only) from $WORK/up/; anything else fails.
for a in "$@"; do case $a in
*/go-containerregistry/releases/latest) cat "$WORK/up/crane-latest"; exit ;;
*/go-containerregistry/*/checksums.txt) cat "$WORK/up/crane-sums"; exit ;;
*/jdx/mise/releases/latest) cat "$WORK/up/mise-latest"; exit ;;
*/jdx/mise/*/SHASUMS256.txt) cat "$WORK/up/mise-sums"; exit ;;
https://auth.docker.io/token*) echo '{"token":"t"}'; exit ;;
*/library/ubuntu/manifests/26.04) cat "$WORK/up/ubuntu-index"; exit ;;
*/library/ubuntu/manifests/sha256:aaaa*) cat "$WORK/up/ubuntu-arm64"; exit ;;
*/library/ubuntu/manifests/sha256:bbbb*) cat "$WORK/up/ubuntu-amd64"; exit ;;
https://cloud-images.ubuntu.com/releases/resolute/) cat "$WORK/up/cloud-listing"; exit ;;
*/resolute/release-20000101/SHA256SUMS) cat "$WORK/up/cloud-sums"; exit ;;
*/resolute/release-20000101/SHA256SUMS.gpg) echo signature; exit ;;
@@ -176,16 +147,6 @@ cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc *ubuntu-26.04-s
const CloudRelease = "release-20000101"
const CloudSHA256Arm64 = "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
const CloudSHA256Amd64 = "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
-- ubuntu-index --
{"manifests":[{"digest":"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","platform":{"architecture":"arm64","os":"linux"}},{"digest":"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","platform":{"architecture":"amd64","os":"linux"}}]}
-- ubuntu-arm64 --
{"annotations":{"org.opencontainers.image.created":"2000-01-02T03:04:05.309136+00:00"}}
-- ubuntu-amd64 --
{"annotations":{"org.opencontainers.image.created":"2000-01-02T03:04:06Z"}}
-- ubuntu-future --
{"annotations":{"org.opencontainers.image.created":"2999-01-01T00:00:00Z"}}
-- ubuntu-hostile --
{"annotations":{"org.opencontainers.image.created":"$(touch pwned)"}}
-- latest-good --
{"tag_name":"v9.9.9"}
-- latest-hostile --
+11 -11
View File
@@ -11,14 +11,14 @@ chmod 0755 qemu/qemu-img
# Everything there: only limactl --version runs.
exec devvm doctor
stdout '^FEATURE +LIMA +SMOLVM\n'
stdout '^build-image +native +native\n'
stdout '^egress-proxy +native +emulated\n'
stdout '^ports +emulated +emulated\n'
stdout '^ports-all +emulated +emulated\n'
stdout '^agent-toggle +native +emulated\n'
stdout '^disk +native +native\n'
stdout '^docker-layer +native +native\n'
stdout '^FEATURE +LIMA\n'
stdout '^build-image +native\n'
stdout '^egress-proxy +native\n'
stdout '^ports +emulated\n'
stdout '^ports-all +emulated\n'
stdout '^agent-toggle +native\n'
stdout '^disk +native\n'
stdout '^docker-layer +native\n'
stdout '^docker_found\n'
stdout '^doctor_ok backend=lima version=\S+\n\z'
! stderr .
@@ -26,7 +26,7 @@ stub_calls
stdout '^limactl --version\n\z'
exec devvm doctor --json
stdout '^{\n "version": 1,\n "backend": "lima",\n "backend_source": "built-in",\n "problems": \[\],\n "warnings": \[\],\n "docker": true,\n'
stdout '^ "egress-proxy": "emulated",$'
stdout '^ "ports": "emulated",$'
! stderr .
# Where the backend came from: a file that sets it is named, and --json
@@ -45,14 +45,14 @@ rm $CFG/config.toml
# Another backend, or one devvm doesn't have.
! exec devvm doctor --backend nope
stderr '^devvm: backend_unknown backends=lima, smolvm name=nope$'
stderr '^devvm: backend_unknown backends=lima name=nope$'
! stdout .
# No Lima, no Homebrew, no Docker: what to install, and it fails.
# QEMU's there, which only Linux checks.
env PATH=$WORK/qemu${:}$DEVVM_BIN
! exec devvm doctor
stdout '^FEATURE +LIMA +SMOLVM\n'
stdout '^FEATURE +LIMA\n'
stdout '^docker_missing\n'
! stdout doctor_ok
stderr '^devvm: lima_missing$'
+15 -28
View File
@@ -1,56 +1,43 @@
# gc --backend: one backend's images, current ones too, and its unused
# tool images, and nothing else; plain gc acts on every backend whatever
# the default backend file says. Never a VM.
# tool images, and nothing else. Never a VM.
env SHARE=$XDG_DATA_HOME/devvm/tools
env PACKS=$XDG_DATA_HOME/devvm/smolvm/images
env PIN=ubuntu:26.04@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# base on each backend; on Lima also foo, made stale.
# base and foo on Lima, foo made stale.
mkdir $XDG_CONFIG_HOME/devvm/layers
cp foo.sh $XDG_CONFIG_HOME/devvm/layers/foo.sh
exec devvm build foo
exec devvm --backend smolvm --from $PIN build base
exec sh -c 'echo "# edited" >> "$XDG_CONFIG_HOME/devvm/layers/foo.sh"'
# Unused tool images: one recorded as smolvm's, one as Lima's, one
# nobody can tell; claude's build, for a VM that's gone since, makes the
# lock, so they're unused.
# Unused tool images: one recorded as Lima's, one nobody can tell;
# claude's build, for a VM that's gone since, makes the lock, so they're
# unused.
project ag
exec devvm --tools none --agents claude --no-network-policy --no-git-protect
exec devvm rm --force --no-export
exec sh -c 'cd "$SHARE" && for v in 1.1.0 1.2.0 1.3.0; do echo x > go-$v-0123456789ab.erofs; done'
json_set $SHARE/go-1.1.0-0123456789ab.erofs.json sha256=x libc=gnu format=plain-0123456789ab backend=smolvm built=2020-01-01T00:00:00Z
exec sh -c 'cd "$SHARE" && for v in 1.2.0 1.3.0; do echo x > go-$v-0123456789ab.erofs; done'
json_set $SHARE/go-1.2.0-0123456789ab.erofs.json sha256=x libc=gnu backend=lima built=2020-01-01T00:00:00Z
# The default backend is smolvm: plain gc still acts on Lima.
exec devvm setup --backend smolvm
# Plain gc: the stale image and the unused tool images.
stub_reset
exec devvm gc --force
stdout '^gc_image image=foo key=[0-9a-f]{12}$'
stdout '^gc_tools count=3 '
stdout '^gc_tools count=2 '
! stdout 'image=base'
exists $PACKS
# Again for smolvm alone: its base, current, and nothing of Lima's; a
# smolvm tool image would go (none is left).
exec sh -c 'cd "$SHARE" && echo x > go-1.1.0-0123456789ab.erofs && echo x > go-1.2.0-0123456789ab.erofs'
json_set $SHARE/go-1.1.0-0123456789ab.erofs.json sha256=x libc=gnu format=plain-0123456789ab backend=smolvm built=2020-01-01T00:00:00Z
# Again for Lima alone: its base, current, and its own tool image, not
# one whose backend nobody can tell.
exec sh -c 'cd "$SHARE" && echo x > go-1.2.0-0123456789ab.erofs && echo x > go-1.3.0-0123456789ab.erofs'
json_set $SHARE/go-1.2.0-0123456789ab.erofs.json sha256=x libc=gnu backend=lima built=2020-01-01T00:00:00Z
stub_reset
exec devvm gc --backend smolvm --force
exec devvm gc --backend lima --force
stdout '^gc_image image=base key=[0-9a-f]{12}$'
stdout -count=1 '^gc_image '
stdout '^gc_tools count=1 '
! stdout gc_mise
exec sh -c 'ls "$PACKS" | wc -l'
stdout '^ *0$'
exists $SHARE/go-1.2.0-0123456789ab.erofs
! exists $SHARE/go-1.1.0-0123456789ab.erofs
stub_calls
! stdout '^limactl delete'
! exists $SHARE/go-1.2.0-0123456789ab.erofs
exists $SHARE/go-1.3.0-0123456789ab.erofs
exec devvm images
stdout '^base +ubuntu 26\.04 .* +current +\S+ +lima$'
! stdout ' smolvm$'
! stdout '^base .* current '
# An unknown backend is refused.
! exec devvm --backend nope gc
+12 -16
View File
@@ -5,7 +5,7 @@
# be being made). Never part of gc's default run.
# Each VM's folder is its name's last 14 characters.
mkdir $VMS/12345612345601 $VMS/12345612345602 $VMS/12345612345603 $VMS/12345612345604 $VMS/12345612345605 $VMS/12345612345607 $VMS/12345612345608
mkdir $VMS/12345612345601 $VMS/12345612345602 $VMS/12345612345603 $VMS/12345612345604 $VMS/12345612345605 $VMS/12345612345607
# This run's Lima home, as a VM's state records it.
exec sh -c 'printf %s "$DEVVM_LIMA_HOME" | { sha256sum 2>/dev/null || shasum -a 256; } | cut -c1-16 > at'
# A Lima VM that exists, and one limactl deleted, with its logs, run and
@@ -19,9 +19,8 @@ exec sh -c 'printf "name=devvm-norec-12345612345605\nimage=base\ndir=/p/norec\nb
exec sh -c 'cd "$VMS" && for h in 12345612345601 12345612345602; do mkdir $h/logs $h/run $h/backend && echo x > $h/logs/network.jsonl && echo x > $h/run/sandbox.sb && echo x > $h/backend/ports; done'
exec sh -c 'cd "$VMS" && touch -t 202001010000 12345612345601/state 12345612345602/state 12345612345604/state 12345612345605/state'
# A VM of a backend this devvm doesn't have (a newer devvm's), which
# can't be asked; a smolvm VM whose machine is gone.
# can't be asked.
exec sh -c 'printf "name=devvm-other-12345612345607\nimage=base\ndir=/p/other\nbackend=nope\nnet=off\n" > "$VMS/12345612345607/state" && touch -t 202001010000 "$VMS/12345612345607/state"'
exec sh -c 'printf "name=devvm-smol-12345612345608\nimage=base\ndir=/p/smol\nbackend=smolvm\nnet=off\n" > "$VMS/12345612345608/state" && touch -t 202001010000 "$VMS/12345612345608/state"'
# The default run leaves them.
exec devvm gc --force
@@ -29,15 +28,13 @@ exists $VMS/12345612345602/state
stub_reset
exec devvm gc --force --orphans
stdout '^gc_orphans count=2$'
stdout '^gc_orphans count=1$'
stdout '^gc_orphan backend=lima dir=/p/gone vm=devvm-gone-12345612345602$'
stdout '^gc_orphan backend=smolvm dir=/p/smol vm=devvm-smol-12345612345608$'
stderr '^gc_orphans_unknown backend=nope$'
stderr '^gc_orphan_elsewhere vm=devvm-moved-12345612345604$'
stderr '^gc_orphan_elsewhere vm=devvm-norec-12345612345605$'
stderr '^gc_orphan_recent vm=devvm-new-12345612345603$'
stdout '^==> forgot_orphan vm=devvm-gone-12345612345602$'
stdout '^==> forgot_orphan vm=devvm-smol-12345612345608$'
# Gone: the orphans' folders (state, logs, run and port files). Left:
# everything else's.
@@ -50,19 +47,18 @@ exists $VMS/12345612345604/state
exists $VMS/12345612345603/state
exists $VMS/12345612345605/state
exists $VMS/12345612345607/state
! exists $VMS/12345612345608
exec sh -c 'grep -c . "$STUB_DIR/instances"'
stdout '^1$'
stub_calls
! stdout 'limactl delete|machine delete'
! stdout 'limactl delete'
# When a backend a VM's state names doesn't answer, gc warns, leaves its
# VMs' state alone, and goes on with the others.
mkdir $VMS/12345612345608
exec sh -c 'printf "name=devvm-smol-12345612345608\nimage=base\ndir=/p/smol\nbackend=smolvm\nnet=off\n" > "$VMS/12345612345608/state" && touch -t 202001010000 "$VMS/12345612345608/state"'
exec sh -c 'touch "$STUB_DIR/smolvm-ls-fails"'
# When a backend a VM's state names doesn't answer, gc warns and leaves
# its VMs' state alone.
mkdir $VMS/12345612345602
exec sh -c 'printf "name=devvm-gone-12345612345602\nimage=base\ndir=/p/gone\nbackend=lima\nnet=off\nbackend_at=%s\n" "$(cat at)" > "$VMS/12345612345602/state" && touch -t 202001010000 "$VMS/12345612345602/state"'
exec sh -c 'touch "$STUB_DIR/list-fails"'
exec devvm gc --force --orphans
stderr '^devvm: gc_backend_skipped backend=smolvm$'
stderr '^gc_orphans_unknown backend=smolvm$'
exists $VMS/12345612345608/state
stderr '^devvm: gc_backend_skipped backend=lima$'
stderr '^gc_orphans_unknown backend=lima$'
exists $VMS/12345612345602/state
exists $VMS/12345612345604/state
+13 -17
View File
@@ -1,7 +1,7 @@
# A backend a VM uses that can't list its images: gc warns, leaves
# everything of that backend's alone (its images, its shared tool images
# and those without a record naming their backend, its VMs' leftovers), and goes
# on with the other backends, succeeding. devvm images still fails.
# and those without a record naming their backend, its VMs' leftovers),
# and succeeds. devvm images still fails.
env SHARE=$XDG_DATA_HOME/devvm/tools
# foo on Lima, made stale.
@@ -10,32 +10,28 @@ cp foo.sh $XDG_CONFIG_HOME/devvm/layers/foo.sh
exec devvm build foo
exec sh -c 'echo "# edited" >> "$XDG_CONFIG_HOME/devvm/layers/foo.sh"'
# Unused tool images: one recorded as smolvm's, one as Lima's, one
# nobody can tell; claude's build, for a VM that's gone since, makes the
# lock, so they're unused.
# Unused tool images: one recorded as Lima's, one nobody can tell;
# claude's build, for a VM that's gone since, makes the lock, so they're
# unused.
project ag
exec devvm --tools none --agents claude --no-network-policy --no-git-protect
exec devvm rm --force --no-export
exec sh -c 'cd "$SHARE" && for v in 1.1.0 1.2.0 1.3.0; do echo x > go-$v-0123456789ab.erofs; done'
json_set $SHARE/go-1.1.0-0123456789ab.erofs.json sha256=x libc=gnu format=plain-0123456789ab backend=smolvm built=2020-01-01T00:00:00Z
exec sh -c 'cd "$SHARE" && for v in 1.2.0 1.3.0; do echo x > go-$v-0123456789ab.erofs; done'
json_set $SHARE/go-1.2.0-0123456789ab.erofs.json sha256=x libc=gnu backend=lima built=2020-01-01T00:00:00Z
# A smolvm VM whose machine is gone, so smolvm is used; then smolvm
# stops answering.
# A Lima VM that's gone, so Lima is used; then Lima stops answering.
mkdir $VMS/12345612345612
exec sh -c 'printf "name=devvm-smol-12345612345612\nimage=base\ndir=/p/smol\nbackend=smolvm\nnet=off\n" > "$VMS/12345612345612/state" && touch -t 202001010000 "$VMS/12345612345612/state"'
exec sh -c 'touch "$STUB_DIR/smolvm-ls-fails"'
exec sh -c 'printf "name=devvm-gone-12345612345612\nimage=base\ndir=/p/gone\nbackend=lima\nnet=off\n" > "$VMS/12345612345612/state" && touch -t 202001010000 "$VMS/12345612345612/state"'
exec sh -c 'touch "$STUB_DIR/list-fails"'
exec devvm gc --force --orphans
stderr '^devvm: gc_backend_skipped backend=smolvm$'
stderr '^gc_orphans_unknown backend=smolvm$'
stderr '^devvm: gc_backend_skipped backend=lima$'
stderr '^gc_orphans_unknown backend=lima$'
! stderr gc_failed
stdout '^gc_image image=foo key=[0-9a-f]{12}$'
stdout '^gc_tools count=1 '
! stdout '^gc_image '
! stdout '^gc_orphan'
exists $VMS/12345612345612/state
exists $SHARE/go-1.1.0-0123456789ab.erofs
! exists $SHARE/go-1.2.0-0123456789ab.erofs
exists $SHARE/go-1.2.0-0123456789ab.erofs
exists $SHARE/go-1.3.0-0123456789ab.erofs
# devvm images lists every backend's or none.
+5 -8
View File
@@ -14,7 +14,7 @@ stdout '^opencode +- +- +- +- +- +- +not installed$'
stderr '^images_total size=0B$'
! stderr images_unused
stub_calls
stdout '^limactl list --json\nsmolvm machine ls( --state-dir \S+)? --json\n\z'
stdout '^limactl list --json\n\z'
# base, foo on it, a build that didn't finish, and a project VM.
mkdir $XDG_CONFIG_HOME/devvm/layers
@@ -33,9 +33,6 @@ stdout '^foo +ubuntu .* +stale +'
# --backend: that backend's images alone.
exec devvm images --backend lima
stdout '^foo +ubuntu .* +stale +\S+ +lima$'
exec devvm images --backend smolvm
! stdout ' lima$'
stdout '^IMAGE +FROM +DIGEST +KEY +STATE +SIZE +BACKEND\n\n'
# Shared tools: each version newest first, how many VMs list it, and
# whether it's the lock's; the lock's go, not built, and an older one no
@@ -45,15 +42,15 @@ exec devvm --tools none --agents claude --no-network-policy --no-git-protect
exec devvm rm --force --no-export
cd $WORK
exec sh -c 'cd "$SHARE" && : > go-1.20.0-0123456789ab.erofs && : > go-1.9.0-0123456789ab.erofs'
json_set $SHARE/go-1.20.0-0123456789ab.erofs.json sha256=x libc=musl format=plain-0123456789ab backend=smolvm built=2020-01-01T00:00:00Z
json_set $SHARE/go-1.20.0-0123456789ab.erofs.json sha256=x libc=musl backend=lima built=2020-01-01T00:00:00Z
mkdir $VMS/12345612345602
exec sh -c 'printf "name=devvm-p-12345612345602\nimage=base\ndir=/p\nbackend=smolvm\nlibc=musl\ntool_names=claude go\ntools=%s go-1.20.0-0123456789ab.erofs\n" "$(cd "$SHARE" && ls claude-*.erofs)" > "$VMS/12345612345602/state"'
exec sh -c 'printf "name=devvm-p-12345612345602\nimage=base\ndir=/p\nbackend=lima\nlibc=musl\ntool_names=claude go\ntools=%s go-1.20.0-0123456789ab.erofs\n" "$(cd "$SHARE" && ls claude-*.erofs)" > "$VMS/12345612345602/state"'
stub_reset
exec devvm images
# The lock's go isn't built; the old go has the backend and C library its
# record names, the oldest, without a record, none; claude's build says
# its own.
stdout '^go +go +1\.27\.2 +- +- +- +- +not built\ngo +go +1\.20\.0 +smolvm +musl +\S+ +1 +in use\ngo +go +1\.9\.0 +- +- +\S+ +0 +unused\n'
stdout '^go +go +1\.27\.2 +- +- +- +- +not built\ngo +go +1\.20\.0 +lima +musl +\S+ +1 +in use\ngo +go +1\.9\.0 +- +- +\S+ +0 +unused\n'
stdout '^claude +claude +2\.1\.295 +lima +gnu +\S+ +1 +current$'
stderr '^images_total size=\S+$'
stdout '^node +- '
@@ -62,7 +59,7 @@ stub_calls
# --json: the same as fields, sizes in bytes; the notes stay on stderr.
exec devvm images --json
stdout '^{\n "version": 1,\n "images": \[\n {\n "name": "base",\n "from": "ubuntu 26\.04 \(\d{8}\)",\n "digest": "sha256:[0-9a-f]{64}",\n "key": "[0-9a-f]{12}",\n "state": "current",\n "size": \d+,\n "sized": true,\n "backend": "lima"\n'
stdout '^ "name": "go",\n "tool": "go",\n "version": "1\.20\.0",\n "built": true,\n "backend": "smolvm",\n "libc": "musl",\n "size": \d+,\n "vms": 1,\n "state": "in use"\n'
stdout '^ "name": "go",\n "tool": "go",\n "version": "1\.20\.0",\n "built": true,\n "backend": "lima",\n "libc": "musl",\n "size": \d+,\n "vms": 1,\n "state": "in use"\n'
stdout '^ "name": "go",\n "tool": "go",\n "version": "1\.27\.2",\n "built": false,\n "size": 0,\n "vms": 0,\n "state": "not built"\n'
stdout '^ "total": \d+,\n "unused_tools": \d+,\n "nix_cache": {\n "files": 0,\n "size": 0,\n "cap": \d+\n }\n}\n\z'
stderr '^images_total size=\S+$'
+1 -1
View File
@@ -7,7 +7,7 @@ exec devvm ls
cmp stdout header.txt
! stderr .
stub_calls
stdout '^limactl list --json\nsmolvm machine ls( --state-dir \S+)? --json\n\z'
stdout '^limactl list --json\n\z'
# A folder named img-foo gives a VM named like an image: listed, while
# the image it was made from isn't. No network policy: off.
+14 -11
View File
@@ -41,23 +41,26 @@ exec devvm rebuild foo
! stdout rebuild_replaces
stdout -count=1 '^==> deleted_old_image image=foo key=[0-9a-f]{12}$'
# A rebuild changes the images of its own backend and base alone, the
# base as given: Lima's base stays current, and so is kept, after
# smolvm's is rebuilt, and so does a base from ubuntu-26.04, whose
# counter a name made of ubuntu:26.04 would once have been.
# A rebuild changes the base as given alone: the base from Ubuntu's
# cloud image stays current, and so is kept, after a --from base is
# rebuilt, and so does a base from ubuntu-26.04, whose counter a name made
# of ubuntu:26.04 would once have been. Registries are never reached: a
# pinned digest needs no lookup.
env PIN=ubuntu:26.04@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
env PIN2=ubuntu-26.04@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
exec devvm --backend smolvm --from $PIN build base
exec devvm --backend smolvm --from $PIN2 build base
env HTTPS_PROXY=http://127.0.0.1:9
env https_proxy=http://127.0.0.1:9
exec devvm --from $PIN build base
exec devvm --from $PIN2 build base
exec devvm images
stdout -count=2 '^base +\S+ .* current +\S+ +smolvm$'
exec devvm rebuild --backend smolvm --from $PIN --force base
stdout -count=3 '^base +.* current +\S+ +lima$'
exec devvm rebuild --from $PIN --force base
stdout -count=1 '^==> deleted_old_image image=base key=[0-9a-f]{12}$'
exec devvm images
stdout -count=1 '^base +ubuntu 26\.04 .* current +\S+ +lima$'
stdout -count=2 '^base +\S+ .* current +\S+ +smolvm$'
stdout -count=1 '^base +ubuntu 26\.04 \(\d{8}\) .* current +\S+ +lima$'
stdout -count=3 '^base +.* current +\S+ +lima$'
! stdout ' stale '
grep '"backend": "smolvm",\n "from": "ubuntu:26.04@sha256:a{64}",\n "name": "base",' $IMAGES/rebuilds.json
grep '"backend": "lima",\n "from": "ubuntu:26.04@sha256:a{64}",\n "name": "base",' $IMAGES/rebuilds.json
! grep '"from": "ubuntu-26.04' $IMAGES/rebuilds.json
-- foo.sh --
+1 -1
View File
@@ -70,7 +70,7 @@ stderr '^devvm: flag_unknown command=devvm restart flag=--backend$'
stderr '^devvm: flag_unknown command=devvm tools add flag=--from$'
# A backend that isn't one is refused first too.
! exec devvm build --backend nope base
stderr '^devvm: backend_unknown backends=lima, smolvm name=nope$'
stderr '^devvm: backend_unknown backends=lima name=nope$'
stderr '^usage_help command=devvm build$'
! stub_calls
+4 -4
View File
@@ -62,7 +62,7 @@ exec devvm setup --backend lima --features fzf
stdout '^==> default_backend backend=lima$'
stdout '^==> base_features features=fzf$'
! exec devvm setup --backend nope
stderr '^devvm: backend_unknown backends=lima, smolvm name=nope$'
stderr '^devvm: backend_unknown backends=lima name=nope$'
grep '^ "backend": "lima",$' $SAVED
# New VMs' size is devvm size -g's, and without a terminal nothing asks
@@ -121,7 +121,7 @@ cd $WORK
# can't change it: refused, naming the file and the key, with nothing
# saved.
cp config.toml $CFG/config.toml
! exec devvm setup --backend smolvm
! exec devvm setup --backend lima
stderr '^devvm: set_in_config file=\S*/config/devvm/config\.toml key=backend$'
! exec devvm setup --features omb
stderr '^devvm: set_in_config file=\S*/config/devvm/config\.toml key=features$'
@@ -134,7 +134,7 @@ exec devvm setup
stdout '^==> setup_in_config file=\S*/config/devvm/config\.toml key=features$'
! stdout base_features
exec devvm doctor --json
stdout '"backend": "smolvm",\n "backend_source": "config.toml",'
stdout '"backend": "lima",\n "backend_source": "config.toml",'
rm $CFG/config.toml
# An unreadable choice stays for you to fix.
@@ -144,7 +144,7 @@ stderr '^devvm: setup_failed reason=\S*/data/devvm/settings\.json: features: not
cmp $SAVED bad.json
-- config.toml --
backend = "smolvm"
backend = "lima"
features = ["fzf"]
agents = ["opencode"]
-- bad.json --
+4 -10
View File
@@ -1,14 +1,13 @@
# A small host, as the test build fakes one (2 CPUs, 7 GiB of memory and
# 1 GiB free, below GitHub's smallest runner): doctor warns about each, a
# build refuses the disk, base is fitted to the host on Lima and smolvm,
# and sizes past the host are refused. Registries are never reached: the
# pinned image needs no lookup, and HTTPS_PROXY points at nothing.
# build refuses the disk, base is fitted to the host, and sizes past the
# host are refused. Registries are never reached: HTTPS_PROXY points at
# nothing.
env DEVVM_TEST_CPUS=2
env DEVVM_TEST_MEMORY_GIB=7
env DEVVM_TEST_FREE_GIB=1
env HTTPS_PROXY=http://127.0.0.1:9
env https_proxy=http://127.0.0.1:9
env PIN=ubuntu:26.04@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# doctor warns, and passes.
exec devvm doctor
@@ -23,17 +22,12 @@ stderr '^devvm: disk_low dir=\S+ free=1\.0 name=base need=[0-9]+$'
stub_calls
! stdout 'limactl create'
# With room, base gets the host's 2 CPUs and half its memory, on Lima and
# on smolvm.
# With room, base gets the host's 2 CPUs and half its memory.
env DEVVM_TEST_FREE_GIB=500
exec devvm build base
stdout '^==> base_fitted cpus=2 memory=3\.5$'
stub_calls
stdout '^limactl create --tty=false --mount-none --name=devvm-img-[0-9a-f]{12} .* --cpus=2 --memory=3\.5 -$'
exec devvm --backend smolvm --from $PIN build base
stdout '^==> base_fitted cpus=2 memory=3\.5$'
stub_calls
stdout '^smolvm machine create( --state-dir \S+)? --name devvm-img-[0-9a-f]{12} --label devvm\.data=\S+ --cpus 2 --mem 3584 '
# Sizes past the host: more CPUs than it has, or more memory than leaves
# it 2 GiB.
-303
View File
@@ -1,303 +0,0 @@
# The smolvm backend (experimental), on the smolvm stub: its checks, base
# built as a pack from a container image, a project VM made from it with
# everything set, and the features it lacks refused in one line naming the
# VM. Registries are never reached: the pinned image needs no lookup, and
# HTTPS_PROXY points at nothing. On Linux every call has --state-dir.
env PACKS=$XDG_DATA_HOME/devvm/smolvm/images
env HTTPS_PROXY=http://127.0.0.1:9
env https_proxy=http://127.0.0.1:9
env PIN=ubuntu:26.04@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# Its checks: smolvm 1.32 or newer.
exec devvm doctor --backend smolvm
stdout '^doctor_ok backend=smolvm version=\S+$'
exec sh -c 'echo 1.31.0 > "$STUB_DIR/smolvm-version"'
! exec devvm doctor --backend smolvm
stderr '^devvm: smolvm_old'
rm $STUB_DIR/smolvm-version
# Base: a machine from the image by its digest, labelled, with base.yaml's
# size and the internet; prepared, its scripts run between the stand-ins,
# then packed and deleted.
exec devvm --backend smolvm --from $PIN build base
stdout '^==> building_image_from from=ubuntu:26.04@sha256:a+ image=base key=[0-9a-f]{12}$'
stub_calls
stdout '^smolvm machine create( --state-dir \S+)? --name devvm-img-([0-9a-f]{12}) --label devvm\.data=\S+/data/devvm --cpus 4 --mem 8192 --storage 100 -v /var/lib/docker --net --image ubuntu:26\.04@sha256:a+$'
stdout '^smolvm machine start( --state-dir \S+)? --name devvm-img-[0-9a-f]{12}$'
stdout '^smolvm machine exec( --state-dir \S+)? --name devvm-img-[0-9a-f]{12} -i -- sh -s -- \S+ \d+$'
stdout '^smolvm machine exec( --state-dir \S+)? --name devvm-img-[0-9a-f]{12} -i -- sh -s -- on$'
stdout '^smolvm machine exec( --state-dir \S+)? --name devvm-img-[0-9a-f]{12} -i -u \S+ -w / .* -- sh -c .* sh bash -s$'
stdout '^smolvm machine exec( --state-dir \S+)? --name devvm-img-[0-9a-f]{12} -i -- sh -s -- off$'
stdout '^smolvm pack create( --state-dir \S+)? --from-vm devvm-img-[0-9a-f]{12} -o \S+/smolvm/images/[0-9a-f]{12}\.tmp/image$'
stdout '^smolvm machine delete( --state-dir \S+)? --name devvm-img-[0-9a-f]{12} -f$'
! stdout limactl
exec sh -c 'ls "$PACKS"/*/image.smolmachine'
exec devvm images
stdout '^base +ubuntu:26\.04@sha256:a+ +a{12} +[0-9a-f]{12} +current +\S+ +smolvm$'
# A new VM forwards every port by default, which smolvm emulates
# (reviewed): none of smolvm's forwards; once its sshd runs, a forwarder of
# devvm's on the host reaches it over ssh (a master, offering the VM's key
# alone, its host key read through smolvm and pinned), and forwards what
# listens in the VM. The ports that listen in it, and the range FIRST-LAST
# the VM lists later, are ones free here.
free_port UNLISTED LISTED
free_port -range FIRST LAST
project all
stub_reset
exec sh -c 'printf "0100007F:%04X\n00000000:0050\n" "$UNLISTED" > "$STUB_DIR/guest-ports"'
exec devvm --backend smolvm --from $PIN --no-network-policy
! stderr 'backend_unreviewed'
! stderr 'ports_'
stub_calls
stdout '^smolvm machine create( --state-dir \S+)? --name devvm-all-[0-9a-f]{14} .* -v \S+:/mnt/devvm-tools:ro --ssh-agent$'
stdout '^smolvm machine exec( --state-dir \S+)? --name devvm-all-[0-9a-f]{14} -- cat /etc/ssh/ssh_host_ed25519_key\.pub$'
stdout '^ssh -F none -M -S \S+/data/devvm/run/smolvm-[0-9a-f]{16}\.ctl -T .* -o IdentityFile=\S+/data/devvm/vms/[0-9a-f]{14}/backend/key .* -o HostKeyAlias=devvm-all-[0-9a-f]{14} .* -o PermitRemoteOpen=none -o ClearAllForwardings=yes .* -p [0-9]+ -l \S+ 127\.0\.0\.1 sh -s$'
vm_name ALL all
catg $ALL_dir/backend/ports.known_hosts
stdout '^devvm-all-[0-9a-f]{14} ssh-ed25519 AAAAstub$'
catg $ALL_dir/backend/ports.log
stdout '^devvm ports: port '$UNLISTED': forwarded$'
stdout '^devvm ports: forwarding devvm-all-[0-9a-f]{14}''s ports$'
! stdout 'port 80'
exec devvm stop
exec devvm rm --force --no-export
! exists $ALL_dir
rm $STUB_DIR/guest-ports
project web
# Listed ports: made from base's pack with everything set (a pack would
# give it its build machine's), started, set up, then the shell. smolvm
# forwards none of its ports, only its ssh: devvm's forwarder forwards the
# listed ports alone (LISTED listens in the VM, and UNLISTED).
exec sh -c 'printf "0100007F:%04X\n0100007F:%04X\n" "$LISTED" "$UNLISTED" > "$STUB_DIR/guest-ports"'
exec devvm --backend smolvm --from $PIN --no-network-policy --ports $LISTED,$FIRST-$LAST --cpus 2
stdout '^==> creating_from image=base vm=devvm-web-[0-9a-f]{14}$'
! stderr 'ports_'
stub_calls
stdout '^smolvm machine create( --state-dir \S+)? --name devvm-web-[0-9a-f]{14} --label devvm\.data=\S+ --from \S+/image\.smolmachine --cpus 2 --mem \d+ --storage 100 -v /var/lib/docker -v (\S+)/web:\S+/web -v \S+/data/devvm/tools:/mnt/devvm-tools:ro --ssh-agent$'
stdout '^smolvm machine update( --state-dir \S+)? --name devvm-web-[0-9a-f]{14} --net -p [0-9]+:22$'
! stdout ' -p ('$LISTED'|'$FIRST')'
stdout '^smolvm machine start( --state-dir \S+)? --name devvm-web-[0-9a-f]{14}$'
stdout '^smolvm machine exec( --state-dir \S+)? --name devvm-web-[0-9a-f]{14} -i -- sh -s -- ssh \S+ ssh-ed25519 \S+ devvm NODE_EXTRA_CA_CERTS PIP_CERT REQUESTS_CA_BUNDLE SSL_CERT_FILE UV_SYSTEM_CERTS$'
stdout '^smolvm machine exec( --state-dir \S+)? --name devvm-web-[0-9a-f]{14} -i( -t)? -u \S+ -w \S+/web .* bash -l$'
! stderr 'backend_unreviewed'
vm_name WEB web
catg $WEB_dir/backend/ports.log
stdout '^devvm ports: port '$LISTED': forwarded$'
stdout '^devvm ports: forwarding devvm-web-[0-9a-f]{14}''s ports$'
! stdout 'port '$UNLISTED':'
exists $STUB_DIR/sync.tar
exec devvm ls
stdout '^devvm-web-[0-9a-f]{14} +Running .*image=base +- +\S+ +off +- +smolvm +\S+/web$'
grep '^Host devvm-web devvm-web-[0-9a-f]{14}$' $DATA/ssh_config
# A listed port a program on this machine has, on any address, isn't
# forwarded from a start that finds it so, warned: the forwarder forwards
# the rest, and smolvm none.
listen_any TAKEN
exec devvm stop
exec devvm ports add $TAKEN
stub_reset
exec sh -c 'printf "0100007F:%04X\n0100007F:%04X\n" "$LISTED" "$TAKEN" >"$STUB_DIR/guest-ports"; : > "$WEB_dir/backend/ports.log"'
exec devvm
stderr '^devvm: ports_taken count=1 ports='$TAKEN' vm=devvm-web-[0-9a-f]{14}$'
! stderr 'ports_forward_failed'
stub_calls
! stdout '^smolvm machine (create|update) .* -p '
! stdout '--remove-port'
catg $WEB_dir/backend/ports.log
stdout '^devvm ports: port '$LISTED': forwarded$'
! stdout 'port '$TAKEN
exec devvm ports
stdout '^'$LISTED','$FIRST'-'$LAST','$TAKEN'$'
# Running: a change starts its forwarder again at once, the VM running on.
stub_reset
exec devvm ports rm $FIRST-$LAST
stdout '^==> ports_forwarding ports='$LISTED','$TAKEN' vm=devvm-web-[0-9a-f]{14}$'
stderr '^devvm: ports_taken count=1 ports='$TAKEN' vm=devvm-web-[0-9a-f]{14}$'
stub_calls
! stdout '^smolvm machine (stop|start|update)'
exec sh -c 'ps -axww -o command= | grep "[_]smolvm-ports -vm devvm-web-" | grep -F -- "-key $XDG_DATA_HOME/devvm/"'
stdout ' -only '$LISTED'$'
rm $STUB_DIR/guest-ports
# Its agent forwarding can be turned on later (emulated, reviewed): made
# forwarding, and given no agent, a path no socket can be at.
catg $WEB_dir/state
stdout '^net=off$'
stdout '^ssh_agent=off$'
stdout '^agent_toggle=on$'
catg $STUB_DIR/smolvm-agent-devvm-web-*
stdout '^/dev/null/devvm-no-agent$'
# rm deletes the machine and what the backend recorded for it.
exists $WEB_dir/backend/record.json
exec devvm rm --force --no-export
stdout '^==> deleted vm=devvm-web-[0-9a-f]{14}$'
! exists $WEB_dir
exec devvm ls
! stdout devvm-web
# Network policy (emulated, reviewed). The proxy decides too, on a port of
# its own, with a token in a file; the machine's allow list is the gateway,
# its DNS a name that doesn't exist, its proxy settings the gateway's, and it
# starts through the decider, the token in no arguments or logs; the
# self-check passes.
project pol
stub_reset
exec devvm --backend smolvm --from $PIN --network-policy --ports none
! stderr 'backend_unreviewed'
vm_name POL pol
catg $POL_dir/state
stdout '^net=on$'
stdout '^net_check=ok$'
stdout '^decider_port=[0-9]+$'
stdout '^decider_token=[0-9a-f]{64}$'
stub_calls
stdout '^smolvm machine update( --state-dir \S+)? --name devvm-pol-[0-9a-f]{14} --reset-allow-list --allow-cidr 100\.96\.0\.1/32 --allow-host-pattern devvm\.invalid -p [0-9]+:22$'
! stdout ' -e HTTPS?_PROXY='
stdout '^smolvm machine start( --state-dir \S+)? --name devvm-pol-[0-9a-f]{14} --mediated-egress --egress-interceptor 127\.0\.0\.1:[0-9]+$'
stdout '^smolvm machine exec( --state-dir \S+)? --name devvm-pol-[0-9a-f]{14} --secret-file HTTP_PROXY=\S+/data/devvm/vms/[0-9a-f]{14}/backend/proxy.* curl --noproxy \* -sS -m 3 -o /dev/null https://1\.1\.1\.1$'
# The proxy's URL is in the machine's proxy file (mode 600), which each exec
# names: never in smolvm's arguments.
exec sh -c 'key=$(sed -n "s/^proxy_key=//p" "$POL_dir/state"); f="$POL_dir/backend/proxy"; grep -qE "^http://devvm:$key@100\.96\.0\.1:[0-9]+$" "$f" && ! grep -qF "$key" "$STUB_LOG" && ls -l "$f"'
stdout '^-rw-------\S* '
# The password is in no run log.
exec sh -c 'key=$(sed -n "s/^proxy_key=//p" "$POL_dir/state"); ! grep -rqF "$key" "$XDG_DATA_HOME"/devvm/logs/runs'
exec sh -c 'grep -F "deciding on 127.0.0.1:$(sed -n "s/^decider_port=//p" "$POL_dir/state") for devvm-pol-" "$POL_dir/logs/proxy.log"'
catg $STUB_DIR/smolvm-decider-devvm-pol-*
stdout '^127\.0\.0\.1:[0-9]+ [0-9a-f]{64}$'
exec sh -c 'tok=$(sed -n "s/^decider_token=//p" "$POL_dir/state"); [ "$(cat "$POL_dir/run/proxy.decider")" = "$tok" ] && ! grep -qF "$tok" "$STUB_LOG" && ! grep -rqF "$tok" "$XDG_DATA_HOME"/devvm/logs "$POL_dir/logs"'
# Running, with its proxy gone and the decider's port taken by another
# program: stopped, never left running without it.
exec sh -c 'pp=$(sed -n "s/^proxy_port=//p" "$POL_dir/state"); dp=$(sed -n "s/^decider_port=//p" "$POL_dir/state"); pkill -f -- "_proxy -listen 127.0.0.1:$pp "; sleep 0.5; echo k > "$WORK/squat.key"; devvm _proxy -listen "127.0.0.1:$dp" -auth-file "$WORK/squat.key" -lifeline "$WORK/squat.none" >/dev/null 2>&1 & echo $! > "$WORK/squat.pid"; sleep 1'
stub_reset
! exec devvm
stderr '^devvm: net_proxy_down_stopped vm=devvm-pol-[0-9a-f]{14}$'
stderr '^devvm: proxy_port_taken port=[0-9]+ vm=devvm-pol-[0-9a-f]{14}$'
stub_calls
stdout '^smolvm machine stop( --state-dir \S+)? --name devvm-pol-[0-9a-f]{14}$'
! stdout 'bash -l$'
exec sh -c 'kill "$(cat "$WORK/squat.pid")"'
exec devvm rm --force --no-export
stdout '^==> deleted vm=devvm-pol-[0-9a-f]{14}$'
# ssh for editors (emulated, reviewed): each start forwards the VM's sshd
# from a host loopback port and runs it with the VM's own key; the ssh
# config reaches it by name with that key alone, its host keys read through
# smolvm and pinned.
project sshd
stub_reset
exec devvm --backend smolvm --from $PIN --no-network-policy --ports 5173
! stderr 'backend_unreviewed'
stub_calls
stdout '^smolvm machine update( --state-dir \S+)? --name devvm-sshd-[0-9a-f]{14} --net -p [0-9]+:22$'
stdout '^smolvm machine exec( --state-dir \S+)? --name devvm-sshd-[0-9a-f]{14} -i -- sh -s -- ssh \S+ ssh-ed25519 \S+ devvm NODE_EXTRA_CA_CERTS PIP_CERT REQUESTS_CA_BUNDLE SSL_CERT_FILE UV_SYSTEM_CERTS$'
vm_name SSHD sshd
exec ls -l $SSHD_dir/backend/key
stdout '^-rw-------\S* '
grep '^Host devvm-sshd devvm-sshd-[0-9a-f]{14}$' $DATA/ssh_config
grep '^ Hostname 127\.0\.0\.1$' $DATA/ssh_config
grep '^ Port [0-9]+$' $DATA/ssh_config
grep '^ IdentityFile ".+/data/devvm/vms/[0-9a-f]{14}/backend/key"$' $DATA/ssh_config
grep '^ ForwardX11 no$' $DATA/ssh_config
grep '^ AddKeysToAgent no$' $DATA/ssh_config
grep '^ IdentitiesOnly yes$' $DATA/ssh_config
grep '^ ForwardAgent no$' $DATA/ssh_config
grep '^devvm-sshd-[0-9a-f]{14} ssh-ed25519 AAAAstub$' $DATA/known_hosts
exec devvm host
stdout '^ssh_host_info dir=\S+/sshd host=devvm-sshd$'
# An image without sshd: the start runs the rest without it, warned; no
# entry, and devvm host says so.
stub_reset
exec sh -c 'touch "$STUB_DIR/no-sshd"'
exec devvm restart
stderr '^devvm: vm_no_sshd vm=devvm-sshd-[0-9a-f]{14}$'
stub_calls
stdout '^smolvm machine exec( --state-dir \S+)? --name devvm-sshd-[0-9a-f]{14} -i -- sh -s --$'
! grep 'devvm-sshd' $DATA/ssh_config
! exec devvm host
stderr '^devvm: vm_no_sshd vm=devvm-sshd-[0-9a-f]{14}$'
rm $STUB_DIR/no-sshd
exec devvm rm --force --no-export
stdout '^==> deleted vm=devvm-sshd-[0-9a-f]{14}$'
! exists $SSHD_dir
# Any number of listed ports, 22 among them: all the forwarder's, none of
# smolvm's.
project many
stub_reset
exec devvm --backend smolvm --from $PIN --no-network-policy --ports 22,3000-3100
! stderr 'backend_unreviewed'
stub_calls
stdout '^smolvm machine create( --state-dir \S+)? --name devvm-many-[0-9a-f]{14} .* --ssh-agent$'
! stdout ' -p (22|3000):'
exec devvm ports
stdout '^22,3000-3100$'
exec devvm rm --force --no-export
# Agent forwarding turned on or off (emulated, reviewed): a new VM is made
# forwarding (--ssh-agent), and each start gives it the agent its choice
# names: none (a path no socket can be at), devvm's own, or yours; a change
# waits for its next start. devvm's own SSH_AUTH_SOCK never reaches smolvm
# otherwise.
env SSH_AUTH_SOCK=$WORK/user.sock
project agent
stub_reset
exec devvm --backend smolvm --from $PIN --no-network-policy --ports none
! stderr 'backend_unreviewed'
stub_calls
stdout '^smolvm machine create( --state-dir \S+)? --name devvm-agent-[0-9a-f]{14} .* --ssh-agent$'
vm_name AGENT agent
catg $AGENT_dir/state
stdout '^ssh_agent=off$'
stdout '^agent_toggle=on$'
catg $STUB_DIR/smolvm-agent-devvm-agent-*
stdout '^/dev/null/devvm-no-agent$'
exec devvm ssh-agent devvm
catg $STUB_DIR/smolvm-agent-devvm-agent-*
stdout '^/dev/null/devvm-no-agent$'
exec devvm
catg $DATA/ssh_config
stdout '^Host devvm-agent devvm-agent-[0-9a-f]{14}\n( .*\n)* ForwardAgent no\n'
exec devvm restart
catg $STUB_DIR/smolvm-agent-devvm-agent-*
stdout '^\S+/data/devvm/agent\.sock$'
catg $DATA/ssh_config
stdout '^Host devvm-agent devvm-agent-[0-9a-f]{14}\n( .*\n)* ForwardAgent "\S+/data/devvm/agent\.sock"\n'
exec devvm ssh-agent on
exec devvm restart
catg $STUB_DIR/smolvm-agent-devvm-agent-*
stdout '^\S+/user\.sock$'
exec devvm ssh-agent off
exec devvm restart
catg $STUB_DIR/smolvm-agent-devvm-agent-*
stdout '^/dev/null/devvm-no-agent$'
# Started outside devvm (smolvm machine start from the user's shell, with
# its agent): stopped, as it may forward an agent devvm didn't choose; then
# devvm starts it again, with none.
exec devvm stop
exec smolvm machine start --name $AGENT
catg $STUB_DIR/smolvm-agent-devvm-agent-*
stdout '^\S+/user\.sock$'
stub_reset
! exec devvm
stderr '^devvm: agent_unchosen_stop vm=devvm-agent-[0-9a-f]{14}$'
stub_calls
stdout '^smolvm machine stop( --state-dir \S+)? --name devvm-agent-[0-9a-f]{14}$'
! stdout 'bash -l$'
exec devvm
catg $STUB_DIR/smolvm-agent-devvm-agent-*
stdout '^/dev/null/devvm-no-agent$'
# Its own start, kept: devvm doesn't stop it.
exec devvm host
! stderr 'agent_unchosen'
# With the user's agent, nothing to keep from it: started outside devvm,
# it runs on.
exec devvm ssh-agent on
exec devvm stop
exec smolvm machine start --name $AGENT
exec devvm
! stderr 'agent_unchosen'
exec devvm rm --force --no-export
+10 -12
View File
@@ -59,8 +59,6 @@ stdout '^images +lima +2 +'
stdout '^tools gnu +lima +'
! stdout '^(history|state|mise|tools -) '
stdout '^total +- +- +\S+ +- +\S+ +- +-$'
stub_calls
! stdout smolvm
! exec devvm space --backend nope
stderr '^devvm: backend_unknown '
@@ -74,21 +72,21 @@ stdout '"total": \d+'
# A backend a VM's state names that doesn't answer is named, and its VMs
# are never leftovers.
mkdir $VMS/12345612345603
exec sh -c 'printf "name=devvm-s-12345612345603\nimage=base\ndir=/s\nbackend=smolvm\n" > "$VMS/12345612345603/state"'
exec sh -c 'touch "$STUB_DIR/smolvm-ls-fails"'
exec sh -c 'printf "name=devvm-s-12345612345603\nimage=base\ndir=/s\nbackend=lima\n" > "$VMS/12345612345603/state"'
exec sh -c 'touch "$STUB_DIR/list-fails"'
exec devvm space
stderr '^space_backend_unknown backend=smolvm$'
stdout '^leftover state +- +1 '
stderr '^space_backend_unknown backend=lima$'
! stdout '^leftover state '
# A backend slower than the timeout is named the same way, and its VMs
# aren't leftovers either.
rm $STUB_DIR/smolvm-ls-fails
exec sh -c 'touch "$STUB_DIR/smolvm-ls-hangs"'
env DEVVM_TEST_LIST_TIMEOUT=10m,smolvm:1s
rm $STUB_DIR/list-fails
exec sh -c 'touch "$STUB_DIR/list-hangs"'
env DEVVM_TEST_LIST_TIMEOUT=10m,lima:1s
exec devvm space
stderr '^space_backend_unknown backend=smolvm$'
stdout '^leftover state +- +1 '
rm $STUB_DIR/smolvm-ls-hangs
stderr '^space_backend_unknown backend=lima$'
! stdout '^leftover state '
rm $STUB_DIR/list-hangs
env DEVVM_TEST_LIST_TIMEOUT=10m
# Lima's download cache, which every Lima home shares: shown apart.
+5 -6
View File
@@ -31,7 +31,7 @@ stdout '^limactl clone --tty=false devvm-img-[0-9a-f]{12} devvm-web-[0-9a-f]{14}
! stdout 'devvm-tools-build'
stdout '^limactl start --tty=false devvm-web-[0-9a-f]{14}\nlimactl shell --workdir / devvm-web-[0-9a-f]{14} sh -c .*/etc/ssh/ssh_host_.*\n'
stdout '^ssh -F none -M -S \S+/data/devvm/run/lima-[0-9a-f]{16}\.ctl -T .* -o IdentityFile=\S+/lima/_config/user .* -o UserKnownHostsFile=\S+/data/devvm/vms/[0-9a-f]{14}/backend/ports\.known_hosts .* -o HostKeyAlias=devvm-web-[0-9a-f]{14} .* -p 60022 -l stub 127\.0\.0\.1 sh -s$'
! stdout '^(docker|smolvm) '
! stdout '^docker '
stdout '^limactl shell --workdir / devvm-web-[0-9a-f]{14} sh -c cd ''/'' && exec ''bash'' ''-c'' ''d=\$\(mktemp -d\); tar -xf - .*''\n(limactl list --json\n)+limactl shell --workdir /\S*/web devvm-web-[0-9a-f]{14}\n\z'
exists $XDG_DATA_HOME/devvm/tools
! exists $XDG_DATA_HOME/devvm/mise.lock
@@ -88,16 +88,15 @@ vm_name API api
catg $API_dir/state
stdout '^git_protect=off$'
# Launches ask only the backends a VM's state names: with only Lima's VMs,
# neither docker nor smolvm runs, for a new VM or an existing one.
# Launches run no docker, which only --from uses, for a new VM or an
# existing one.
stub_calls
! stdout '^(docker|smolvm) '
! stdout '^docker '
stub_reset
exec devvm --no-network-policy
! stdout creating_from
stub_calls
stdout '^limactl list --json$'
! stdout '^(docker|smolvm) '
! stdout '^docker '
# Linux hosts: set-id files in the folder are named (they reach the host).
[linux] mkdir $WORK/setid
+4 -1
View File
@@ -2,7 +2,8 @@
# Stand-in for limactl in tests. Logs every call to $STUB_LOG, and the folder
# and Lima home of the last one to $STUB_DIR/limactl-env. Answers list --json
# from $STUB_DIR/instances ("name [status]" per line, status defaults to
# Stopped), which create, clone, start, stop and delete keep up to date;
# Stopped), which create, clone, start, stop and delete keep up to date,
# failing with $STUB_DIR/list-fails and hanging with $STUB_DIR/list-hangs;
# create's template on its input (-) goes to $STUB_DIR/create-template. A
# VM's config is $STUB_DIR/config-<name>.json, else {}; its size
# ("CPUS MEMORY DISK", in bytes) $STUB_DIR/size-<name>, else 4 CPUs, 8 GiB
@@ -211,6 +212,8 @@ esac
[[ ${1:-} != --version ]] || { echo "limactl version 2.2.1"; exit 0; }
[[ ${1:-} == list && ${2:-} == --json ]] || exit 0
[[ ! -e $STUB_DIR/list-fails ]] || exit 1
[[ ! -e $STUB_DIR/list-hangs ]] || exec sleep 30
while read -r n st; do
read -r cpus mem disk < <(cat "$STUB_DIR/size-$n" 2>/dev/null || echo "4 8589934592 107374182400")
cfg=$(cat "$STUB_DIR/config-$n.json" 2>/dev/null || echo '{}')
-148
View File
@@ -1,148 +0,0 @@
#!/bin/bash
# Stand-in for smolvm in tests. Logs every call to $STUB_LOG. Its machines are files in
# $STUB_DIR/smolvm/: one per machine, "STATE CPUS MEM_MIB STORAGE_GB NET LABEL", which create,
# start, stop, update and delete keep up to date; machine ls --json answers from them, and fails
# with $STUB_DIR/smolvm-ls-fails (hangs 30 s with $STUB_DIR/smolvm-ls-hangs). A machine
# with $STUB_DIR/smolvm-foreign-NAME has another label (someone else's). start fails with
# $STUB_DIR/smolvm-start-fails, leaving it stopped, and records the SSH agent it was given
# ($SSH_AUTH_SOCK, or "unset") to $STUB_DIR/smolvm-agent-NAME. exec answers the libc check
# with gnu (musl with $STUB_DIR/build-libc saying so), the host keys' cat with a made-up
# ed25519 key (AAAAstub), keeps the tar stream a VM's setup is sent as
# $STUB_DIR/sync.tar, appends a script's second line to $STUB_DIR/scripts when one is fed to bash
# -s or sh -s, answers the sshd probe with none when $STUB_DIR/no-sshd exists, fails a direct connection (curl --noproxy) unless $STUB_DIR/net-direct exists, and fails with $STUB_DIR/exec-fails (a script fed to bash -s: with $STUB_DIR/script-fails). The tools build machine's build.sh writes the
# images it's asked for into the folder it mounts. pack create writes its stub and .smolmachine.
# --version is 1.32.2, or $STUB_DIR/smolvm-version.
# A machine's allow lists and whether it needs a decider are in $STUB_DIR/smolvm-egress/NAME
# ("cidrs …", "hosts =…", "mediated true|false"), which update's --allow-cidr,
# --allow-host-pattern, --reset-allow-list and --no-egress-interceptor change, and machine ls shows;
# update prints the environment it sets (-e), values and all, as smolvm does. exec fails, as
# smolvm's does, when a --secret-file's file can't be read.
# start --mediated-egress records "INTERCEPTOR TOKEN" to $STUB_DIR/smolvm-decider-NAME (a start
# without it, "none ${SMOLVM_INTERCEPTOR_TOKEN-unset}"), and a mediated machine started without one
# fails. start writes the machine's agent.pid with $SMOLVM_STUB_PID (a process that outlives the
# command, as smolvm's does), else its caller's pid.
set -euo pipefail
"${0%/*}/stub-log" "$STUB_LOG" smolvm "$@"
dir=$STUB_DIR/smolvm
mkdir -p "$dir"
[[ ${1:-} != --version ]] || { echo "smolvm $(cat "$STUB_DIR/smolvm-version" 2>/dev/null || echo 1.32.2)"; exit 0; }
cmd="${1:-} ${2:-}"
shift 2 || true
# Options before --, and the arguments after it.
name="" label="" cpus="" mem="" storage="" net="" out="" vols=() after=()
cidrs=() hosts=() reset=false nointer=false mediated=false inter="" envs=() secrets=()
while (( $# )); do
case $1 in
-e) envs+=("$2"); shift ;;
--secret-file) secrets+=("$2"); shift ;;
--allow-cidr) cidrs+=("$2"); shift ;;
--allow-host-pattern) hosts+=("=$2"); shift ;;
--reset-allow-list) reset=true ;;
--no-egress-interceptor) nointer=true ;;
--mediated-egress) mediated=true ;;
--egress-interceptor) inter=$2; shift ;;
--name|-n) name=$2; shift ;;
--label) label=${2#*=}; shift ;;
--cpus) cpus=$2; shift ;;
--mem) mem=$2; shift ;;
--storage) storage=$2; shift ;;
--net) net=true ;;
--no-net) net=false ;;
-o|--output) out=$2; shift ;;
--from-vm) name=$2; shift ;;
-v) vols+=("$2"); shift ;;
--state-dir|--image|--from|-p|--remove-port|--remove-volume|--remove-env|-u|-w) shift ;;
--) shift; after=("$@"); break ;;
esac
shift
done
f=$dir/$name
get() { read -r st c m s n l < "$f"; }
put() { echo "$st $c $m $s $n $l" > "$f"; }
eg=$STUB_DIR/smolvm-egress
mkdir -p "$eg"
# egress NAME KEY: a line of a machine's egress file, without its key.
egress() { [[ ! -f $eg/$1 ]] || sed -n "s/^$2 *//p" "$eg/$1"; }
# json_list WORDS…: a JSON list of strings.
json_list() { local s="" w; for w in "$@"; do s+="${s:+,}\"$w\""; done; echo "[$s]"; }
case $cmd in
"machine ls")
[[ ! -e $STUB_DIR/smolvm-ls-fails ]] || { echo "smolvm: the engine didn't answer" >&2; exit 1; }
[[ ! -e $STUB_DIR/smolvm-ls-hangs ]] || exec sleep 30
sep="" out="["
for m in "$dir"/*; do
[[ -f $m ]] || continue
read -r st c mm s n l < "$m"; nm=$(basename "$m")
[[ ! -e $STUB_DIR/smolvm-foreign-$nm ]] || l=/elsewhere
allow=""
# shellcheck disable=SC2046 # the lists are words
[[ -z $(egress "$nm" cidrs) ]] || allow+=",\"allowed_cidrs\":$(json_list $(egress "$nm" cidrs))"
# shellcheck disable=SC2046
[[ -z $(egress "$nm" hosts) ]] || allow+=",\"allowed_hosts\":$(json_list $(egress "$nm" hosts))"
out+="$sep{\"name\":\"$nm\",\"state\":\"$st\",\"cpus\":$c,\"memory_mib\":$mm,\"storage_gb\":$s,\"network\":$n,\"labels\":{\"devvm.data\":\"$l\"}$allow}"
sep=,
done
echo "$out]" ;;
"machine create")
[[ ! -e $f ]] || { echo "exists" >&2; exit 1; }
echo "created ${cpus:-4} ${mem:-8192} ${storage:-null} ${net:-false} $label" > "$f"
for v in ${vols[@]+"${vols[@]}"}; do [[ $v != *:/mnt/devvm-tools ]] || echo "${v%%:*}" > "$STUB_DIR/tools-out"; done ;;
"machine start")
get
[[ ! -e $STUB_DIR/smolvm-start-fails ]] || exit 1
if $mediated; then
[[ -n $inter && ${SMOLVM_INTERCEPTOR_TOKEN:-} =~ ^[0-9a-f]{64}$ ]] || { echo "no interceptor" >&2; exit 1; }
echo "$inter $SMOLVM_INTERCEPTOR_TOKEN" > "$STUB_DIR/smolvm-decider-$name"
{ echo "cidrs $(egress "$name" cidrs)"; echo "hosts $(egress "$name" hosts)"; echo "mediated true"; } > "$eg/$name.new"
mv "$eg/$name.new" "$eg/$name"
else
[[ $(egress "$name" mediated) != true ]] || { echo "requires an external interceptor" >&2; exit 1; }
echo "none ${SMOLVM_INTERCEPTOR_TOKEN-unset}" > "$STUB_DIR/smolvm-decider-$name"
fi
echo "${SSH_AUTH_SOCK-unset}" > "$STUB_DIR/smolvm-agent-$name"
mkdir -p "$STUB_DIR/smolvm-data/$name"
printf '%s\n%s' "${SMOLVM_STUB_PID:-$PPID}" "$(date +%s)$RANDOM$RANDOM" > "$STUB_DIR/smolvm-data/$name/agent.pid"
st=running; put ;;
"machine stop") get; st=stopped; put ;;
"machine delete") rm -f "$f" "$eg/$name" ;;
"machine update")
get
[[ -z $cpus ]] || c=$cpus
[[ -z $mem ]] || m=$mem
[[ -z $storage ]] || s=$storage
[[ -z $net ]] || n=$net
oc=$(egress "$name" cidrs) oh=$(egress "$name" hosts) om=$(egress "$name" mediated)
! $reset || oc="" oh=""
! $nointer || om=false
nc="$oc ${cidrs[*]+"${cidrs[*]}"}" nh="$oh ${hosts[*]+"${hosts[*]}"}"
# shellcheck disable=SC2086 # the lists are words
{ echo "cidrs" $nc; echo "hosts" $nh; echo "mediated ${om:-false}"; } > "$eg/$name"
[[ -z ${nc// /} ]] || n=true
# As smolvm does: what it set, values and all.
for e in ${envs[@]+"${envs[@]}"}; do echo " env: $e"; done
put ;;
"machine data-dir") echo "$STUB_DIR/smolvm-data/$name" ;;
"machine exec")
[[ ! -e $STUB_DIR/exec-fails ]] || exit 1
for ref in ${secrets[@]+"${secrets[@]}"}; do
[[ -r ${ref#*=} ]] || { echo "resolve secret '${ref%%=*}': file_read_failed" >&2; exit 1; }
done
line="${after[*]}"
if [[ $line == *"curl --noproxy"* ]]; then [[ -e $STUB_DIR/net-direct ]] || exit 7; fi
if [[ $line == *"command -v apk"* ]]; then cat "$STUB_DIR/build-libc" 2>/dev/null || echo gnu; exit 0; fi
if [[ $line == *"/etc/ssh/ssh_host_"* ]]; then echo "ssh-ed25519 AAAAstub root@stub"; exit 0; fi
if [[ $line == *"then echo sshd"* ]]; then if [[ -e $STUB_DIR/no-sshd ]]; then echo none; else echo sshd; fi; exit 0; fi
if [[ $line == *"tar -xf - "* ]]; then cat > "$STUB_DIR/sync.tar"; exit 0; fi
if [[ $name == devvm-tools-build && $line == *" bash -s -- "* ]]; then
tout=$(cat "$STUB_DIR/tools-out")
for ((i = 0; i < ${#after[@]}; i++)); do [[ ${after[i]} == -- ]] && break; done
for ((i = i + 3; i < ${#after[@]}; i += 3)); do echo "image ${after[i]}" > "$tout/${after[i]}"; done
cat > /dev/null; exit 0
fi
if [[ $line == *"bash -s"* || $line == *"sh -s"* ]]; then
"${0%/*}/stub-log" "$STUB_DIR/scripts" "$(sed -n 2p)"; cat > /dev/null || true
[[ ! -e $STUB_DIR/script-fails || $line != *"bash -s"* ]] || exit 1
fi ;;
"pack create")
: > "$out"; echo pack > "$out.smolmachine" ;;
esac
+1 -1
View File
@@ -3,7 +3,7 @@
# VM. Logs every call to $STUB_LOG, and runs the git command it's given
# here, on $STUB_DIR/vmfs/DIR (the VM's files, as the limactl stub keeps
# them). With $STUB_DIR/ssh-fails, or for anything else, it fails as ssh
# does. A master connection (-M, a smolvm VM's port forwarder's) reads the script it's fed, answers it with $STUB_DIR/guest-ports (what listens in the VM, as /proc/net/tcp has
# does. A master connection (-M, a VM's port forwarder's) reads the script it's fed, answers it with $STUB_DIR/guest-ports (what listens in the VM, as /proc/net/tcp has
# it) and ".", then waits to be stopped. A link session's master (-M -N -S CONTROL, devvm _links's)
# listens on its control socket until it's stopped, and its -O forward and -O cancel work, but for a
# forward whose ADDRESS:PORT is a line of $STUB_DIR/link-taken, which the VM refuses.