mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-01 17:35:19 +00:00
pci, vmm: Add migratable support to VFIO devices
Based on recent changes to VfioPciDevice, the VFIO devices can now be migrated. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
f48b05eee6
commit
c021dda267
@ -1153,6 +1153,7 @@ impl VfioPciDevice {
|
|||||||
legacy_interrupt_group: Option<Arc<dyn InterruptSourceGroup>>,
|
legacy_interrupt_group: Option<Arc<dyn InterruptSourceGroup>>,
|
||||||
iommu_attached: bool,
|
iommu_attached: bool,
|
||||||
bdf: PciBdf,
|
bdf: PciBdf,
|
||||||
|
restoring: bool,
|
||||||
) -> Result<Self, VfioPciError> {
|
) -> Result<Self, VfioPciError> {
|
||||||
let device = Arc::new(device);
|
let device = Arc::new(device);
|
||||||
device.reset();
|
device.reset();
|
||||||
@ -1185,8 +1186,13 @@ impl VfioPciDevice {
|
|||||||
vfio_wrapper: Arc::new(vfio_wrapper) as Arc<dyn Vfio>,
|
vfio_wrapper: Arc::new(vfio_wrapper) as Arc<dyn Vfio>,
|
||||||
};
|
};
|
||||||
|
|
||||||
common.parse_capabilities(bdf);
|
// No need to parse capabilities from the device if on the restore path.
|
||||||
common.initialize_legacy_interrupt()?;
|
// The initialization will be performed later when restore() will be
|
||||||
|
// called.
|
||||||
|
if !restoring {
|
||||||
|
common.parse_capabilities(bdf);
|
||||||
|
common.initialize_legacy_interrupt()?;
|
||||||
|
}
|
||||||
|
|
||||||
let vfio_pci_device = VfioPciDevice {
|
let vfio_pci_device = VfioPciDevice {
|
||||||
id,
|
id,
|
||||||
|
@ -2978,10 +2978,6 @@ impl DeviceManager {
|
|||||||
device_cfg: &mut DeviceConfig,
|
device_cfg: &mut DeviceConfig,
|
||||||
) -> DeviceManagerResult<(PciBdf, String)> {
|
) -> DeviceManagerResult<(PciBdf, String)> {
|
||||||
let vfio_name = if let Some(id) = &device_cfg.id {
|
let vfio_name = if let Some(id) = &device_cfg.id {
|
||||||
if self.device_tree.lock().unwrap().contains_key(id) {
|
|
||||||
return Err(DeviceManagerError::DeviceIdAlreadyInUse);
|
|
||||||
}
|
|
||||||
|
|
||||||
id.clone()
|
id.clone()
|
||||||
} else {
|
} else {
|
||||||
let id = self.next_device_name(VFIO_DEVICE_NAME_PREFIX)?;
|
let id = self.next_device_name(VFIO_DEVICE_NAME_PREFIX)?;
|
||||||
@ -3090,6 +3086,7 @@ impl DeviceManager {
|
|||||||
legacy_interrupt_group,
|
legacy_interrupt_group,
|
||||||
device_cfg.iommu,
|
device_cfg.iommu,
|
||||||
pci_device_bdf,
|
pci_device_bdf,
|
||||||
|
self.restoring,
|
||||||
)
|
)
|
||||||
.map_err(DeviceManagerError::VfioPciCreate)?;
|
.map_err(DeviceManagerError::VfioPciCreate)?;
|
||||||
|
|
||||||
@ -3111,7 +3108,7 @@ impl DeviceManager {
|
|||||||
})
|
})
|
||||||
.map_err(DeviceManagerError::VfioMapRegion)?;
|
.map_err(DeviceManagerError::VfioMapRegion)?;
|
||||||
|
|
||||||
let mut node = device_node!(vfio_name);
|
let mut node = device_node!(vfio_name, vfio_pci_device);
|
||||||
|
|
||||||
// Update the device tree with correct resource information.
|
// Update the device tree with correct resource information.
|
||||||
node.resources = new_resources;
|
node.resources = new_resources;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user