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

@@ -4445,7 +4445,7 @@ impl Snapshottable for DeviceManager {
}
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
let mut snapshot = Snapshot::default();
let mut snapshot = Snapshot::from_data(SnapshotData::new_from_state(&self.state())?);
// We aggregate all devices snapshots.
for (_, device_node) in self.device_tree.lock().unwrap().iter() {
@@ -4455,9 +4455,6 @@ impl Snapshottable for DeviceManager {
}
}
// Then we store the DeviceManager state.
snapshot.add_data(SnapshotData::new_from_state(&self.state())?);
Ok(snapshot)
}
}