vm-migration: Rename SnapshotDataSection into SnapshotData

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2022-12-02 14:49:22 +01:00
parent 1b32e2f8b2
commit 4517b76a23
5 changed files with 19 additions and 19 deletions

View File

@ -80,9 +80,9 @@ pub trait Pausable {
/// Splitting a component migration data into different sections
/// allows for easier and forward compatible extensions.
#[derive(Clone, Default, Deserialize, Serialize)]
pub struct SnapshotDataSection(pub Vec<u8>);
pub struct SnapshotData(pub Vec<u8>);
impl SnapshotDataSection {
impl SnapshotData {
/// Generate the state data from the snapshot data
pub fn to_state<'a, T>(&'a self) -> Result<T, MigratableError>
where
@ -109,7 +109,7 @@ impl SnapshotDataSection {
let data = serde_json::to_vec(state)
.map_err(|e| MigratableError::Snapshot(anyhow!("Error serialising: {}", e)))?;
let snapshot_data = SnapshotDataSection(data);
let snapshot_data = SnapshotData(data);
Ok(snapshot_data)
}
@ -124,7 +124,7 @@ impl SnapshotDataSection {
.serialize(&mut data, &T::version_map(), VMM_VERSION)
.map_err(|e| MigratableError::Snapshot(anyhow!("Error serialising: {}", e)))?;
let snapshot_data = SnapshotDataSection(data);
let snapshot_data = SnapshotData(data);
Ok(snapshot_data)
}
@ -139,7 +139,7 @@ impl SnapshotDataSection {
/// For example, a device manager snapshot is the composition of all its
/// devices snapshots. The device manager Snapshot would have no snapshot_data
/// but one Snapshot child per tracked device. Then each device's Snapshot
/// would carry an empty snapshots map but a map of SnapshotDataSection, i.e.
/// would carry an empty snapshots map but a map of SnapshotData, i.e.
/// the actual device snapshot data.
#[derive(Clone, Default, Deserialize, Serialize)]
pub struct Snapshot {
@ -151,7 +151,7 @@ pub struct Snapshot {
/// The Snapshottable component's snapshot data.
/// A map of snapshot sections, indexed by the section ids.
pub snapshot_data: Option<SnapshotDataSection>,
pub snapshot_data: Option<SnapshotData>,
}
impl Snapshot {
@ -169,7 +169,7 @@ impl Snapshot {
T: Serialize,
{
let mut snapshot_data = Snapshot::new(id);
snapshot_data.add_data_section(SnapshotDataSection::new_from_state(state)?);
snapshot_data.add_data_section(SnapshotData::new_from_state(state)?);
Ok(snapshot_data)
}
@ -180,7 +180,7 @@ impl Snapshot {
T: Versionize + VersionMapped,
{
let mut snapshot_data = Snapshot::new(id);
snapshot_data.add_data_section(SnapshotDataSection::new_from_versioned_state(state)?);
snapshot_data.add_data_section(SnapshotData::new_from_versioned_state(state)?);
Ok(snapshot_data)
}
@ -191,8 +191,8 @@ impl Snapshot {
.insert(snapshot.id.clone(), Box::new(snapshot));
}
/// Add a SnapshotDatasection to the component snapshot data.
pub fn add_data_section(&mut self, section: SnapshotDataSection) {
/// Add a SnapshotData to the component snapshot data.
pub fn add_data_section(&mut self, section: SnapshotData) {
self.snapshot_data = Some(section);
}

View File

@ -77,8 +77,8 @@ use vm_memory::ByteValued;
use vm_memory::{Bytes, GuestAddressSpace};
use vm_memory::{GuestAddress, GuestMemoryAtomic};
use vm_migration::{
snapshot_from_id, Migratable, MigratableError, Pausable, Snapshot, SnapshotDataSection,
Snapshottable, Transportable,
snapshot_from_id, Migratable, MigratableError, Pausable, Snapshot, SnapshotData, Snapshottable,
Transportable,
};
use vmm_sys_util::eventfd::EventFd;
use vmm_sys_util::signal::{register_signal_handler, SIGRTMIN};
@ -403,7 +403,7 @@ impl Snapshottable for Vcpu {
// TODO: The special format of the CPU id can be removed once ready to
// break live upgrade.
let mut vcpu_snapshot = Snapshot::new(&format!("{:03}", self.id));
vcpu_snapshot.add_data_section(SnapshotDataSection::new_from_state(&saved_state)?);
vcpu_snapshot.add_data_section(SnapshotData::new_from_state(&saved_state)?);
self.saved_state = Some(saved_state);

View File

@ -95,7 +95,7 @@ use vm_memory::{Address, GuestAddress, GuestUsize, MmapRegion};
use vm_memory::{GuestAddressSpace, GuestMemory};
use vm_migration::{
protocol::MemoryRangeTable, snapshot_from_id, versioned_state_from_id, Migratable,
MigratableError, Pausable, Snapshot, SnapshotDataSection, Snapshottable, Transportable,
MigratableError, Pausable, Snapshot, SnapshotData, Snapshottable, Transportable,
};
use vm_virtio::AccessPlatform;
use vm_virtio::VirtioDeviceType;
@ -4456,7 +4456,7 @@ impl Snapshottable for DeviceManager {
}
// Then we store the DeviceManager state.
snapshot.add_data_section(SnapshotDataSection::new_from_state(&self.state())?);
snapshot.add_data_section(SnapshotData::new_from_state(&self.state())?);
Ok(snapshot)
}

View File

@ -52,7 +52,7 @@ use vm_memory::{
};
use vm_migration::{
protocol::MemoryRange, protocol::MemoryRangeTable, Migratable, MigratableError, Pausable,
Snapshot, SnapshotDataSection, Snapshottable, Transportable, VersionMapped,
Snapshot, SnapshotData, Snapshottable, Transportable, VersionMapped,
};
pub const MEMORY_MANAGER_ACPI_SIZE: usize = 0x18;
@ -2442,7 +2442,7 @@ impl Snapshottable for MemoryManager {
// memory range content for the ranges requiring it.
self.snapshot_memory_ranges = memory_ranges;
memory_manager_snapshot.add_data_section(SnapshotDataSection::new_from_versioned_state(
memory_manager_snapshot.add_data_section(SnapshotData::new_from_versioned_state(
&self.snapshot_data(),
)?);

View File

@ -93,7 +93,7 @@ use vm_memory::{Bytes, GuestAddress, GuestAddressSpace, GuestMemoryAtomic};
use vm_migration::protocol::{Request, Response, Status};
use vm_migration::{
protocol::MemoryRangeTable, snapshot_from_id, Migratable, MigratableError, Pausable, Snapshot,
SnapshotDataSection, Snapshottable, Transportable,
SnapshotData, Snapshottable, Transportable,
};
use vmm_sys_util::eventfd::EventFd;
use vmm_sys_util::signal::unblock_signal;
@ -2521,7 +2521,7 @@ impl Snapshottable for Vm {
vm_snapshot.add_snapshot(self.memory_manager.lock().unwrap().snapshot()?);
vm_snapshot.add_snapshot(self.device_manager.lock().unwrap().snapshot()?);
vm_snapshot.add_data_section(SnapshotDataSection(vm_snapshot_data));
vm_snapshot.add_data_section(SnapshotData(vm_snapshot_data));
event!("vm", "snapshotted");
Ok(vm_snapshot)