mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
main
7
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e4b44b5994 |
fix(lima): limactl shell never starts a stopped VM past devvm's checks
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]>
|
||
|
|
b6954e1e11 |
refactor(vmname): a VM's name is a vmname.VM, parsed where it's read
vmname.VM is the name of every machine devvm runs on a backend: a project VM, an image's machine (devvm-img-<key>), a build VM and a remake's aside. Fields, parameters, results and map keys that held a VM's name as a string now hold a VM, from the backend interface down to the CLI's --json structs, whose output is byte for byte the same. Boundary parsers, the only places a string becomes a VM: - vmname.Parse: a project VM's name (state's vm.json name, export file names, devvm _links's argument, the forwarder's -vm, project.Nth) - vmname.ParseListed: one path element, for what a backend lists - VM.UnmarshalText: JSON (Lima's list, proxy config and events, links' targets in state, link lists); empty stays no VM - vmname.Image(key), VM.Aside(), and typed constants for Lima's build VMs - msg.M.VM: the VM a message's function took, read back vmname's functions on names became methods (Hash, Slug, Short, Aside, AsideHash, ImageKey, IsProject); Lima's image prefix moved to vmname; vmname.Join joins VM lists. Messages' vm and vm_name fields are typed by the generator. Seven messages whose field took something else became what= (backend_lacks, backend_unreviewed, backend_unreviewed_used, starting, deleting, configuring, running_script) and rm_vm_failed's name=: the text is unchanged, the names-mode scripts follow. Review.RequireFor names an image or the tools being built. Typed sites per package (added lines with vmname.VM, non-test): msg 347 (generated), vm 124, lima 48, backendtest 32, vmssh 31, netpolicy 22, backend 16, gitprotect 14, proxy 11, cli 11, project 10, state 8, ports 6, paths 3, sshagent 2, sshconfig 2, tools 2. The structure test's owners rule now fails on a field, parameter or result named for a VM (vm, vms, otherVM, vmName) typed string, []string or map[string]…, and on converting anything but a literal to vmname.VM outside the files it lists; internal/stubtest is free. depguard holds internal/vmname to the standard library, and the proxy may import it. ParseListed and UnmarshalText refuse a name starting with -, which would read as a flag in limactl's argv, and vmname.Image refuses a key that's empty, holds a / or NUL, or makes a project VM's name, so Lima's ImageSize and DeleteImage no longer check it themselves. The check also fails on a *string VM name and an alias of vmname.VM, and says what it doesn't see. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ab125b1af6 |
fix(lima): tidy the remount restart's failure paths
A review of the remount restart found its failure paths loose: - A restart whose limactl stop failed returned the plain message, and the caller then stopped the VM's proxy with the VM still running. Now a folder still mounted with the old mode is warned of and the VM goes on with its proxy, and anything else fails as a logged stop_failed, saying the VM didn't stop. - The interrupt's cleanup was dropped before the restart's stop, so a Ctrl+C during that stop could leave an open-tier VM running. It now stays until any stop in remountProject returns. - The start again repeated the first start's warnings (policy lines, pins, a degraded start). The UI now says each warning once a run, by its name and values, which covers every package's warnings without a flag through each of them. - mount_cache_unmounted and mount_cache_unchecked come only after the restart failed, so they no longer say to run devvm restart: they say the VM is stopped and its console log may say why. mount_cache_remount_failed says the old mode can lose writes and what may hold the folder. Their doc links stay on "When the cache mode changes", which now points to the console log. - The mountinfo check's comments and docs say why it's used (portable: any awk, no util-linux tool but mountpoint), not that Alpine lacks findmnt, which devvm's base layer installs there. - design.md: the stop that fails, the warnings said once, the cleanup through the stop, and the older race of another devvm starting the VM in the gap, which fails closed. Tests: TestRemountRestartStop (the cleanup held through the stop; a stop that fails, mounted or not), TestRemountRestartConfined (each start's undoStart, an interrupt between the starts: one start, the proxy stopped, the one undo kept; a start again whose proxy fails), TestWarnOnce, and mount_cache.txtar's allowlist restart warning of a bad policy line once. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HTFcPrY8FzzQMopN5wgpLQ |
||
|
|
db26def35b |
fix(lima): restart once when the folder can't be mounted again
After a cache-mode change, a Linux VM's start mounts its 9p project
folder again in the guest. On an Alpine --from VM (OpenRC) the umount
succeeds but both mounts fail ("already mounted or mount point busy"),
and devvm stopped the VM with mount_cache_unmounted, though a plain
restart boots with the new mode, which lima.yaml already has.
Now a folder left unmounted, still on the old mode, or a check that
fails gets one restart: the Lima backend writes why in the run log,
stops the VM under one status step (remount_restarting) and returns a
backend.RemountError. The caller, starter.start, starts the VM again
once through startOnce, the same path every start takes, so the restart
gets a new proxy following the new hostagent (the old one exits with
it), the .git pins applied in QEMU's new namespace, its host keys read
again for the new start, and its start recorded. That start's
Want.CheckCache asks Lima for the mountinfo check without the remount;
its outcome is final: unmounted or unchecked stops the VM and fails
with today's messages, another mode warns (its text now says to run
devvm restart to try again). An interrupt gets no restart, and the
cleanup stops the VM once.
- backend: RemountError, Want.CheckCache; backendtest.Fake.StartErr.
- Tests: TestStartSetsProjectCacheOnce (each failure a RemountError,
the run log's line), TestStartRechecksProjectCache (the restart's
check, no second restart), TestRemountInterrupted (no restart),
TestRemountRestart in vm (two starts, a proxy each, no third).
- Stubs: remount-fails (the remount fails and leaves the folder
unmounted until the next start); TestGuestMountOptions covers it.
- mount_cache.txtar: the restart that mounts the folder, and the one
that doesn't, with no third start.
- e2e: the from section's Alpine check expects the launch to succeed
through the restart.
- Docs: backends/lima.md's "When the cache mode changes", design.md's
remount, restart and running-VM paragraphs, tests.md.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HTFcPrY8FzzQMopN5wgpLQ
|
||
|
|
b67ae25b31 |
test(lima): strict conversion and the cache switch on one start
mount_cache.txtar, on a Linux host: a VM an earlier devvm left strict, with no cache mode chosen, after devvm mount-cache none, converts strict to on (git_strict_converted) and switches the cache in the same start, with exactly one limactl edit that sets 9p's cache none, then mounts the folder again; its state has git.mode=on and mount.cache=none. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2406b498d8 |
fix(lima): check the remounted folder without findmnt
After a start that switches a Linux VM's project folder to cache none, devvm checked the remount with findmnt -no OPTIONS, but the Alpine --from base has no util-linux and busybox has no findmnt, so an Alpine VM got an empty answer and was stopped with mount_cache_unchecked. The guest now prints the folder's line of /proc/self/mountinfo, picked by a POSIX awk (lastMount) that busybox runs: the last line whose mount point is the folder exactly, as mountinfo escapes it (mountinfoPath: \040, \011, \012, \134), which awk reads from the environment, as -v would undo the escapes. devvm reads the mount's and its file system's options from it (optionsOfMountinfo), refuses an answer that isn't a mountinfo line, and keeps the 4 KiB cap, the last line and "unknown" for a mode it doesn't know. - TestOptionsOfMountinfo, TestMountinfoPath, TestLastMount: real lines, 9p with and without cache=0x5, Alpine's without optional fields, stacked mounts, a path with a space; awk run on them. - The stubs' guest answers with a mountinfo line; the start tests and the mount_cache script check the new command. - e2e: the from section's Alpine VM, given Lima's mmap with no mode chosen, gets none from devvm mount-cache none at its next start on a Linux host; the e2e helper reads mountinfo too. - design.md and tests.md say how the check works and what e2e checks. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6fd1d846d6 |
fix(lima): cache a Linux VM's project folder with 9p's none
Linux's 9p client loses data with Lima's default cache=mmap for a writable share: a stat() during an extending write() takes the host's stale size and writeback drops the data, so files reach the host empty or cut to 4096 bytes even after fsync (Claude Code's Edit sets it off); and on devvm's Ubuntu 26.04 guest kernel, a lock after a write makes the next read return zeros, which breaks SQLite in any journal mode and Gradle's daemon. macOS's vz VMs use virtiofs and aren't affected. - New VMs on a Linux host record cache mode none in a new mount section of vm.json, and their project folder is made and started with it, as is the folder devvm clone off mounts. VMs whose state has no mode (0.1.0's, and every VM made before this) keep Lima's mmap untouched, with no limactl edit, and each launch warns (mount_cache_unchosen) until devvm mount-cache none. - devvm mount-cache [none], with --json: none is the only mode devvm sets, so any other value is a usage error (mount_cache_invalid); a stopped VM gets it in its next start's one edit, a running one after the restart devvm offers. macOS refuses (backend_lacks), and so does a Linux VM whose folder isn't a 9p mount (mount_cache_no_choice). No -g or config.toml key: every new VM gets none. - The start that changes the mode mounts the folder again in the guest, as cloud-init rewrites fstab only after systemd has mounted it, through the logged runner with a minute's limit (output pipes closed a second after), then checks it with mountpoint and findmnt, reading 4 KiB at most and only the last line: a folder left unmounted stops the VM and fails the start before its shell (mount_cache_unmounted), and so does a check that gets no answer (mount_cache_unchecked); one still mounted with the old mode is warned of (mount_cache_remount_failed), any mode but none or mmap named unknown. An interrupt meanwhile, on any tier, leaves a cleanup that stops the VM, the one stop then. A launch into a running VM asks the guest, in words, whether its folder is a mount point, and refuses one that isn't (project_unmounted) or whose check fails or gives no answer (project_unchecked). A stored mmap, from a build before none alone, reads as none chosen, and devvm clone off records none for its new mount; any other mode is refused naming vm.json. - backend: FeatureMountCache (native on Linux, none on macOS, built on project-mount), Want.ProjectCache, Instance.ProjectCache, CacheModes. - lima: mount rewrites keep only the sshfs and 9p settings devvm knows where they differ from Lima's defaults, and drop the rest for Lima to fill in, so lima.yaml never freezes a default; same() compares the cache where devvm sets one. Build VMs' writable output folders (tools, --from) get none. - tools: an EROFS tool image that ends before its superblock does, or is shorter than its superblock says, as a build under mmap could leave one, counts as not built, so the next build makes it again; a build's short output is refused. The fakes' tool images are a page (backendtest.ToolImage). - The limactl stub lists QEMU's vmType, fills in 9p cache defaults on Linux, and answers the remount's check. - Docs: backends/lima (the project folder's cache, when it changes, programs that map files for writing, SQLite), using/limits, using/clone, commands, internals/lima, internals/backends, the design note (both mmap bugs, why none alone, the remount, tool images, the e2e findings), the CLI reference and the cli skill. - Tests: TestProjectCache, TestMountRoundTrip, TestStartSetsProjectCacheOnce (the remount's outcomes), TestCutShort, TestBuiltCutShort, TestGuestMountOptions, TestFilledMounts, TestUpCacheMode, TestWarnMountCache, TestCacheAtNextStart, TestSwitchCache, TestSetMountCache, TestCheckStateCache, the mount_cache CLI test, clone_switch and the 0.1.0 fixture on Linux, and e2e's projectMountCache (findmnt, a stat-while-write loop, SQLite's journals, a shared writable mmap refused, the opt-in switch of an unchosen VM, what mmap does reported, macOS unchanged). Co-Authored-By: Claude Opus 5.5 <[email protected]> |