mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: api: Add "power-button" API entry point
This will lead to the triggering of an ACPI button inside the guest in order to cleanly shutdown the guest. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
@@ -677,6 +677,14 @@ impl Vmm {
|
||||
}
|
||||
}
|
||||
|
||||
fn vm_power_button(&mut self) -> result::Result<(), VmError> {
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
vm.power_button()
|
||||
} else {
|
||||
Err(VmError::VmNotRunning)
|
||||
}
|
||||
}
|
||||
|
||||
fn vm_receive_config<T>(
|
||||
&mut self,
|
||||
req: &Request,
|
||||
@@ -1317,6 +1325,14 @@ impl Vmm {
|
||||
.map(|_| ApiResponsePayload::Empty);
|
||||
sender.send(response).map_err(Error::ApiResponseSend)?;
|
||||
}
|
||||
ApiRequest::VmPowerButton(sender) => {
|
||||
let response = self
|
||||
.vm_power_button()
|
||||
.map_err(ApiError::VmPowerButton)
|
||||
.map(|_| ApiResponsePayload::Empty);
|
||||
|
||||
sender.send(response).map_err(Error::ApiResponseSend)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user