feat(aarch64): support external graceful shutdown via SendCtrlAltDel#5984
Open
14sea wants to merge 1 commit into
Open
feat(aarch64): support external graceful shutdown via SendCtrlAltDel#598414sea wants to merge 1 commit into
14sea wants to merge 1 commit into
Conversation
Until now `SendCtrlAltDel` was rejected with a 400 on aarch64 and there was no way to request a graceful shutdown of a microVM from the host. Fixes firecracker-microvm#2046. Add a minimal PL061 GPIO controller as an aarch64 MMIO device and describe a `gpio-keys` power button (KEY_POWER) in the FDT. `SendCtrlAltDel` is reused: on x86_64 it still injects CTRL+ALT+DEL through the i8042 device; on aarch64 it drives a short press/release pulse on the virtual power button. A guest with the standard gpio-keys driver and a power-key consumer (e.g. systemd-logind, which defaults to HandlePowerKey=poweroff) then shuts down cleanly and Firecracker exits on the resulting KVM_SYSTEM_EVENT_SHUTDOWN. Details: - The PL061 SPI is declared edge-triggered to match Firecracker's plain irqfd injection (no resample fd). A level-high line would never be de-asserted and the GIC would re-fire it after the guest EOIs, storming the host. - The PL061 register state is saved and restored across snapshots, so the power button keeps working on a restored microVM. The snapshot version is bumped to 11.0.0 accordingly. - The press/release pulse runs synchronously so the two edges stay atomic with respect to other API actions; a concurrent snapshot can never capture the button half-pressed. Validated on aarch64 + KVM hardware: KEY_POWER is delivered to the guest with no interrupt storm, systemd-logind powers the VM off automatically, and the path also works after a snapshot/restore cycle. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: 14sea <wanhuaning@gmail.com>
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.
Changes
Add external graceful shutdown support on aarch64 by reusing the existing
SendCtrlAltDelaction.describe a
gpio-keyspower button (KEY_POWER) in the FDT.SendCtrlAltDel: on x86_64 it still injects CTRL+ALT+DEL through thei8042 device (unchanged); on aarch64 it drives a short, synchronous
press/release pulse on the virtual power button. The API no longer rejects the
action with a
400on aarch64.irqfd injection (no resample fd). A level-high line would never be de-asserted
and the GIC would re-fire it after the guest EOIs, storming the host.
working on a restored microVM. The snapshot version is bumped
10.0.0→11.0.0.(
CONFIG_GPIOLIB,CONFIG_GPIO_PL061,CONFIG_INPUT_KEYBOARD,CONFIG_KEYBOARD_GPIO) toresources/guest_configs/ci.config, and updatedocs/api_requests/actions.md,docs/device-api.mdandCHANGELOG.md.This follows the direction confirmed by @ShadowCurse in
#2046:
no feature gating (always enabled on aarch64), reuse
SendCtrlAltDel, and relyon the
systemd-logindalready present in the CI rootfs.A couple of points worth a maintainer's eye:
ci.configratherthan a separate
debug.config-style fragment, because the integration testsboot the non-debug CI kernels (which only concatenate
ci.config), and thefile already carries the x86 "CTRL+ALT+DEL support" section. Happy to move it
if you'd prefer a dedicated fragment.
test_send_ctrl_alt_delon aarch64. It is keptskipif-skipped on aarch64for now: the kernel config is included here, but a fresh PR runs against the
currently-published guest-kernel artifacts, which do not yet have gpio-keys.
Once the CI guest kernels are rebuilt with this
ci.configchange the skip canbe removed so the existing test exercises the aarch64 path. Would you like me
to drop the skip in this PR, or as a follow-up after the artifacts are
rebuilt?
Hardware validation
Validated on real aarch64 + KVM hardware (RK3568, Ubuntu guest), on this exact
rebased commit:
/proc/interruptsshows the line asEdge; the countincrements by exactly +2 per action (press + release) and host CPU stays
effectively idle (~0.7% over the window). A level storm would peg a CPU.
systemd-logindactive,SendCtrlAltDel→systemd-poweroff→reboot: Power down→KVM_SYSTEM_EVENT→Firecracker exiting successfully. exit_code=0.still takes the interrupt (
+2) and emits a byte-identicalKEY_POWERpress/release event stream on
/dev/input/event0, confirming the PL061interrupt-enable state survives restore.
Reason
Closes #2046. aarch64 previously rejected
SendCtrlAltDelwith a400and had nomechanism to request a graceful shutdown of a microVM from the host, unlike
x86_64. This brings aarch64 to parity using the standard guest gpio-keys path.
License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.PR Checklist
clippy -D warningson bothx86_64 and aarch64 (
tools/devtool buildon aarch64 hardware); CI runs thefull
checkbuild --all.tools/devtool checkstyleto verify that the PR passes theautomated style checks.
how they are solving the problem in a clear and encompassing way.
in the PR.
CHANGELOG.md.Runbook for Firecracker API changes.
integration tests (PL061 device unit tests added; the
test_send_ctrl_alt_delintegration test remains aarch64-skipped pending a gpio-keys CI kernel — see
above).
TODO.rust-vmm.