From 3edaa8adb69056b4480274bc3d5ee25d997d6dcc Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Thu, 2 Jun 2022 18:02:36 +0200 Subject: [PATCH] vmm: Ensure restore matches boot sequence The vCPU is created and set after all the devices on a VM's boot. There's no reason to follow a different order on the restore codepath as this could cause some unexpected behaviors. Signed-off-by: Sebastien Boeuf --- vmm/src/vm.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index e18be4816..fdf69c01a 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -2753,17 +2753,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" - ))); - } - if let Some(device_manager_snapshot) = snapshot.snapshots.get(DEVICE_MANAGER_SNAPSHOT_ID) { self.device_manager .lock() @@ -2775,6 +2764,17 @@ 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)?;