mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: vm, device_manager: Trigger a power button notification via ACPI
Use the ACPI GED device to trigger a notitifcation of type POWER_BUTTON_CHANGED which will ultimately lead to the guest being notified. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
@@ -234,6 +234,12 @@ pub enum Error {
|
||||
|
||||
/// Cannot activate virtio devices
|
||||
ActivateVirtioDevices(device_manager::DeviceManagerError),
|
||||
|
||||
/// Power button not supported
|
||||
PowerButtonNotSupported,
|
||||
|
||||
/// Error triggering power button
|
||||
PowerButton(device_manager::DeviceManagerError),
|
||||
}
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
@@ -1762,6 +1768,18 @@ impl Vm {
|
||||
.activate_virtio_devices()
|
||||
.map_err(Error::ActivateVirtioDevices)
|
||||
}
|
||||
|
||||
pub fn power_button(&self) -> Result<()> {
|
||||
#[cfg(feature = "acpi")]
|
||||
return self
|
||||
.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.notify_power_button()
|
||||
.map_err(Error::PowerButton);
|
||||
#[cfg(not(feature = "acpi"))]
|
||||
Err(Error::PowerButtonNotSupported)
|
||||
}
|
||||
}
|
||||
|
||||
impl Pausable for Vm {
|
||||
|
||||
Reference in New Issue
Block a user