diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 66b04f6fb..ec08884e3 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -941,6 +941,9 @@ pub struct DeviceManager { // Flag to force setting the iommu on virtio devices force_iommu: bool, + + // Helps identify if the VM is currently being restored + restoring: bool, } impl DeviceManager { @@ -955,6 +958,7 @@ impl DeviceManager { #[cfg(feature = "acpi")] numa_nodes: NumaNodes, activate_evt: &EventFd, force_iommu: bool, + restoring: bool, ) -> DeviceManagerResult>> { let device_tree = Arc::new(Mutex::new(DeviceTree::new())); @@ -1028,6 +1032,7 @@ impl DeviceManager { #[cfg(target_arch = "aarch64")] gpio_device: None, force_iommu, + restoring, }; let device_manager = Arc::new(Mutex::new(device_manager)); @@ -3637,6 +3642,10 @@ impl DeviceManager { } } + // The devices have been fully restored, we can now update the + // restoring state of the DeviceManager. + self.restoring = false; + Ok(()) } diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 55b300777..6f528373d 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -541,6 +541,7 @@ impl Vm { hypervisor::ClockData, >, activate_evt: EventFd, + restoring: bool, ) -> Result { config .lock() @@ -571,6 +572,7 @@ impl Vm { numa_nodes.clone(), &activate_evt, force_iommu, + restoring, ) .map_err(Error::DeviceManager)?; @@ -796,6 +798,7 @@ impl Vm { #[cfg(all(feature = "kvm", target_arch = "x86_64"))] None, activate_evt, + false, )?; // The device manager must create the devices from here as it is part @@ -865,6 +868,7 @@ impl Vm { #[cfg(all(feature = "kvm", target_arch = "x86_64"))] vm_snapshot.clock, activate_evt, + true, ) } @@ -907,6 +911,7 @@ impl Vm { #[cfg(all(feature = "kvm", target_arch = "x86_64"))] None, activate_evt, + true, ) }