mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 03:12:27 +00:00
pci: vfio: Implement Migratable for VfioPciDevice
Based on the VfioCommon implementation, the VfioPciDevice now implements the Migratable trait. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
49069d8474
commit
3b59e57001
@ -30,7 +30,9 @@ use vm_device::interrupt::{
|
|||||||
};
|
};
|
||||||
use vm_device::{BusDevice, Resource};
|
use vm_device::{BusDevice, Resource};
|
||||||
use vm_memory::{Address, GuestAddress, GuestUsize};
|
use vm_memory::{Address, GuestAddress, GuestUsize};
|
||||||
use vm_migration::{MigratableError, Pausable, Snapshot, Snapshottable, VersionMapped};
|
use vm_migration::{
|
||||||
|
Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable, VersionMapped,
|
||||||
|
};
|
||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
@ -1616,3 +1618,31 @@ impl PciDevice for VfioPciDevice {
|
|||||||
Some(self.id.clone())
|
Some(self.id.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Pausable for VfioPciDevice {}
|
||||||
|
|
||||||
|
impl Snapshottable for VfioPciDevice {
|
||||||
|
fn id(&self) -> String {
|
||||||
|
self.id.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
||||||
|
let mut vfio_pci_dev_snapshot = Snapshot::new(&self.id);
|
||||||
|
|
||||||
|
// Snapshot VfioCommon
|
||||||
|
vfio_pci_dev_snapshot.add_snapshot(self.common.snapshot()?);
|
||||||
|
|
||||||
|
Ok(vfio_pci_dev_snapshot)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn restore(&mut self, snapshot: Snapshot) -> std::result::Result<(), MigratableError> {
|
||||||
|
// Restore VfioCommon
|
||||||
|
if let Some(vfio_common_snapshot) = snapshot.snapshots.get(&self.common.id()) {
|
||||||
|
self.common.restore(*vfio_common_snapshot.clone())?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Transportable for VfioPciDevice {}
|
||||||
|
impl Migratable for VfioPciDevice {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user