dragonball: Set default queue config for vhost-net device

Dragonball sets a default queue config in the case of `None`. The
queue_size and num_queues of vhost-net are set to `Some(0)` by default.
Therefore, we might get an invalid queue config. This patch fixes this
issue.

Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
This commit is contained in:
Xuewei Niu 2023-12-11 10:09:22 +08:00
parent c11b066728
commit 82fde4431e

View File

@ -128,9 +128,23 @@ impl From<&NetworkInterfaceConfig> for VhostNetDeviceConfigInfo {
fn from(value: &NetworkInterfaceConfig) -> Self {
let num_queues = value
.num_queues
.map(|nq| {
if nq == 0 {
vhost_net_dev_mgr::DEFAULT_NUM_QUEUES
} else {
nq
}
})
.unwrap_or(vhost_net_dev_mgr::DEFAULT_NUM_QUEUES);
let queue_size = value
.queue_size
.map(|qs| {
if qs == 0 {
vhost_net_dev_mgr::DEFAULT_QUEUE_SIZE
} else {
qs
}
})
.unwrap_or(vhost_net_dev_mgr::DEFAULT_QUEUE_SIZE);
// It is safe because we tested the type of config before.