mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 11:22:26 +00:00
vmm: Ensure that allocate_bars() is called before mmio_regions()
The allocate_bars method has a side effect which collates the BARs used for the device and stores them internally. Ensure that any use of this internal state is after the state is created otherwise no MMIO regions will be seen and so none will be mapped. Fixes: #3237 Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
d00eb4aa25
commit
c25bd447a1
@ -2886,7 +2886,7 @@ impl DeviceManager {
|
||||
None
|
||||
};
|
||||
|
||||
let mut vfio_pci_device = VfioPciDevice::new(
|
||||
let vfio_pci_device = VfioPciDevice::new(
|
||||
&self.address_manager.vm,
|
||||
vfio_device,
|
||||
vfio_container,
|
||||
@ -2908,21 +2908,6 @@ impl DeviceManager {
|
||||
id
|
||||
};
|
||||
|
||||
vfio_pci_device
|
||||
.map_mmio_regions(&self.address_manager.vm, || {
|
||||
self.memory_manager.lock().unwrap().allocate_memory_slot()
|
||||
})
|
||||
.map_err(DeviceManagerError::VfioMapRegion)?;
|
||||
|
||||
let mut node = device_node!(vfio_name);
|
||||
|
||||
for region in vfio_pci_device.mmio_regions() {
|
||||
node.resources.push(Resource::MmioAddressRange {
|
||||
base: region.start.0,
|
||||
size: region.length as u64,
|
||||
});
|
||||
}
|
||||
|
||||
let vfio_pci_device = Arc::new(Mutex::new(vfio_pci_device));
|
||||
|
||||
self.add_pci_device(
|
||||
@ -2931,6 +2916,23 @@ impl DeviceManager {
|
||||
pci_device_bdf,
|
||||
)?;
|
||||
|
||||
vfio_pci_device
|
||||
.lock()
|
||||
.unwrap()
|
||||
.map_mmio_regions(&self.address_manager.vm, || {
|
||||
self.memory_manager.lock().unwrap().allocate_memory_slot()
|
||||
})
|
||||
.map_err(DeviceManagerError::VfioMapRegion)?;
|
||||
|
||||
let mut node = device_node!(vfio_name);
|
||||
|
||||
for region in vfio_pci_device.lock().unwrap().mmio_regions() {
|
||||
node.resources.push(Resource::MmioAddressRange {
|
||||
base: region.start.0,
|
||||
size: region.length as u64,
|
||||
});
|
||||
}
|
||||
|
||||
node.pci_bdf = Some(pci_device_bdf);
|
||||
node.pci_device_handle = Some(PciDeviceHandle::Vfio(vfio_pci_device));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user