mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Implement VM pause
In order to pause a VM, we signal all the vCPU threads to get them out of vmx non-root. Once out, the vCPU thread will check for a an atomic pause boolean. If it's set to true, then the thread will park until being resumed. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
committed by
Sebastien Boeuf
parent
80c3fd922a
commit
4ac0cb9cff
@@ -227,6 +227,14 @@ impl Vmm {
|
||||
}
|
||||
}
|
||||
|
||||
fn vm_pause(&mut self) -> result::Result<(), VmError> {
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
vm.pause()
|
||||
} else {
|
||||
Err(VmError::VmNotBooted)
|
||||
}
|
||||
}
|
||||
|
||||
fn vm_shutdown(&mut self) -> result::Result<(), VmError> {
|
||||
if let Some(ref mut vm) = self.vm.take() {
|
||||
vm.shutdown()
|
||||
@@ -414,6 +422,14 @@ impl Vmm {
|
||||
|
||||
sender.send(response).map_err(Error::ApiResponseSend)?;
|
||||
}
|
||||
ApiRequest::VmPause(sender) => {
|
||||
let response = self
|
||||
.vm_pause()
|
||||
.map_err(ApiError::VmPause)
|
||||
.map(|_| ApiResponsePayload::Empty);
|
||||
|
||||
sender.send(response).map_err(Error::ApiResponseSend)?;
|
||||
}
|
||||
ApiRequest::VmmShutdown(sender) => {
|
||||
let response = self
|
||||
.vmm_shutdown()
|
||||
|
||||
Reference in New Issue
Block a user