mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 21:55:20 +00:00
Revert "vmm: config: Close FDs for TAP devices that are provided to VM"
This reverts commit b14427540b
.
Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
3432c0ce5e
commit
f4090b0196
@ -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 {
|
impl RngConfig {
|
||||||
pub fn parse(rng: &str) -> Result<Self> {
|
pub fn parse(rng: &str) -> Result<Self> {
|
||||||
let mut parser = OptionParser::new();
|
let mut parser = OptionParser::new();
|
||||||
@ -2354,10 +2343,6 @@ mod tests {
|
|||||||
NetConfig {
|
NetConfig {
|
||||||
mac: MacAddr::parse_str("de:ad:be:ef:12:34").unwrap(),
|
mac: MacAddr::parse_str("de:ad:be:ef:12:34").unwrap(),
|
||||||
host_mac: Some(MacAddr::parse_str("12:34:de:ad:be:ef").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()
|
..Default::default()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -2368,9 +2353,6 @@ mod tests {
|
|||||||
mac: MacAddr::parse_str("de:ad:be:ef:12:34").unwrap(),
|
mac: MacAddr::parse_str("de:ad:be:ef:12:34").unwrap(),
|
||||||
host_mac: Some(MacAddr::parse_str("12:34:de:ad:be:ef").unwrap()),
|
host_mac: Some(MacAddr::parse_str("12:34:de:ad:be:ef").unwrap()),
|
||||||
id: Some("mynet0".to_owned()),
|
id: Some("mynet0".to_owned()),
|
||||||
fds: None,
|
|
||||||
tap: None,
|
|
||||||
vhost_socket: None,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -2385,9 +2367,6 @@ mod tests {
|
|||||||
tap: Some("tap0".to_owned()),
|
tap: Some("tap0".to_owned()),
|
||||||
ip: "192.168.100.1".parse().unwrap(),
|
ip: "192.168.100.1".parse().unwrap(),
|
||||||
mask: "255.255.255.128".parse().unwrap(),
|
mask: "255.255.255.128".parse().unwrap(),
|
||||||
fds: None,
|
|
||||||
id: None,
|
|
||||||
vhost_socket: None,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -2401,9 +2380,6 @@ mod tests {
|
|||||||
host_mac: Some(MacAddr::parse_str("12:34:de:ad:be:ef").unwrap()),
|
host_mac: Some(MacAddr::parse_str("12:34:de:ad:be:ef").unwrap()),
|
||||||
vhost_user: true,
|
vhost_user: true,
|
||||||
vhost_socket: Some("/tmp/sock".to_owned()),
|
vhost_socket: Some("/tmp/sock".to_owned()),
|
||||||
fds: None,
|
|
||||||
id: None,
|
|
||||||
tap: None,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -2416,10 +2392,6 @@ mod tests {
|
|||||||
num_queues: 4,
|
num_queues: 4,
|
||||||
queue_size: 1024,
|
queue_size: 1024,
|
||||||
iommu: true,
|
iommu: true,
|
||||||
fds: None,
|
|
||||||
id: None,
|
|
||||||
tap: None,
|
|
||||||
vhost_socket: None,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -2430,9 +2402,6 @@ mod tests {
|
|||||||
mac: MacAddr::parse_str("de:ad:be:ef:12:34").unwrap(),
|
mac: MacAddr::parse_str("de:ad:be:ef:12:34").unwrap(),
|
||||||
fds: Some(vec![3, 7]),
|
fds: Some(vec![3, 7]),
|
||||||
num_queues: 4,
|
num_queues: 4,
|
||||||
id: None,
|
|
||||||
tap: None,
|
|
||||||
vhost_socket: None,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -2855,10 +2824,6 @@ mod tests {
|
|||||||
let mut invalid_config = valid_config.clone();
|
let mut invalid_config = valid_config.clone();
|
||||||
invalid_config.net = Some(vec![NetConfig {
|
invalid_config.net = Some(vec![NetConfig {
|
||||||
vhost_user: true,
|
vhost_user: true,
|
||||||
fds: None,
|
|
||||||
id: None,
|
|
||||||
tap: None,
|
|
||||||
vhost_socket: None,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}]);
|
}]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -2870,9 +2835,6 @@ mod tests {
|
|||||||
still_valid_config.net = Some(vec![NetConfig {
|
still_valid_config.net = Some(vec![NetConfig {
|
||||||
vhost_user: true,
|
vhost_user: true,
|
||||||
vhost_socket: Some("/path/to/sock".to_owned()),
|
vhost_socket: Some("/path/to/sock".to_owned()),
|
||||||
fds: None,
|
|
||||||
id: None,
|
|
||||||
tap: None,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}]);
|
}]);
|
||||||
still_valid_config.memory.shared = true;
|
still_valid_config.memory.shared = true;
|
||||||
@ -2881,9 +2843,6 @@ mod tests {
|
|||||||
let mut invalid_config = valid_config.clone();
|
let mut invalid_config = valid_config.clone();
|
||||||
invalid_config.net = Some(vec![NetConfig {
|
invalid_config.net = Some(vec![NetConfig {
|
||||||
fds: Some(vec![0]),
|
fds: Some(vec![0]),
|
||||||
id: None,
|
|
||||||
tap: None,
|
|
||||||
vhost_socket: None,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}]);
|
}]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -2894,10 +2853,6 @@ mod tests {
|
|||||||
let mut invalid_config = valid_config.clone();
|
let mut invalid_config = valid_config.clone();
|
||||||
invalid_config.net = Some(vec![NetConfig {
|
invalid_config.net = Some(vec![NetConfig {
|
||||||
offload_csum: false,
|
offload_csum: false,
|
||||||
fds: None,
|
|
||||||
id: None,
|
|
||||||
tap: None,
|
|
||||||
vhost_socket: None,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}]);
|
}]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -3001,10 +2956,6 @@ mod tests {
|
|||||||
still_valid_config.net = Some(vec![NetConfig {
|
still_valid_config.net = Some(vec![NetConfig {
|
||||||
iommu: true,
|
iommu: true,
|
||||||
pci_segment: 1,
|
pci_segment: 1,
|
||||||
fds: None,
|
|
||||||
id: None,
|
|
||||||
tap: None,
|
|
||||||
vhost_socket: None,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}]);
|
}]);
|
||||||
assert!(still_valid_config.validate().is_ok());
|
assert!(still_valid_config.validate().is_ok());
|
||||||
@ -3073,10 +3024,6 @@ mod tests {
|
|||||||
invalid_config.net = Some(vec![NetConfig {
|
invalid_config.net = Some(vec![NetConfig {
|
||||||
iommu: false,
|
iommu: false,
|
||||||
pci_segment: 1,
|
pci_segment: 1,
|
||||||
fds: None,
|
|
||||||
id: None,
|
|
||||||
tap: None,
|
|
||||||
vhost_socket: None,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}]);
|
}]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
Loading…
Reference in New Issue
Block a user