Skip to content

Commit 51875de

Browse files
committed
vmm: device_manager: Map MMIO regions to the guest correctly
To correctly map MMIO regions to the guest, we will need to wait for valid MMIO region information which is generated from 'PciDevice::allocate_bars()' (as a part of 'DeviceManager::add_pci_device()'). Signed-off-by: Bo Chen <[email protected]>
1 parent c073736 commit 51875de

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

vmm/src/device_manager.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3345,12 +3345,6 @@ impl DeviceManager {
33453345
)
33463346
.map_err(DeviceManagerError::VfioUserCreate)?;
33473347

3348-
vfio_user_pci_device
3349-
.map_mmio_regions(&self.address_manager.vm, || {
3350-
self.memory_manager.lock().unwrap().allocate_memory_slot()
3351-
})
3352-
.map_err(DeviceManagerError::VfioUserMapRegion)?;
3353-
33543348
let memory = self.memory_manager.lock().unwrap().guest_memory();
33553349
let vfio_user_mapping = Arc::new(VfioUserDmaMapping::new(client, Arc::new(memory)));
33563350
for virtio_mem_device in self.virtio_mem_devices.iter() {
@@ -3382,6 +3376,14 @@ impl DeviceManager {
33823376
resources,
33833377
)?;
33843378

3379+
vfio_user_pci_device
3380+
.lock()
3381+
.unwrap()
3382+
.map_mmio_regions(&self.address_manager.vm, || {
3383+
self.memory_manager.lock().unwrap().allocate_memory_slot()
3384+
})
3385+
.map_err(DeviceManagerError::VfioUserMapRegion)?;
3386+
33853387
let mut node = device_node!(vfio_user_name);
33863388

33873389
// Update the device tree with correct resource information.

0 commit comments

Comments
 (0)