vmm: device_manager: always tear down vfio_user DMA handlers on eject

The PciDeviceHandle::VfioUser arm in eject_device propagated dma_unmap
failures with ?, which short-circuited the subsequent
remove_dma_mapping_handler loop and left stale Arc<VfioUserDmaMapping>
entries in every virtio-mem device's handler map.  Log unmap errors
with warn! and continue so the handler map cleanup always runs.

This only happens if a vfio-user process crashes and the same device is
later removed. However, given we've seen similar issues on vhost-user
this is probably worth cleaning up.

Signed-off-by: Dylan Reid <dgreid@fb.com>
This commit is contained in:
Dylan Reid
2026-05-04 23:35:49 -07:00
committed by Rob Bradford
parent 6111d549b7
commit 1b5c6d9977

View File

@@ -4832,8 +4832,11 @@ impl DeviceManager {
let mut dev = vfio_user_pci_device.lock().unwrap(); let mut dev = vfio_user_pci_device.lock().unwrap();
for (_, zone) in self.memory_manager.lock().unwrap().memory_zones().iter() { for (_, zone) in self.memory_manager.lock().unwrap().memory_zones().iter() {
for region in zone.regions() { for region in zone.regions() {
dev.dma_unmap(region) // On error, log, but continue so the loop below removing the mapping from
.map_err(DeviceManagerError::VfioUserDmaUnmap)?; // the devices runs.
if let Err(e) = dev.dma_unmap(region) {
warn!("vfio-user dma_unmap failed during eject: {e}");
}
} }
} }