fix(vm): binder:vm / TCG compatibility & boot-cache reliability sweep - #248
Merged
Conversation
Compatibility-focused batch hardening the binder:vm (QEMU micro-VM / TCG) backend so a cold software-emulated boot succeeds and repeats cleanly, plus process-safety and cache-correctness fixes. - Accelerator-aware ADB-connect wait: TCG uses a boot-completed-scale deadline instead of the flat 60s so a ~222s cold TCG boot no longer fails `up` before the guest exposes ADB; KVM keeps the short default (#160) - boot_cache: fold resolved -smp/-m geometry into the staleness fingerprint so a geometry edit cold-boots instead of resuming into a mismatch (#161); recreate a snapshot-less overlay before a cold boot so an aborted first boot's dirty COW layer is never reused, sidecar written atomically (#175); re-check QEMU liveness during the ADB wait and fall back to one cold boot when a warm -loadvm resume dies (#176) - compute_cache_key/base_identity break basename ties on content hash, hashing each input exactly once (#235) - doctor: drop the always-failing Magisk rows on the Magisk-less VM guest (#163) - up()/_up_cached() terminate the just-launched QEMU on a timed-out wait instead of orphaning it (#174) - verify the recorded PID still names this instance's QEMU before SIGTERM/SIGKILL on down/restart/destroy (#162) - fix the in-guest ADB port to a single 5555 contract (#237) and harden the adb relay: IPv6 loopback, eth0 address verify, distinct warnings, short-read-safe adbprobe (#238) - align self-contradicting vm.py comments/docstrings with guest-init.sh (#241) - e2e tier-vm-qemu caches the savevm overlay to skip the ~100s cold TCG boot on repeat runs (#49) All changes covered by new tests; full gate green (ruff, mypy --strict src+tests, pytest 100% line+branch, shellcheck/shfmt, yamllint, actionlint, zizmor, codespell, deptry). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P1YsNMpGizhSDDPCBu5cut
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First batch of an automated codebase sweep, focused on
binder: vm(QEMU micro-VM / TCG) compatibility — the one device backend reachable on binderless / no-KVM hosts (incl. the Claude Code web sandbox). These fixes make a cold software-emulated (TCG) boot actually succeed, repeat cleanly via the savevm boot-cache, and not corrupt or orphan state, plus a few process-safety and cache-correctness bugs.Each issue was verified against the real code by a triage pass, implemented with tests, and gate-checked before integration.
Fixes (12 issues)
Compatibility / TCG boot
upand the cold boot_cache path fail before the guest's ADB relay is reachable #160 — accelerator-aware ADB-connect wait: TCG uses a boot-completed-scale deadline instead of the flat 60s, so a ~222s cold TCG boot no longer failsupbefore the guest exposes ADB (KVM keeps the short default).-smp/-mgeometry into the staleness fingerprint, so a geometry edit cold-boots instead of-loadvm-resuming into a mismatch QEMU rejects.-loadvmresume dies, instead of burning the full timeout with a misleading TCG-slowness error.compute_cache_key/base_identitybreak basename ties on content hash (and hash each input exactly once).savevm/snapshot to skip the ~100s TCG boot in e2e/perf jobs #49 — e2etier-vm-qemucaches the savevm overlay (keyed by kernel+rootfs hash) to skip the ~100s cold TCG boot on repeat runs.Process safety / correctness
/proc/<pid>/cmdline) before SIGTERM/SIGKILL ondown/restart/destroy;is_running()and kill-escalation both route through the identity check.up#174 — a timed-outupterminates the QEMU it just launched instead of orphaning it.doctordrops the always-failing Magiskzygisk/denylistrows on the Magisk-less upstream-redroid VM guest, so a healthy VM stops reporting as broken.Relay / guest
5555contract so the relay can't diverge from the QEMUhostfwdtarget.bindv6onlydependency), verifyeth0got10.0.2.15, distinct warnings on bring-up failure, short-read-safeadbprobe.vm.pycomments/docstrings withguest-init.sh(relay attaches only post-boot).Testing
Full local gate green:
ruff check(src+tests),ruff format --check,mypy --strict(src+tests),pytest -p no:randomlywith 100% line+branch coverage (1744 passed, 6 docker-daemon skips),shellcheck -S style -s sh+shfmt -i 4,yamllint,actionlint1.7.12,zizmor1.25.2,codespell2.4.2,deptry0.25.1,uv lock --check, changelog lint.🤖 Generated with Claude Code
https://claude.ai/code/session_01P1YsNMpGizhSDDPCBu5cut
Generated by Claude Code