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

@@ -399,12 +399,11 @@ impl Snapshottable for Vcpu {
.state()
.map_err(|e| MigratableError::Pause(anyhow!("Could not get vCPU state {:?}", e)))?;
let mut vcpu_snapshot = Snapshot::default();
vcpu_snapshot.add_data(SnapshotData::new_from_state(&saved_state)?);
self.saved_state = Some(saved_state.clone());
self.saved_state = Some(saved_state);
Ok(vcpu_snapshot)
Ok(Snapshot::from_data(SnapshotData::new_from_state(
&saved_state,
)?))
}
}