vmm: Provide a restoring state to the DeviceManager

In anticipation for creating vhost-user devices in a different way when
being restored compared to a fresh start, this commit introduces a new
boolean created by the Vm depending on the use case, and passed down to
the DeviceManager. In the future, the DeviceManager will use this flag
to assess how vhost-user devices should be created.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2021-08-06 15:39:09 +02:00 committed by Bo Chen
parent 2c54c30435
commit 06729bb3ba
2 changed files with 14 additions and 0 deletions

View File

@ -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<Arc<Mutex<Self>>> {
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(())
}

View File

@ -541,6 +541,7 @@ impl Vm {
hypervisor::ClockData,
>,
activate_evt: EventFd,
restoring: bool,
) -> Result<Self> {
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,
)
}