Files
devvm/testdata/script/ls.txtar
T
w3cjandClaude Opus 5.5 31d1f3c78e feat(smolvm): an experimental smolvm backend, its native features
A second backend, registered beside Lima: each VM is a smolvm machine
(a microVM running its image as a container, no init system), each
image a pack in devvm's data folder.

- internal/backend/smolvm: images built as packs (pack create --from-vm)
  from Ubuntu's container image by its registry digest (or --from's,
  registry images only), base prepared first (prepare.sh: sudo, CA
  certificates, bash, the host's user and uid); systemctl/rc-update
  stand-ins while a build's scripts run (shims.sh); project VMs made
  from a pack with network, CPUs, memory and disk set; after each start
  the loop devices, the tools' mounts and dockerd (services.sh); Exec as
  the VM's user with a login's environment; ports, agent folders, size;
  a record per VM of what smolvm doesn't show. On macOS every machine
  carries the label devvm.data=<data folder> and nothing without it is
  touched (smolvm_machine_foreign); on Linux --state-dir too.
  SMOLVM_USAGE=0, SMOLVM_MACHINE_NAME never passed on. Images used by a
  VM aren't deleted (their pack is read when a disk grows).
- Caps: native for everything but egress-proxy, ssh, ports-all and
  agent-toggle (none until their emulations are reviewed), refused in
  one line naming the VM.
- Interface: two features, ports-all (every port; new VMs' default) and
  agent-toggle (forwarding changed after create), each Lima-native;
  Backend.ToolFormat and ToolsSpec.Format; backend.KeyFiles, the
  backend's own scripts in base's key; --clone requires ssh. Lima's
  image and tool keys are unchanged: the format is hashed only when it
  isn't build.sh's own, and backend files only when there are any.
- Tool images: smolvm's tools build runs tools/build.sh unchanged, then
  remakes each image uncompressed (plain.sh); its format is named by
  plain.sh's hash. tools.Target (libc and format) replaces the libc
  argument; devvm images counts an image current for any backend.
- The proxy reads only the lifeline's first line (smolvm's has the start
  time on a second). guest/sync.sh tells a running systemd by
  /run/systemd/system (Docker's packages install systemctl).
- Messages: smolvm_missing(_fix), smolvm_broken(_fix), smolvm_old(_fix),
  smolvm_host_unsupported, smolvm_machine_foreign, smolvm_update_failed,
  smolvm_script_failed, smolvm_from_registry_only, smolvm_mount_colon,
  smolvm_too_many_ports, smolvm_no_agent, creating_from_image,
  packing_image, pack_failed; doc links to the smolvm page.
- Tests: internal/backend/smolvm (caps, ports, create, only ours, start,
  base build, failed build, set calls, Linux state dir, problems) on
  testdata/stubs/smolvm; testscript smolvm.txtar; TestE2EExecQuoting for
  smolvm; tests/e2e.sh --backend smolvm (the smolvm section: 34 checks);
  existing scripts expect the second backend.
- Docs: new smolvm.md; backends.md's column and the two new rows;
  design.md's smolvm section as built; limits, contributing; AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 01:31:24 -06:00

82 lines
3.1 KiB
Plaintext

# ls: project VMs on every backend, by name, with their status, image,
# .git protection, network policy, backend and folder. Images and build
# VMs aren't listed; a project VM named like an image is.
env DEVVM_MESSAGES=names
env VMS=$XDG_DATA_HOME/devvm/vms
env RUN=$XDG_DATA_HOME/devvm/run
# No VMs: the header alone, and nothing is asked of a backend but its list.
exec devvm ls
cmp stdout header.txt
! stderr .
stub_calls
stdout '^limactl list --json\nsmolvm machine ls --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.
mkdir $WORK/img-foo
cd $WORK/img-foo
exec devvm --no-network-policy --no-git-protect base
exec devvm ls
stdout '^NAME +STATUS +IMAGE +GIT +NET +BACKEND +FOLDER\n'
stdout '^devvm-img-foo-[0-9a-f]{14} +Running +base +off +off +lima +/\S*/img-foo\n\z'
! stdout '^devvm-img-[0-9a-f]{12} '
# Network policy: on while it runs on the hostagent devvm started (here
# the test's runner, which runs on); started some other way since, or a
# failed self-check, unenforced. Stopped, it starts confined next time.
mkdir $WORK/net
cd $WORK/net
exec devvm --network-policy --no-git-protect base
exec sh -c 'n=$(basename "$VMS"/devvm-net-*); echo $PPID > "$LIMA_HOME/$n/ha.pid"; echo "$PPID 1" > "$RUN/$n.started"'
exec devvm ls
stdout '^devvm-net-[0-9a-f]{14} +Running +base +off +on +lima '
exec sh -c 'n=$(basename "$VMS"/devvm-net-*); limactl stop "$n" && limactl start --tty=false "$n"'
exec devvm ls
stdout '^devvm-net-[0-9a-f]{14} +Running +base +off +unenforced +lima '
exec sh -c 'limactl stop "$(basename "$VMS"/devvm-net-*)"'
exec devvm ls
stdout '^devvm-net-[0-9a-f]{14} +Stopped +base +off +on +lima '
exec sh -c 'f=$(ls "$VMS"/devvm-net-*); { grep -v ^net_check= "$f"; echo net_check=unenforced; } > "$WORK/st" && mv "$WORK/st" "$f"'
exec devvm ls
stdout '^devvm-net-[0-9a-f]{14} +Stopped +base +off +unenforced +lima '
# A --clone VM shows clone in GIT, a base from a container image its
# label, and a VM whose creation didn't finish - for what it lacks.
cp $WORK/clone.state $VMS/devvm-cl-0123456789abcd
cp $WORK/from.state $VMS/devvm-from-0123456789abcd
exec sh -c 'printf "devvm-cl-0123456789abcd\ndevvm-from-0123456789abcd Running\ndevvm-half-0123456789abcd\ndevvm-tools-build\n" >> "$STUB_DIR/instances"'
exec devvm ls
stdout '^devvm-cl-0123456789abcd +Stopped +node +clone +on +lima +/p/cl\n'
stdout '^devvm-from-0123456789abcd +Running +image_from from=node:24 image=base +on +off +lima +/p/from\n'
stdout '^devvm-half-0123456789abcd +Stopped +- +- +- +lima +-\n'
! stdout devvm-tools-build
# Sorted by name.
stdout '\ndevvm-cl-.*\ndevvm-from-.*\ndevvm-half-.*\ndevvm-img-foo-.*\ndevvm-net-'
# Lima can't list (not installed): fails, as a VM's state names it; with
# none, the header alone.
env PATH=$DEVVM_BIN
! exec devvm ls
! stdout .
stderr '^devvm: lima_missing$'
rm $VMS
exec devvm ls
cmp stdout $WORK/header.txt
-- header.txt --
NAME STATUS IMAGE GIT NET BACKEND FOLDER
-- clone.state --
image=node
dir=/p/cl
backend=lima
net=on
mode=clone
-- from.state --
image=base
dir=/p/from
from=node:24
backend=lima
net=off
git_protect=on