mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
@@ -2508,7 +2508,6 @@ impl Snapshottable for Vm {
|
||||
})?
|
||||
};
|
||||
|
||||
let mut vm_snapshot = Snapshot::default();
|
||||
let vm_snapshot_data = serde_json::to_vec(&VmSnapshot {
|
||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||
clock: self.saved_clock,
|
||||
@@ -2517,6 +2516,8 @@ impl Snapshottable for Vm {
|
||||
})
|
||||
.map_err(|e| MigratableError::Snapshot(e.into()))?;
|
||||
|
||||
let mut vm_snapshot = Snapshot::from_data(SnapshotData(vm_snapshot_data));
|
||||
|
||||
let (id, snapshot) = {
|
||||
let mut cpu_manager = self.cpu_manager.lock().unwrap();
|
||||
(cpu_manager.id(), cpu_manager.snapshot()?)
|
||||
@@ -2532,7 +2533,6 @@ impl Snapshottable for Vm {
|
||||
(device_manager.id(), device_manager.snapshot()?)
|
||||
};
|
||||
vm_snapshot.add_snapshot(id, snapshot);
|
||||
vm_snapshot.add_data(SnapshotData(vm_snapshot_data));
|
||||
|
||||
event!("vm", "snapshotted");
|
||||
Ok(vm_snapshot)
|
||||
|
||||
Reference in New Issue
Block a user