mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Add memory hotplug support to VFIO PCI devices
Extend the update_memory() method from DeviceManager so that VFIO PCI devices can update their DMA mappings to the physical IOMMU, after a memory hotplug has been performed. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -270,6 +270,10 @@ pub enum DeviceManagerError {
|
|||||||
|
|
||||||
/// Cannot find a memory range for virtio-mem memory
|
/// Cannot find a memory range for virtio-mem memory
|
||||||
VirtioMemRangeAllocation,
|
VirtioMemRangeAllocation,
|
||||||
|
|
||||||
|
/// Failed updating guest memory for VFIO PCI device.
|
||||||
|
#[cfg(feature = "pci_support")]
|
||||||
|
UpdateMemoryForVfioPciDevice(VfioPciError),
|
||||||
}
|
}
|
||||||
pub type DeviceManagerResult<T> = result::Result<T, DeviceManagerError>;
|
pub type DeviceManagerResult<T> = result::Result<T, DeviceManagerError>;
|
||||||
|
|
||||||
@@ -1886,6 +1890,22 @@ impl DeviceManager {
|
|||||||
.map_err(DeviceManagerError::UpdateMemoryForVirtioDevice)?;
|
.map_err(DeviceManagerError::UpdateMemoryForVirtioDevice)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Take care of updating the memory for VFIO PCI devices.
|
||||||
|
#[cfg(feature = "pci_support")]
|
||||||
|
{
|
||||||
|
for (_, any_device) in self.pci_devices.iter() {
|
||||||
|
if let Ok(vfio_pci_device) =
|
||||||
|
Arc::clone(any_device).downcast::<Mutex<VfioPciDevice>>()
|
||||||
|
{
|
||||||
|
vfio_pci_device
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.update_memory(_new_region)
|
||||||
|
.map_err(DeviceManagerError::UpdateMemoryForVfioPciDevice)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user