From 4517b76a23678d3e40ad601e08a69fbf34481342 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Fri, 2 Dec 2022 14:49:22 +0100 Subject: [PATCH] vm-migration: Rename SnapshotDataSection into SnapshotData Signed-off-by: Sebastien Boeuf --- vm-migration/src/lib.rs | 20 ++++++++++---------- vmm/src/cpu.rs | 6 +++--- vmm/src/device_manager.rs | 4 ++-- vmm/src/memory_manager.rs | 4 ++-- vmm/src/vm.rs | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/vm-migration/src/lib.rs b/vm-migration/src/lib.rs index 5aa397159..20a3fe0c5 100644 --- a/vm-migration/src/lib.rs +++ b/vm-migration/src/lib.rs @@ -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); +pub struct SnapshotData(pub Vec); -impl SnapshotDataSection { +impl SnapshotData { /// Generate the state data from the snapshot data pub fn to_state<'a, T>(&'a self) -> Result 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, + pub snapshot_data: Option, } 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); } diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index d28b53296..0e2d36258 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -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); diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 1e5671e9f..100fad55a 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -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) } diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index dcf802fa2..2e97a82a6 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -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(), )?); diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index df4b71894..a8caa63c2 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -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)