Skip to content

monitor: implement system_powerdown MMP command (closes #88)#116

Open
mvanhorn wants to merge 1 commit intogevico:mainfrom
mvanhorn:osc/88-system-powerdown
Open

monitor: implement system_powerdown MMP command (closes #88)#116
mvanhorn wants to merge 1 commit intogevico:mainfrom
mvanhorn:osc/88-system-powerdown

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

@mvanhorn mvanhorn commented May 8, 2026

Summary

Closes #88

The MMP dispatcher accepted qmp_capabilities, query-status, stop, cont, quit, query-cpus-fast, and system_reset (deferred). system_powerdown returned CommandNotFound, which prevented QMP clients from issuing the standard graceful-shutdown command against machina.

Changes

  • monitor/src/mmp.rs: add a "system_powerdown" arm to dispatch() that reuses the existing MonitorService::quit() path. machina has no separate ACPI shutdown path, so reusing the run-loop quit signal is the semantically equivalent behavior the issue called out.
  • monitor/src/mmp.rs: extend handle_connection() to terminate the TCP session when it sees system_powerdown (previously only quit did this) so a client that issues system_powerdown over TCP no longer leaves the connection stuck and the server returning to incoming() despite quit being requested.
  • tests/src/monitor.rs: add test_mmp_system_powerdown, mirroring the existing test_mmp_quit. Asserts the empty success envelope and is_quit_requested() flips after dispatch.

Verification

Per the workshop description, this is a 4-line dispatch addition; the diff is 18 added lines including the regression test. cargo build -p machina-monitor is clean. make clippy and make test could not be run on this machine (the JIT crate accel/ requires a host x86-64 target via extern "sysv64"); CI on the gevico/machina x86-64 runners will exercise the full quality gates.

Issue ref: #88

The QMP system_powerdown command shuts down the VM. machina has no
separate ACPI shutdown path, so dispatch reuses the existing quit()
path on MonitorService -- semantically equivalent for the embedded
monitor and consistent with how the existing "quit" command reaches
the shutdown signal.

Add a regression test in tests/src/monitor.rs that mirrors the
existing test_mmp_quit, asserting the empty success envelope and
that is_quit_requested() flips to true after dispatch.

Closes gevico#88

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
@zevorn
Copy link
Copy Markdown
Member

zevorn commented May 9, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f9ba1fe3f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread monitor/src/mmp.rs
// QMP system_powerdown shuts down the VM. machina has no
// separate ACPI shutdown path, so reuse quit() which signals
// the run loop to stop -- semantically equivalent here.
s.quit();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Treat system_powerdown as guest request, not forced quit

dispatch() currently maps system_powerdown directly to quit(), which forces the VM to terminate immediately instead of requesting an in-guest powerdown flow. In QMP, system_powerdown is a soft guest request that may be ignored or delayed, so conflating it with quit can cause management clients that expect graceful shutdown semantics to trigger abrupt exits (and possible guest data loss) once they switch from handling CommandNotFound to using this command.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Open Source Workshop] Implement system_powerdown command for MMP monitor

2 participants