From 1b5c6d9977ecfb0565051f903eefd5ee53f85c60 Mon Sep 17 00:00:00 2001 From: Dylan Reid Date: Mon, 4 May 2026 23:35:49 -0700 Subject: [PATCH] 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 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 --- vmm/src/device_manager.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index a82b96804..640181d70 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -4832,8 +4832,11 @@ impl DeviceManager { let mut dev = vfio_user_pci_device.lock().unwrap(); for (_, zone) in self.memory_manager.lock().unwrap().memory_zones().iter() { for region in zone.regions() { - dev.dma_unmap(region) - .map_err(DeviceManagerError::VfioUserDmaUnmap)?; + // On error, log, but continue so the loop below removing the mapping from + // the devices runs. + if let Err(e) = dev.dma_unmap(region) { + warn!("vfio-user dma_unmap failed during eject: {e}"); + } } }