Files
devvm/testdata/script/space.txtar
T
w3cjandClaude Opus 5.5 f4fd373439 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]>
2026-11-03 11:34:05 -07:00

102 lines
4.4 KiB
Plaintext

# space: each kind of thing devvm keeps, on every backend, with its count,
# size, whether devvm makes it again, what gc frees of it now and what
# frees the rest, then a total; the backends' caches apart. It changes
# nothing: no backend command but listings.
env SHARE=$XDG_DATA_HOME/devvm/tools
# Nothing yet: devvm's state and the total.
exec devvm space
stdout '^WHAT +BACKEND +COUNT +SIZE +KEPT +GC +FREED BY +RETAIN\n'
stdout '^state +- +1 +\S+ +state +- +- +-\n'
stdout '^total +- +- +\S+ +- +- +- +-\n'
! stdout '^images'
! stderr .
# base and foo, then foo is stale; claude's tools, current, an old go a VM
# has and one nothing has; a Lima VM, and the state of one Lima no longer
# has; an export, network and run logs.
mkdir $XDG_CONFIG_HOME/devvm/layers
cp foo.sh $XDG_CONFIG_HOME/devvm/layers/foo.sh
exec devvm build foo
project ag
exec devvm --tools none --agents claude --no-network-policy --no-git-protect
exec devvm rm --force --no-export
exec sh -c 'echo "# edited" >> "$XDG_CONFIG_HOME/devvm/layers/foo.sh"'
exec sh -c 'cd "$SHARE" && echo x > go-1.20.0-0123456789ab.erofs && echo x > go-1.9.0-0123456789ab.erofs'
json_set $SHARE/go-1.20.0-0123456789ab.erofs.json sha256=x libc=gnu backend=lima built=2020-01-01T00:00:00Z
mkdir $VMS/12345612345601/logs $VMS/12345612345602/logs
exec sh -c 'printf "name=devvm-p-12345612345601\nimage=base\ndir=/p\nbackend=lima\nlibc=gnu\ntool_names=go\ntools=go-1.20.0-0123456789ab.erofs\n" > "$VMS/12345612345601/state"'
exec sh -c 'printf "name=devvm-gone-12345612345602\nimage=base\ndir=/q\nbackend=lima\nlibc=gnu\ntool_names=go\n" > "$VMS/12345612345602/state"'
exec sh -c 'echo devvm-p-12345612345601 >> "$STUB_DIR/instances"'
mkdir $DATA/exports $DATA/logs $DATA/cache/mise/2026.1.1
exec sh -c 'echo x > "$DATA/exports/devvm-old-12345612345612-20260101-000000.tar.gz"'
# The VM's network and proxy logs are network logs; the gone one's are
# part of its leftover state.
exec sh -c 'echo x > "$VMS/12345612345601/logs/network.jsonl" && echo x > "$VMS/12345612345601/logs/proxy.log" && echo x > "$VMS/12345612345602/logs/proxy.log"'
stub_reset
exec devvm space
stdout '^VMs +lima +1 +\S+ +only copy +- +devvm rm +-$'
stdout '^images +lima +2 +\S+ +remade +\S+ +gc --backend lima +-$'
stdout '^tools gnu +lima +\d+ +\S+ +remade +- +gc --tool-images +-$'
stdout '^tools - +- +1 +\S+ +remade +\S+ +gc --tool-images +-$'
stdout '^history +- +1 +\S+ +only copy +- +gc --history +-$'
stdout '^network logs +- +2 +\S+ +log +- +devvm rm +-$'
stdout '^run logs +- +\d+ +\S+ +log +- +the newest 20 stay +-$'
stdout '^mise +- +1 +'
stdout '^leftover state +- +1 +\S+ +leftover +- +gc --orphans +-$'
stdout '^total +- +- +\S+ +- +\S+ +- +-$'
! stdout '^devvm.s files'
! stderr .
stub_calls
! stdout 'create|clone|delete|start|stop|edit|rm |prune|shell'
# --backend: that backend's rows alone, with their total, and no other
# backend asked.
stub_reset
exec devvm space --backend lima
stdout '^VMs +lima +1 +'
stdout '^images +lima +2 +'
stdout '^tools gnu +lima +'
! stdout '^(history|state|mise|tools -) '
stdout '^total +- +- +\S+ +- +\S+ +- +-$'
! exec devvm space --backend nope
stderr '^devvm: backend_unknown '
# --json, for scripts.
exec devvm space --json
stdout '^{\n "version": 1,\n "devvm": \[\n'
stdout '"what": "leftover state"'
stdout '"kept": "only copy"'
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=lima\n" > "$VMS/12345612345603/state"'
exec sh -c 'touch "$STUB_DIR/list-fails"'
exec devvm space
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/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=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.
[darwin] mkdir $HOME/Library/Caches/lima/download/by-url-sha256/0123
[darwin] exec sh -c 'echo x > "$HOME/Library/Caches/lima/download/by-url-sha256/0123/data"'
[darwin] exec devvm space
[darwin] stdout '^BACKEND +CACHE +COUNT +SIZE +PATH\nlima +download cache +1 +\S+ +\S+/Library/Caches/lima\n'
[darwin] stderr '^space_caches_note$'
-- foo.sh --
#!/bin/bash
echo foo