mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
DeviceManager and VfioPciDevice both hold Arc<MmapRegion> for each VFIO BAR mmap window. During VM shutdown, VfioPciDevice drops after DeviceManager::Drop::drop (via device_tree field drop). Without clearing DeviceManager's clones first, VfioPciDevice::unmap_mmio_regions decrements the Arc but does not reach zero, munmap never fires, the VFIO device file VMAs survive, and VFIO_GROUP_UNSET_CONTAINER returns EBUSY. Clear DeviceManager's mmio_regions in Drop::drop so VfioPciDevice is the sole Arc owner at drop time and ensure VFIO_GROUP_UNSET_CONTAINER ioctl success. Remove redundant .clone() on the mmio_regions() return value in the eject_device() hot-unplug path. Add detail comments Signed-off-by: Saravanan D <saravanand@crusoe.ai>