vm-migration: Define the Snapshottable and Transportable traits

A Snapshottable component can snapshot itself and
provide a MigrationSnapshot payload as a result.

A MigrationSnapshot payload is a map of component IDs to a list of
migration sections (MigrationSection). As component can be made of
several Migratable sub-components (e.g. the DeviceManager and its
device objects), a migration snapshot can be made of multiple snapshot
itself.
A snapshot is a list of migration sections, each section being a
component state snapshot. Having multiple sections allows for easier and
backward compatible migration payload extensions.

Once created, a migratable component snapshot may be transported and this
is what the Transportable trait defines, through 2 methods: send and recv.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
This commit is contained in:
Samuel Ortiz
2019-05-02 00:59:51 +08:00
committed by Rob Bradford
parent 2d17f4384a
commit 1b1a2175ca
25 changed files with 788 additions and 615 deletions

View File

@@ -26,8 +26,8 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Barrier, Mutex};
use std::thread;
use std::{fmt, io, result};
use vm_device::{Migratable, MigratableError, Pausable, Snapshotable};
use vm_memory::{Address, GuestAddress, GuestAddressSpace, GuestMemoryAtomic, GuestMemoryMmap};
use vm_migration::{Migratable, MigratableError, Pausable, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd;
use vmm_sys_util::signal::{register_signal_handler, SIGRTMIN};
@@ -1068,5 +1068,6 @@ impl Pausable for CpuManager {
}
}
impl Snapshotable for CpuManager {}
impl Snapshottable for CpuManager {}
impl Transportable for CpuManager {}
impl Migratable for CpuManager {}

View File

@@ -51,11 +51,11 @@ use vm_allocator::SystemAllocator;
use vm_device::interrupt::{
InterruptIndex, InterruptManager, LegacyIrqGroupConfig, MsiIrqGroupConfig,
};
use vm_device::{Migratable, MigratableError, Pausable, Snapshotable};
use vm_memory::guest_memory::FileOffset;
use vm_memory::{
Address, GuestAddress, GuestAddressSpace, GuestRegionMmap, GuestUsize, MmapRegion,
};
use vm_migration::{Migratable, MigratableError, Pausable, Snapshottable, Transportable};
#[cfg(feature = "pci_support")]
use vm_virtio::transport::VirtioPciDevice;
use vm_virtio::transport::VirtioTransport;
@@ -2373,7 +2373,8 @@ impl Pausable for DeviceManager {
}
}
impl Snapshotable for DeviceManager {}
impl Snapshottable for DeviceManager {}
impl Transportable for DeviceManager {}
impl Migratable for DeviceManager {}
#[cfg(feature = "pci_support")]

View File

@@ -27,7 +27,7 @@ use std::path::PathBuf;
use std::sync::mpsc::{Receiver, RecvError, SendError, Sender};
use std::sync::{Arc, Mutex};
use std::{result, thread};
use vm_device::Pausable;
use vm_migration::Pausable;
use vmm_sys_util::eventfd::EventFd;
pub mod api;

View File

@@ -23,6 +23,7 @@ use vm_memory::{
GuestMemory, GuestMemoryAtomic, GuestMemoryMmap, GuestMemoryRegion, GuestRegionMmap,
GuestUsize, MmapRegion,
};
use vm_migration::{Migratable, Pausable, Snapshottable, Transportable};
const HOTPLUG_COUNT: usize = 8;
@@ -884,3 +885,8 @@ impl Aml for MemoryManager {
bytes
}
}
impl Pausable for MemoryManager {}
impl Snapshottable for MemoryManager {}
impl Transportable for MemoryManager {}
impl Migratable for MemoryManager {}

View File

@@ -48,11 +48,11 @@ use std::path::PathBuf;
use std::sync::{Arc, Mutex, RwLock};
use std::{result, str, thread};
use vm_allocator::{GsiApic, SystemAllocator};
use vm_device::{Migratable, MigratableError, Pausable, Snapshotable};
use vm_memory::{
Address, Bytes, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryMmap,
GuestMemoryRegion, GuestUsize,
};
use vm_migration::{Migratable, MigratableError, Pausable, Snapshottable, Transportable};
use vmm_sys_util::eventfd::EventFd;
use vmm_sys_util::terminal::Terminal;
@@ -966,7 +966,8 @@ impl Pausable for Vm {
}
}
impl Snapshotable for Vm {}
impl Snapshottable for Vm {}
impl Transportable for Vm {}
impl Migratable for Vm {}
#[cfg(test)]