mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-05 03:26:37 +00:00
runtime-rs: DAN supports vhost-user-net device
DAN reads vhost-user-net device from JSON config. It only supports VMM running as server right now. Fixes: #8625 Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
This commit is contained in:
parent
693a0cfbfd
commit
60a42351e2
@ -33,9 +33,10 @@ use tokio::sync::RwLock;
|
|||||||
use super::network_entity::NetworkEntity;
|
use super::network_entity::NetworkEntity;
|
||||||
use super::utils::address::{ip_family_from_ip_addr, parse_ip_cidr};
|
use super::utils::address::{ip_family_from_ip_addr, parse_ip_cidr};
|
||||||
use super::{EndpointState, NetnsGuard, Network};
|
use super::{EndpointState, NetnsGuard, Network};
|
||||||
use crate::network::endpoint::TapEndpoint;
|
use crate::network::endpoint::{TapEndpoint, VhostUserEndpoint};
|
||||||
use crate::network::network_info::network_info_from_dan::NetworkInfoFromDan;
|
use crate::network::network_info::network_info_from_dan::NetworkInfoFromDan;
|
||||||
use crate::network::utils::generate_private_mac_addr;
|
use crate::network::utils::generate_private_mac_addr;
|
||||||
|
use crate::network::Endpoint;
|
||||||
|
|
||||||
/// Directly attachable network
|
/// Directly attachable network
|
||||||
pub struct Dan {
|
pub struct Dan {
|
||||||
@ -78,16 +79,24 @@ impl DanInner {
|
|||||||
let mut entity_list = Vec::with_capacity(config.devices.len());
|
let mut entity_list = Vec::with_capacity(config.devices.len());
|
||||||
for (idx, device) in config.devices.iter().enumerate() {
|
for (idx, device) in config.devices.iter().enumerate() {
|
||||||
let name = format!("eth{}", idx);
|
let name = format!("eth{}", idx);
|
||||||
let endpoint = match &device.device {
|
let endpoint: Arc<dyn Endpoint> = match &device.device {
|
||||||
// TODO: Support VhostUserNet protocol
|
|
||||||
Device::VhostUser {
|
Device::VhostUser {
|
||||||
path,
|
path,
|
||||||
queue_num: _,
|
queue_num,
|
||||||
queue_size: _,
|
queue_size,
|
||||||
} => {
|
} => Arc::new(
|
||||||
warn!(sl!(), "A DAN device whose type is \"vhost-user\" and socket path is {} is ignored.", path);
|
VhostUserEndpoint::new(
|
||||||
continue;
|
dev_mgr,
|
||||||
}
|
idx as u32,
|
||||||
|
&name,
|
||||||
|
&device.guest_mac,
|
||||||
|
path,
|
||||||
|
*queue_num,
|
||||||
|
*queue_size,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.with_context(|| format!("create a vhost user endpoint, path: {}", path))?,
|
||||||
|
),
|
||||||
Device::HostTap {
|
Device::HostTap {
|
||||||
tap_name,
|
tap_name,
|
||||||
queue_num,
|
queue_num,
|
||||||
@ -104,7 +113,7 @@ impl DanInner {
|
|||||||
dev_mgr,
|
dev_mgr,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("New a {} tap endpoint", tap_name))?,
|
.with_context(|| format!("create a {} tap endpoint", tap_name))?,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user