vm-migration: Introduce new constructor for Snapshot

This simplifies the Snapshot creation as we expect a SnapshotData to be
provided most of the time.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2022-12-02 16:03:50 +01:00
parent 4ae6b595d7
commit 3931b99d4e
5 changed files with 20 additions and 30 deletions

View File

@@ -2428,8 +2428,6 @@ impl Snapshottable for MemoryManager {
}
fn snapshot(&mut self) -> result::Result<Snapshot, MigratableError> {
let mut memory_manager_snapshot = Snapshot::default();
let memory_ranges = self.memory_range_table(true)?;
// Store locally this list of ranges as it will be used through the
@@ -2442,11 +2440,9 @@ impl Snapshottable for MemoryManager {
// memory range content for the ranges requiring it.
self.snapshot_memory_ranges = memory_ranges;
memory_manager_snapshot.add_data(SnapshotData::new_from_versioned_state(
Ok(Snapshot::from_data(SnapshotData::new_from_versioned_state(
&self.snapshot_data(),
)?);
Ok(memory_manager_snapshot)
)?))
}
}