mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-31 16:36:38 +00:00
dragonball: Make vhost-user-net ready for VhostUserEndpoint
The changes involve: - Expose VhostUserConfig struct to runtime-rs. - Set a default value while num_queues or queue_size are 0. Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
This commit is contained in:
@@ -32,4 +32,6 @@ pub use virtio_net::VirtioConfig;
|
||||
feature = "vhost-net",
|
||||
feature = "vhost-user-net"
|
||||
))]
|
||||
pub use virtio_net::{Backend, NetworkInterfaceConfig, NetworkInterfaceUpdateConfig};
|
||||
pub use virtio_net::{
|
||||
Backend, NetworkInterfaceConfig, NetworkInterfaceUpdateConfig, VhostUserConfig,
|
||||
};
|
||||
|
@@ -68,6 +68,7 @@ pub struct VirtioConfig {
|
||||
pub allow_duplicate_mac: bool,
|
||||
}
|
||||
|
||||
/// Config for vhost-user-net device
|
||||
#[cfg(feature = "vhost-user-net")]
|
||||
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq, Serialize)]
|
||||
pub struct VhostUserConfig {
|
||||
@@ -197,9 +198,23 @@ impl From<&NetworkInterfaceConfig> for VhostUserNetDeviceConfigInfo {
|
||||
fn from(value: &NetworkInterfaceConfig) -> Self {
|
||||
let num_queues = value
|
||||
.num_queues
|
||||
.map(|nq| {
|
||||
if nq == 0 {
|
||||
vhost_user_net_dev_mgr::DEFAULT_NUM_QUEUES
|
||||
} else {
|
||||
nq
|
||||
}
|
||||
})
|
||||
.unwrap_or(vhost_user_net_dev_mgr::DEFAULT_NUM_QUEUES);
|
||||
let queue_size = value
|
||||
.queue_size
|
||||
.map(|qs| {
|
||||
if qs == 0 {
|
||||
vhost_user_net_dev_mgr::DEFAULT_QUEUE_SIZE
|
||||
} else {
|
||||
qs
|
||||
}
|
||||
})
|
||||
.unwrap_or(vhost_user_net_dev_mgr::DEFAULT_QUEUE_SIZE);
|
||||
// It is safe because we tested the type of config before.
|
||||
#[allow(unreachable_patterns)]
|
||||
|
Reference in New Issue
Block a user