mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
hypervisor: implement pause/resume API for MSHV
Implementing pause/Resume API for MSHV. Here we set/reset the partition property(TIME_FREEZE) Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
parent
3fe9b87736
commit
aabfc9513e
@ -2076,4 +2076,36 @@ impl vm::Vm for MshvVm {
|
||||
fn get_preferred_target(&self, kvi: &mut VcpuInit) -> vm::Result<()> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
/// Pause the VM
|
||||
fn pause(&self) -> vm::Result<()> {
|
||||
// Freeze the partition
|
||||
self.fd
|
||||
.set_partition_property(
|
||||
hv_partition_property_code_HV_PARTITION_PROPERTY_TIME_FREEZE,
|
||||
1u64,
|
||||
)
|
||||
.map_err(|e| {
|
||||
vm::HypervisorVmError::SetVmProperty(anyhow!(
|
||||
"Failed to set partition property: {}",
|
||||
e
|
||||
))
|
||||
})
|
||||
}
|
||||
|
||||
/// Resume the VM
|
||||
fn resume(&self) -> vm::Result<()> {
|
||||
// Resuming the partition using TIME_FREEZE property
|
||||
self.fd
|
||||
.set_partition_property(
|
||||
hv_partition_property_code_HV_PARTITION_PROPERTY_TIME_FREEZE,
|
||||
0u64,
|
||||
)
|
||||
.map_err(|e| {
|
||||
vm::HypervisorVmError::SetVmProperty(anyhow!(
|
||||
"Failed to set partition property: {}",
|
||||
e
|
||||
))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -231,6 +231,10 @@ pub enum HypervisorVmError {
|
||||
///
|
||||
#[error("Failed to complete isolated import: {0}")]
|
||||
CompleteIsolatedImport(#[source] anyhow::Error),
|
||||
/// Failed to set VM property
|
||||
///
|
||||
#[error("Failed to set VM property: {0}")]
|
||||
SetVmProperty(#[source] anyhow::Error),
|
||||
}
|
||||
///
|
||||
/// Result type for returning from a function
|
||||
|
Loading…
Reference in New Issue
Block a user