From 86e7f07485cfea12e5d4b29eb70d228a54f0190d Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Fri, 4 Nov 2022 14:29:06 +0100 Subject: [PATCH] vmm: cpu: Create vCPUs before the DeviceManager Moving the creation of the vCPUs before the DeviceManager gets created will allow for the aarch64 vGIC to be created before the DeviceManager as well in a follow up patch. The end goal being to adopt the same creation sequence for both x86_64 and aarch64, and keeping in mind that the vGIC requires every vCPU to be created. Signed-off-by: Sebastien Boeuf --- vmm/src/cpu.rs | 5 ++--- vmm/src/vm.rs | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 4e693f98d..cd0489f5f 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -2082,10 +2082,9 @@ impl Snapshottable for CpuManager { fn restore(&mut self, snapshot: Snapshot) -> std::result::Result<(), MigratableError> { for (cpu_id, snapshot) in snapshot.snapshots.iter() { + let cpu_id = cpu_id.parse::().unwrap(); info!("Restoring VCPU {}", cpu_id); - let vcpu = self - .create_vcpu(cpu_id.parse::().unwrap()) - .map_err(|e| MigratableError::Restore(anyhow!("Could not create vCPU {:?}", e)))?; + let vcpu = self.vcpus[cpu_id].clone(); self.configure_vcpu(vcpu, None, Some(*snapshot.clone())) .map_err(|e| { MigratableError::Restore(anyhow!("Could not configure vCPU {:?}", e)) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 7d7273c51..4e2455a15 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -538,6 +538,12 @@ impl Vm { ) .map_err(Error::CpuManager)?; + cpu_manager + .lock() + .unwrap() + .create_boot_vcpus() + .map_err(Error::CpuManager)?; + #[cfg(feature = "tdx")] let dynamic = !tdx_enabled; #[cfg(not(feature = "tdx"))]