Repository navigation
feat(qemu): pause() and in-place reset() — paused marker, CLI verbs (#375) - #376
mobileskyfi wants to merge 3 commits into
Conversation
…375) - chr.pause() / quickchr pause: monitor `stop` under the machine lock; NICs keep carrier, the guest clock stops. Idempotent; sets a new `paused` marker (never `frozen`). - chr.reset() / quickchr reset [--no-wait] [-T]: monitor `system_reset` in place (same QEMU PID and sockets), REST-ready by default. A paused or frozen guest is resumed by the reset and both markers are cleared. - continue() clears `paused` as well as `frozen`; stop/clean/relaunch/status refresh clear it with the pid. - rest()/exec()/qga() fail fast with the new MACHINE_PAUSED code; shutdown() of a paused guest power-cuts at once and reports `forced`. - list/get show `(paused)`, a `Paused:` detail line and `paused` in --json; help, completions, MANUAL, DESIGN, qemu.instructions, CHANGELOG. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
mobileskyfi
left a comment
There was a problem hiding this comment.
The 101 focused unit tests and the RouterOS 7.25.2 Linux/KVM integration test passed. The inline findings cover pause state after cross-process resume and monitor failures, reset’s effect on live links at timeout, and CLI paths that miss the paused state. I reproduced the stale-handle, monitor-reply, and CLI argument cases with local fixtures.
…s, reset keeps QEMU on timeout - assertNotPaused: the on-disk record wins in both directions, so a handle that saw `paused` stops refusing once another process resumes the VM. - pause/reset/continue: `info status` must parse and every `stop`/`cont`/ `system_reset` needs the final prompt; `/^error/i` replies fail; the marker is set only once QEMU reports the guest held. - buildAndSpawnQemu clears `paused` and sets `frozen` from the launch before any pid or record is saved; the foreground exit also drops the old pid. - snapshot.load: a failed loadvm resumes the guest only if it was running. - reset: a REST-wait timeout keeps QEMU and its links up (BOOT_TIMEOUT with the report), instead of the continue-style stop. - CLI: `get` prints a paused report instead of live reads; `qga` refuses a paused machine; `continue`/`reset` refuse a valueless --timeout-extra/-T. - Tests: exact monitor sequences, strict-reply cases, reverse stale handle, snapshot-load on a paused guest, spawn markers, CLI get/qga/-T, and a RAM sentinel across the live paused reset. snapshot-budgets stub grows `info status`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t pause survives without a reboot - Morpheus (Intel Mac, HVF, QEMU 11.1.1): the first `stop` after a boot does not freeze guest time, and a first pause of 20 s or more crashes the guest kernel on `cont` (RouterOS reboots in the same QEMU). Later pauses freeze the clock as on KVM. Linux/KVM re-checked: a 30 s first pause straight after boot is clean. Documented in MANUAL and qemu.instructions; follow-up #377. - pause-reset integration: a RAM :global set before pause() must survive continue(), so a resume that came back through a reboot fails the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
macOS grounding (Morpheus)Environment: macOS 26.6.2, Intel x86_64, HVF (
Probe (
Linux/KVM re-check: a 30 s pause straight after boot (uptime 21 s) kept a RAM What changed (0e7760a):
Linux/KVM at 0e7760a: |
|
macOS re-run at
|
Closes #375.
What
chr.pause()/quickchr pause <name>— QEMU monitorstopunder the machine lock. QEMU, its sockets and every NIC's carrier stay up (a hung switch, not a pulled cable). A/^error/ireply isPROCESS_FAILEDand sets no marker. An already-held guest only gets the marker. A stopped machine isMACHINE_STOPPEDand leaves clean state.chr.reset({ wait, timeoutExtra })/quickchr reset <name> [--no-wait] [-T <s>]— monitorsystem_reseton that machine only: same QEMU PID, every socket kept, RouterOS cold-boots, REST-ready by default (same wait andBOOT_TIMEOUTcapture ascontinue(), now shared inwaitAfterResume()). Far-end carrier is not touched; MANUAL showsset --linkon the peers around it.pausedmarker onMachineState, separate fromfrozen(doc comment says how they differ).continue()clears both.finalizeStoppedState(),markMachineStopped(),clean(), the device-mode relaunch and_launchExistingclear it with the pid.statusstays"running".list/get:(paused)in the table, aPaused:line in the detail view,pausedin--json.Decisions to review
system_reset, QEMU leaves a held guest inpaused (prelaunch).reset()checksinfo statusand sendscont, then clears both markers. A reset always ends with RouterOS booting. Staying held would add nothing that apause()after the reset doesn't already give, andreset()could not keep its REST-ready promise.exec/restagainst a paused machine: fail fast, not documented waits.rest(),exec()(every transport) andqga()throw a newMACHINE_PAUSEDcode at once. They read the marker frommachine.json, so a handle made before aquickchr pausein another process still sees it.shutdown()of a paused guest power-cuts at once and reportsforced(with arequestErrorthat says why) instead of waiting out its timeout.pause()never touchesfrozen; pausing a frozen machine setspausedbeside it.Docs
MANUAL (
pause,resetsections with the #364 grounded facts: frozen clock, SIGSTOP vs. watchdog, backpressure; the library table and interface; the error-code table),qemu.instructions.md(durable QEMU facts), DESIGN.md (decision record), CHANGELOG.Tests
test/unit/pause-reset.test.ts(fake monitor that models run state): pause sets the marker and leaves frozen alone; idempotent pause; stop error; dead pid; continue clears; a stale handle sees the on-disk marker;rest/exec/exec --via console/qgafail fast; reset sendscontonly for a held guest and clears both markers; reset error keeps the marker; no-user-NIC refusal; stop, shutdown and status refresh clear the marker.test/unit/cli-pause-reset.test.ts: list markers (table/detail/json), usage errors,exec→MACHINE_PAUSED, help text, option forwarding.test/integration/pause-reset.test.ts: two CHRs on a socket link. Pause keeps the peer's carrier (checked every 1 s for 4 s) while pings get 0 replies; guest requests are refused in under 2 s; continue returns REST-ready and pings flow; reset keeps the same PID, and a RAM:globalis gone afterwards (a real reboot) while the disk config survives; resetting a paused machine resumes it; stop clears the marker.Runs
bun test test/unit/2184 pass / 0 fail;bun run checkclean (the one biome warning was already there); integrationpause-reset1/1 pass (95 s);frozen-continue4/4 pass (regression for thecontinue()refactor).Follow-ups
routeros-quickchrskill in tikoci/routeros-skills should learnpause/reset/MACHINE_PAUSEDonce this merges.🤖 Generated with Claude Code