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:
Samuel Ortiz
2019-10-10 17:16:58 +02:00
committed by Sebastien Boeuf
parent 80c3fd922a
commit 4ac0cb9cff
6 changed files with 88 additions and 2 deletions

View File

@@ -76,6 +76,9 @@ pub enum ApiError {
/// The VM config is missing.
VmMissingConfig,
/// The VM could not be paused.
VmPause(VmError),
/// The VM is not booted.
VmNotBooted,
@@ -132,6 +135,9 @@ pub enum ApiRequest {
/// Request the VM information.
VmInfo(Sender<ApiResponse>),
/// Pause a VM.
VmPause(Sender<ApiResponse>),
/// Shut the previously booted virtual machine down.
/// If the VM was not previously booted or created, the VMM API server
/// will send a VmShutdown error back.
@@ -181,6 +187,9 @@ pub enum VmAction {
/// Reboot a VM
Reboot,
/// Pause a VM
Pause,
}
fn vm_action(api_evt: EventFd, api_sender: Sender<ApiRequest>, action: VmAction) -> ApiResult<()> {
@@ -191,6 +200,7 @@ fn vm_action(api_evt: EventFd, api_sender: Sender<ApiRequest>, action: VmAction)
VmAction::Delete => ApiRequest::VmDelete(response_sender),
VmAction::Shutdown => ApiRequest::VmShutdown(response_sender),
VmAction::Reboot => ApiRequest::VmReboot(response_sender),
VmAction::Pause => ApiRequest::VmPause(response_sender),
};
// Send the VM request.
@@ -218,6 +228,10 @@ pub fn vm_reboot(api_evt: EventFd, api_sender: Sender<ApiRequest>) -> ApiResult<
vm_action(api_evt, api_sender, VmAction::Reboot)
}
pub fn vm_pause(api_evt: EventFd, api_sender: Sender<ApiRequest>) -> ApiResult<()> {
vm_action(api_evt, api_sender, VmAction::Pause)
}
pub fn vm_info(api_evt: EventFd, api_sender: Sender<ApiRequest>) -> ApiResult<VmInfo> {
let (response_sender, response_receiver) = channel();