Skip to content
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

Implement the infrastructure to support sending shut down signals to the guest #163

Merged
merged 5 commits into from
Feb 13, 2024

Conversation

slp
Copy link
Contributor

@slp slp commented Feb 9, 2024

This PR implementes the required infrastructure to support sending a shut down signal to request the guest to orderly shutdown, and a first interface for macOS/aarch64 (should be easily portable to Linux/aarch64 too) based on the PL061 GPIO.

Consumers of the EFI variant of library can request an eventfd file descriptor with the new krun_get_shutdown_eventfd function, which can be used to trigger the signal by simply writing to it.

This PR also extends the boot_efi example to illustrate how to use it.

In macOS eventfd is emulated with a pipe pair. To be able to export the
EventFd to library consumers we need to be able to expose the write side
of the pipe. Do this by adding a new "get_write_fd" method in our
EventFd wrapper.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Extend the API to allow consumers of the library to grab a file
descriptor to signal the guest to shut down orderly.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Import a PL061-based GPIO to have an interface in the guest to send our
shut down signal. This device, along with its FDT entry, will instruct
Linux to enable a gpio-keys interface to receive key events.

When a consumer of the library writes to the eventfd received from
krun_get_shutdown_eventfd(), this device will send a key press event
followed by a key release event, for the key code KEY_RESTART. We're
using KEY_RESTART instead of KEY_POWEROFF because it's easier to
identify a vCPU exiting for a reboot than for a poweroff.

For the moment we're only implementing support on macOS/aarch64, but
should be possible to work mostly in the same way on Linux/aarch64.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Extend the "boot_efi" example to demonstrate how to grab the eventfd for
the shutdown signal and use to send a request to the guest to shut down
orderly.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Always build net config, previously gated behind the "net" feature, to
simplify code and avoid clippy warnings on shared paths.

Signed-off-by: Sergio Lopez <slp@redhat.com>
@slp slp merged commit 916f47e into containers:main Feb 13, 2024
5 checks passed
@slp slp deleted the add-pl061 branch February 13, 2024 10:57
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.

1 participant