mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-18 23:04:20 +01:00
runtime-rs: Remove virtio config from Backend
Virtio-net and vhost-net share a common virtio config, and vhost-user-net uses another config, named `VhostUserConfig`. Thus, the virtio config could be added into `NetworkConfig` instead of `Backend`. Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
This commit is contained in:
@@ -4,28 +4,19 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use std::{
|
||||
io::{self, Error},
|
||||
sync::Arc,
|
||||
};
|
||||
use std::io::{self, Error};
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use async_trait::async_trait;
|
||||
use hypervisor::device::device_manager::{do_handle_device, DeviceManager};
|
||||
use hypervisor::device::driver::NetworkConfig;
|
||||
use hypervisor::device::{DeviceConfig, DeviceType};
|
||||
use hypervisor::{Backend, Hypervisor, NetworkDevice};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use hypervisor::{
|
||||
device::{
|
||||
device_manager::{do_handle_device, DeviceManager},
|
||||
driver::NetworkConfig,
|
||||
DeviceConfig, DeviceType,
|
||||
},
|
||||
Hypervisor, NetworkBackend, NetworkDevice, VirtioConfig,
|
||||
};
|
||||
|
||||
use super::{
|
||||
endpoint_persist::{EndpointState, IpVlanEndpointState},
|
||||
Endpoint,
|
||||
};
|
||||
use super::endpoint_persist::{EndpointState, IpVlanEndpointState};
|
||||
use super::Endpoint;
|
||||
use crate::network::{network_model::TC_FILTER_NET_MODEL_STR, utils, NetworkPair};
|
||||
|
||||
// IPVlanEndpoint is the endpoint bridged to VM
|
||||
@@ -64,11 +55,9 @@ impl IPVlanEndpoint {
|
||||
})?;
|
||||
|
||||
Ok(NetworkConfig {
|
||||
backend: NetworkBackend::Virtio(VirtioConfig {
|
||||
host_dev_name: iface.name.clone(),
|
||||
virt_iface_name: self.net_pair.virt_iface.name.clone(),
|
||||
..Default::default()
|
||||
}),
|
||||
host_dev_name: iface.name.clone(),
|
||||
virt_iface_name: self.net_pair.virt_iface.name.clone(),
|
||||
backend: Backend::Virtio,
|
||||
guest_mac: Some(guest_mac),
|
||||
..Default::default()
|
||||
})
|
||||
|
||||
@@ -4,28 +4,19 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use std::{
|
||||
io::{self, Error},
|
||||
sync::Arc,
|
||||
};
|
||||
use std::io::{self, Error};
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use async_trait::async_trait;
|
||||
use hypervisor::device::device_manager::{do_handle_device, DeviceManager};
|
||||
use hypervisor::device::driver::NetworkConfig;
|
||||
use hypervisor::device::{DeviceConfig, DeviceType};
|
||||
use hypervisor::{Backend, Hypervisor, NetworkDevice};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use hypervisor::{
|
||||
device::{
|
||||
device_manager::{do_handle_device, DeviceManager},
|
||||
driver::NetworkConfig,
|
||||
DeviceConfig, DeviceType,
|
||||
},
|
||||
Hypervisor, NetworkBackend, NetworkDevice, VirtioConfig,
|
||||
};
|
||||
|
||||
use super::{
|
||||
endpoint_persist::{EndpointState, MacvlanEndpointState},
|
||||
Endpoint,
|
||||
};
|
||||
use super::endpoint_persist::{EndpointState, MacvlanEndpointState};
|
||||
use super::Endpoint;
|
||||
use crate::network::{utils, NetworkPair};
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -63,11 +54,9 @@ impl MacVlanEndpoint {
|
||||
})?;
|
||||
|
||||
Ok(NetworkConfig {
|
||||
backend: NetworkBackend::Virtio(VirtioConfig {
|
||||
host_dev_name: iface.name.clone(),
|
||||
virt_iface_name: self.net_pair.virt_iface.name.clone(),
|
||||
..Default::default()
|
||||
}),
|
||||
host_dev_name: iface.name.clone(),
|
||||
virt_iface_name: self.net_pair.virt_iface.name.clone(),
|
||||
backend: Backend::Virtio,
|
||||
guest_mac: Some(guest_mac),
|
||||
..Default::default()
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ use anyhow::{Context, Result};
|
||||
use async_trait::async_trait;
|
||||
use hypervisor::device::device_manager::{do_handle_device, DeviceManager};
|
||||
use hypervisor::device::{DeviceConfig, DeviceType};
|
||||
use hypervisor::{Hypervisor, NetworkBackend, NetworkConfig, NetworkDevice, VirtioConfig};
|
||||
use hypervisor::{Backend, Hypervisor, NetworkConfig, NetworkDevice};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use super::endpoint_persist::TapEndpointState;
|
||||
@@ -74,11 +74,9 @@ impl TapEndpoint {
|
||||
fn get_network_config(&self) -> Result<NetworkConfig> {
|
||||
let guest_mac = utils::parse_mac(&self.guest_mac).context("Parse mac address")?;
|
||||
Ok(NetworkConfig {
|
||||
backend: NetworkBackend::Virtio(VirtioConfig {
|
||||
host_dev_name: self.tap_iface.name.clone(),
|
||||
virt_iface_name: self.name.clone(),
|
||||
..Default::default()
|
||||
}),
|
||||
host_dev_name: self.tap_iface.name.clone(),
|
||||
virt_iface_name: self.name.clone(),
|
||||
backend: Backend::Virtio,
|
||||
guest_mac: Some(guest_mac),
|
||||
queue_num: self.queue_num,
|
||||
queue_size: self.queue_size,
|
||||
|
||||
@@ -4,28 +4,19 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use std::{
|
||||
io::{self, Error},
|
||||
sync::Arc,
|
||||
};
|
||||
use std::io::{self, Error};
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use async_trait::async_trait;
|
||||
use hypervisor::device::device_manager::{do_handle_device, DeviceManager};
|
||||
use hypervisor::device::driver::NetworkConfig;
|
||||
use hypervisor::device::{DeviceConfig, DeviceType};
|
||||
use hypervisor::{Backend, Hypervisor, NetworkDevice};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use hypervisor::{
|
||||
device::{
|
||||
device_manager::{do_handle_device, DeviceManager},
|
||||
driver::NetworkConfig,
|
||||
DeviceConfig, DeviceType,
|
||||
},
|
||||
Hypervisor, NetworkBackend, NetworkDevice, VirtioConfig,
|
||||
};
|
||||
|
||||
use super::{
|
||||
endpoint_persist::{EndpointState, VethEndpointState},
|
||||
Endpoint,
|
||||
};
|
||||
use super::endpoint_persist::{EndpointState, VethEndpointState};
|
||||
use super::Endpoint;
|
||||
use crate::network::{utils, NetworkPair};
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -63,11 +54,9 @@ impl VethEndpoint {
|
||||
})?;
|
||||
|
||||
Ok(NetworkConfig {
|
||||
backend: NetworkBackend::Virtio(VirtioConfig {
|
||||
host_dev_name: iface.name.clone(),
|
||||
virt_iface_name: self.net_pair.virt_iface.name.clone(),
|
||||
..Default::default()
|
||||
}),
|
||||
host_dev_name: iface.name.clone(),
|
||||
virt_iface_name: self.net_pair.virt_iface.name.clone(),
|
||||
backend: Backend::Virtio,
|
||||
guest_mac: Some(guest_mac),
|
||||
..Default::default()
|
||||
})
|
||||
|
||||
@@ -4,29 +4,21 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use std::{
|
||||
io::{self, Error},
|
||||
sync::Arc,
|
||||
};
|
||||
use std::io::{self, Error};
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use async_trait::async_trait;
|
||||
use hypervisor::device::device_manager::{do_handle_device, DeviceManager};
|
||||
use hypervisor::device::driver::NetworkConfig;
|
||||
use hypervisor::device::{DeviceConfig, DeviceType};
|
||||
use hypervisor::{Backend, Hypervisor, NetworkDevice};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use hypervisor::{
|
||||
device::{
|
||||
device_manager::{do_handle_device, DeviceManager},
|
||||
driver::NetworkConfig,
|
||||
DeviceConfig, DeviceType,
|
||||
},
|
||||
Hypervisor, NetworkBackend, NetworkDevice, VirtioConfig,
|
||||
};
|
||||
|
||||
use super::{
|
||||
endpoint_persist::{EndpointState, VlanEndpointState},
|
||||
Endpoint,
|
||||
};
|
||||
use crate::network::{network_model::TC_FILTER_NET_MODEL_STR, utils, NetworkPair};
|
||||
use super::endpoint_persist::{EndpointState, VlanEndpointState};
|
||||
use super::Endpoint;
|
||||
use crate::network::network_model::TC_FILTER_NET_MODEL_STR;
|
||||
use crate::network::{utils, NetworkPair};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct VlanEndpoint {
|
||||
@@ -62,11 +54,9 @@ impl VlanEndpoint {
|
||||
})?;
|
||||
|
||||
Ok(NetworkConfig {
|
||||
backend: NetworkBackend::Virtio(VirtioConfig {
|
||||
host_dev_name: iface.name.clone(),
|
||||
virt_iface_name: self.net_pair.virt_iface.name.clone(),
|
||||
..Default::default()
|
||||
}),
|
||||
host_dev_name: iface.name.clone(),
|
||||
virt_iface_name: self.net_pair.virt_iface.name.clone(),
|
||||
backend: Backend::Virtio,
|
||||
guest_mac: Some(guest_mac),
|
||||
..Default::default()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user