mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: device_manager: Implement the Pausable trait
Since the Snapshotable placeholder and Migratable traits are provided as well, the DeviceManager object and all its objects are now Migratable. All Migratable devices are tracked as Arc<Mutex<dyn Migratable>> references. Keeping track of all migratable devices allows for implementing the Migratable trait for the DeviceManager structure, making the whole device model potentially migratable. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
@@ -43,6 +43,7 @@ use std::os::unix::io::FromRawFd;
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
use std::{result, str, thread};
|
||||
use vm_allocator::{GsiApic, SystemAllocator};
|
||||
use vm_device::{MigratableError, Pausable};
|
||||
use vm_memory::guest_memory::FileOffset;
|
||||
use vm_memory::{
|
||||
Address, Bytes, Error as MmapError, GuestAddress, GuestMemory, GuestMemoryMmap,
|
||||
@@ -145,6 +146,12 @@ pub enum Error {
|
||||
|
||||
/// Capability missing
|
||||
CapabilityMissing(Cap),
|
||||
|
||||
/// Cannot pause devices
|
||||
PauseDevices(MigratableError),
|
||||
|
||||
/// Cannot resume devices
|
||||
ResumeDevices(MigratableError),
|
||||
}
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
@@ -627,6 +634,7 @@ impl Vm {
|
||||
.unwrap()
|
||||
.pause()
|
||||
.map_err(Error::CpuManager)?;
|
||||
self.devices.pause().map_err(Error::PauseDevices)?;
|
||||
|
||||
*state = new_state;
|
||||
|
||||
@@ -639,6 +647,7 @@ impl Vm {
|
||||
|
||||
state.valid_transition(new_state)?;
|
||||
|
||||
self.devices.resume().map_err(Error::ResumeDevices)?;
|
||||
self.cpu_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
|
||||
Reference in New Issue
Block a user