vmm: Move CpuManager and Vcpu to the new restore design

Every Vcpu is now created with the right state if there's an available
snapshot associated with it. This simplifies the restore logic.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2022-11-30 11:15:33 +01:00
parent b62a40efae
commit 4487c8376b
2 changed files with 53 additions and 72 deletions

View File

@@ -541,7 +541,7 @@ impl Vm {
cpu_manager
.lock()
.unwrap()
.create_boot_vcpus()
.create_boot_vcpus(snapshot_from_id(snapshot, CPU_MANAGER_SNAPSHOT_ID))
.map_err(Error::CpuManager)?;
#[cfg(feature = "tdx")]
@@ -2083,7 +2083,7 @@ impl Vm {
self.cpu_manager
.lock()
.unwrap()
.configure_vcpu(vcpu, entry_point, None)
.configure_vcpu(vcpu, entry_point)
.map_err(Error::CpuManager)?;
}
@@ -2636,17 +2636,6 @@ impl Snapshottable for Vm {
)));
}
if let Some(cpu_manager_snapshot) = snapshot.snapshots.get(CPU_MANAGER_SNAPSHOT_ID) {
self.cpu_manager
.lock()
.unwrap()
.restore(*cpu_manager_snapshot.clone())?;
} else {
return Err(MigratableError::Restore(anyhow!(
"Missing CPU manager snapshot"
)));
}
#[cfg(target_arch = "aarch64")]
self.restore_vgic_and_enable_interrupt(&snapshot)?;