mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
self.balloon and self.virtio_mem_devices are not updated when eject_device removes the underlying device, leaving stale Arc<Mutex<...>> entries that resize_balloon / balloon_size and the virtio-mem DMA-handler iteration would dereference if reached after eject. Clear self.balloon and retain-out the matching virtio-mem entry in the PciDeviceHandle::Virtio eject arm, identifying the ejected device by Arc pointer-equality against the already-resolved Arc<Mutex<dyn VirtioDevice>>. This change is defensive: DeviceManager::remove_device currently rejects VirtioDeviceType::Balloon and VirtioDeviceType::Mem with RemovalNotAllowed before pci_devices_down is set, so the guest never sees an eject notification and eject_device is never reached for either type today. If the allowlist is extended later, this cleanup keeps the post-eject state consistent. Signed-off-by: Dylan Reid <dgreid@fb.com>