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:
@@ -2,6 +2,7 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
use std::collections::HashSet;
|
||||
use std::net::IpAddr;
|
||||
use std::path::{Path, PathBuf};
|
||||
#[cfg(feature = "fw_cfg")]
|
||||
@@ -1065,7 +1066,7 @@ pub struct VmConfig {
|
||||
// causes the FDs to be closed early. This allows management software to
|
||||
// gracefully clean up resources (e.g., libvirt closes tap devices).
|
||||
#[serde(skip)]
|
||||
pub preserved_fds: Option<Vec<i32>>,
|
||||
pub preserved_fds: Option<HashSet<i32>>,
|
||||
#[serde(default)]
|
||||
pub landlock_enable: bool,
|
||||
pub landlock_rules: Option<Box<[LandlockConfig]>>,
|
||||
|
||||
Reference in New Issue
Block a user