vmm: add guest exit event path

Introduce a dedicated guest_exit_evt and a matching epoll dispatch
path for guest-triggered shutdowns.

This series is needed because managment software such as libvirt may
still need the Cloud Hypervisor process to stay alive after the guest
has shut down.
Today a guest-triggered shutdown can make the VMM disappear immediately,
which means the managment software can lose track of the VM run-state.

This must only apply to guest-triggered shutdowns. Fatal error paths
and other internal exit paths must keep using the existing VMM exit
handling.

For now GuestExit still calls vmm_shutdown(), so this commit only adds
the separate plumbing and keeps the current behavior unchanged.

On-behalf-of: SAP leander.kohler@sap.com
Signed-off-by: Leander Kohler <leander.kohler@cyberus-technology.de>
This commit is contained in:
Leander Kohler
2026-03-09 16:02:40 +01:00
committed by Rob Bradford
parent dc0e003be0
commit c698075157
3 changed files with 48 additions and 0 deletions
+7
View File
@@ -1080,6 +1080,7 @@ pub struct DeviceManager {
// Exit event
exit_evt: EventFd,
reset_evt: EventFd,
guest_exit_evt: EventFd,
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
id_to_dev_info: HashMap<(DeviceType, String), MmioDeviceInfo>,
@@ -1206,6 +1207,7 @@ impl DeviceManager {
cpu_manager: Arc<Mutex<CpuManager>>,
exit_evt: EventFd,
reset_evt: EventFd,
guest_exit_evt: EventFd,
seccomp_action: SeccompAction,
numa_nodes: NumaNodes,
activate_evt: &EventFd,
@@ -1402,6 +1404,7 @@ impl DeviceManager {
device_tree,
exit_evt,
reset_evt,
guest_exit_evt,
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
id_to_dev_info: HashMap::new(),
seccomp_action,
@@ -1519,6 +1522,9 @@ impl DeviceManager {
self.exit_evt
.try_clone()
.map_err(DeviceManagerError::EventFd)?,
self.guest_exit_evt
.try_clone()
.map_err(DeviceManagerError::EventFd)?,
)?;
}
@@ -1889,6 +1895,7 @@ impl DeviceManager {
interrupt_manager: &dyn InterruptManager<GroupConfig = LegacyIrqGroupConfig>,
reset_evt: EventFd,
exit_evt: EventFd,
_guest_exit_evt: EventFd,
) -> DeviceManagerResult<Option<Arc<Mutex<devices::AcpiGedDevice>>>> {
let vcpus_kill_signalled = self
.cpu_manager