From f4090b01960a2e6b24502390557ba8ee1ba43a44 Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Fri, 14 Apr 2023 15:41:47 -0700 Subject: [PATCH] Revert "vmm: config: Close FDs for TAP devices that are provided to VM" This reverts commit b14427540b1ec159719dae8f48e14f65a877cc50. Signed-off-by: Bo Chen --- vmm/src/config.rs | 53 ----------------------------------------------- 1 file changed, 53 deletions(-) diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 7c1937b3d..98d533038 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -1150,17 +1150,6 @@ impl Clone for NetConfig { } } -impl Drop for NetConfig { - fn drop(&mut self) { - if let Some(mut fds) = self.fds.take() { - for fd in fds.drain(..) { - // SAFETY: Safe as the fd was given to the config by the API - unsafe { libc::close(fd) }; - } - } - } -} - impl RngConfig { pub fn parse(rng: &str) -> Result { let mut parser = OptionParser::new(); @@ -2354,10 +2343,6 @@ mod tests { NetConfig { mac: MacAddr::parse_str("de:ad:be:ef:12:34").unwrap(), host_mac: Some(MacAddr::parse_str("12:34:de:ad:be:ef").unwrap()), - fds: None, - id: None, - tap: None, - vhost_socket: None, ..Default::default() } ); @@ -2368,9 +2353,6 @@ mod tests { mac: MacAddr::parse_str("de:ad:be:ef:12:34").unwrap(), host_mac: Some(MacAddr::parse_str("12:34:de:ad:be:ef").unwrap()), id: Some("mynet0".to_owned()), - fds: None, - tap: None, - vhost_socket: None, ..Default::default() } ); @@ -2385,9 +2367,6 @@ mod tests { tap: Some("tap0".to_owned()), ip: "192.168.100.1".parse().unwrap(), mask: "255.255.255.128".parse().unwrap(), - fds: None, - id: None, - vhost_socket: None, ..Default::default() } ); @@ -2401,9 +2380,6 @@ mod tests { host_mac: Some(MacAddr::parse_str("12:34:de:ad:be:ef").unwrap()), vhost_user: true, vhost_socket: Some("/tmp/sock".to_owned()), - fds: None, - id: None, - tap: None, ..Default::default() } ); @@ -2416,10 +2392,6 @@ mod tests { num_queues: 4, queue_size: 1024, iommu: true, - fds: None, - id: None, - tap: None, - vhost_socket: None, ..Default::default() } ); @@ -2430,9 +2402,6 @@ mod tests { mac: MacAddr::parse_str("de:ad:be:ef:12:34").unwrap(), fds: Some(vec![3, 7]), num_queues: 4, - id: None, - tap: None, - vhost_socket: None, ..Default::default() } ); @@ -2855,10 +2824,6 @@ mod tests { let mut invalid_config = valid_config.clone(); invalid_config.net = Some(vec![NetConfig { vhost_user: true, - fds: None, - id: None, - tap: None, - vhost_socket: None, ..Default::default() }]); assert_eq!( @@ -2870,9 +2835,6 @@ mod tests { still_valid_config.net = Some(vec![NetConfig { vhost_user: true, vhost_socket: Some("/path/to/sock".to_owned()), - fds: None, - id: None, - tap: None, ..Default::default() }]); still_valid_config.memory.shared = true; @@ -2881,9 +2843,6 @@ mod tests { let mut invalid_config = valid_config.clone(); invalid_config.net = Some(vec![NetConfig { fds: Some(vec![0]), - id: None, - tap: None, - vhost_socket: None, ..Default::default() }]); assert_eq!( @@ -2894,10 +2853,6 @@ mod tests { let mut invalid_config = valid_config.clone(); invalid_config.net = Some(vec![NetConfig { offload_csum: false, - fds: None, - id: None, - tap: None, - vhost_socket: None, ..Default::default() }]); assert_eq!( @@ -3001,10 +2956,6 @@ mod tests { still_valid_config.net = Some(vec![NetConfig { iommu: true, pci_segment: 1, - fds: None, - id: None, - tap: None, - vhost_socket: None, ..Default::default() }]); assert!(still_valid_config.validate().is_ok()); @@ -3073,10 +3024,6 @@ mod tests { invalid_config.net = Some(vec![NetConfig { iommu: false, pci_segment: 1, - fds: None, - id: None, - tap: None, - vhost_socket: None, ..Default::default() }]); assert_eq!(