-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AArch64: graceful power-off from external #2047
Conversation
In order to gracefully poweroff microvm from external, firecracker needs to add gpio pl061 controller and gpio-keys node. This commit implements ARM PrimeCell General Purpose Input/Output(PL061) specification. See https://static.docs.arm.com/ddi0190/b/DDI0190.pdf Signed-off-by: Penny Zheng <[email protected]> Signed-off-by: Wei Chen <[email protected]>
Added a new API action to inject GPIO Pin 3 keypress to the microvm. This can be used to trigger a graceful shutdown of the microVM, if the guest has support for gpio pl061 and gpio-keys. This new action is only supported on AArch64. Signed-off-by: Penny Zheng <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this contribution!
Overall PR looks good, but I want to dive-deep on the options available here. I'm afraid using such a specific GPIO mechanism isn't the best solution (although I don't have a better idea right now).
In the future we might want to add ACPI support and handle this consistently across archs and kernel configs.
We'll take a deeper look at the proposal and implementation and come back with more feedback.
timer = ">=0.1.3" | ||
chrono = ">=0.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a different mechanism than relying on timer
(which also brings in chrono
) for multiple reasons:
timer
crate has an incompatibleMPL-2.0
licensetimer
is implemented using a multi-thread timer model: spawns a new thread to do the work after a certain time. This is not in line with our security model/posture where we want to keep strict control over process threads (ourseccomp
filters do not allow spawning new threads).chrono
is a bloated dependency with a long-ish trail of child dependencies. We'd like to avoid it since the use-case for it is simple enough to cover withstd::time
.
Possible alternative: use TimerFd
- for example that's what we use in our Rate Limiter implementation: https://github.com/firecracker-microvm/firecracker/blob/master/src/rate_limiter/src/lib.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks. I'll try to replace them with TimerFd
. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our device model uses a single emulation thread that asynchronously handles device events. TimerFd
would be such a gpio_pl061
device event.
The device needs to use our EventManager
Subscriber interface to register async events.
A simple example device with a single event can be seen in our Serial device
implementation:
firecracker/src/devices/src/legacy/serial.rs
Line 290 in db84b94
impl Subscriber for Serial { |
#[cfg(target_arch = "aarch64")] | ||
pub gpio_pl061: Option<Arc<Mutex<devices::legacy::GPIO>>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to create a gpio
bus (which only currently has this device)?
Hi @acatangiu @dianpopa thanks for the review~ |
Hi @acatangiu @dianpopa
So Wdyt? ☺ |
Hi , Sorry for the late late reply. We want to take some time and think about the design decisions implied by adding support for shutdown on aarch64. We have lots of other priorities so it might take a while until we come back to your PR. Thanks for your contribution and your patience @Pennyzct ! |
Hi @Pennyzct , Last year was a very busy one for us and I wanted to let you know that we are still trying to reach a conclusion regarding your PR. We are still interested in implementing |
Hi @Pennyzct, We reached a conclusion regarding this functionality. Later this year we are planning on adding ACPI PM support in Firecracker, check this out. Having ACPI power management will allow for a more straightforward way of doing reboot on all platforms currently supported without the need to use a dedicated device. As a consequence, I am closing this PR for the moment. Thanks for your implication! |
Reason for This PR
#2046
Description of Changes
Add a new API action
PressGPIOPowerOff
to inject GPIO Pin 3 keypress to the microvm.This can be used to trigger a graceful shutdown of the microVM, if the guest has support for gpio pl061 and gpio-keys.
Firecracker needs to add emulated gpio pl061 controller and gpio-keys node in microvm.
Related commit follows ARM PrimeCell General Purpose Input/Output(PL061) specification.
See https://static.docs.arm.com/ddi0190/b/DDI0190.pdf
License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.
PR Checklist
[Author TODO: Meet these criteria.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]
git commit -s
).unsafe
code is properly documented.firecracker/swagger.yaml
.CHANGELOG.md
.