mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Use HashSet for VmConfig::preserved_fds
Each VM reboot re-entered the VFIO/virtio-net add paths and re-appended the same originating fds, leaving duplicates in preserved_fds and a double-close hazard at final teardown. Switching to HashSet makes add_preserved_fds idempotent. Signed-off-by: Bo Chen <bchen@crusoe.ai> Assisted-by: Claude:Opus-4.7
This commit is contained in:
@@ -4797,7 +4797,7 @@ impl DeviceManager {
|
||||
|
||||
debug!("Closing preserved FDs from virtio-net device: id={id}, fds={fds:?}");
|
||||
for fd in fds {
|
||||
config.preserved_fds.as_mut().unwrap().retain(|x| *x != fd);
|
||||
config.preserved_fds.as_mut().unwrap().remove(&fd);
|
||||
// SAFETY: We are closing the only remaining instance of this FD.
|
||||
unsafe {
|
||||
libc::close(fd);
|
||||
|
||||
Reference in New Issue
Block a user