diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 496b1803b..87726b624 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -12,7 +12,6 @@ use std::net::AddrParseError; use std::net::Ipv4Addr; use std::path::PathBuf; use std::result; -use vm_virtio::vhost_user::VhostUserConfig; pub const DEFAULT_VCPUS: &str = "1"; pub const DEFAULT_MEMORY: &str = "size=512M"; @@ -459,10 +458,17 @@ impl DeviceConfig { } } +#[derive(Clone, Debug)] +pub struct VuConfig { + pub sock: String, + pub num_queues: usize, + pub queue_size: u16, +} + #[derive(Clone, Debug)] pub struct VhostUserNetConfig { pub mac: MacAddr, - pub vu_cfg: VhostUserConfig, + pub vu_cfg: VuConfig, } impl VhostUserNetConfig { @@ -508,7 +514,7 @@ impl VhostUserNetConfig { .map_err(Error::ParseVuQueueSizeParam)?; } - let vu_cfg = VhostUserConfig { + let vu_cfg = VuConfig { sock: sock.to_string(), num_queues, queue_size, @@ -554,7 +560,7 @@ impl VsockConfig { #[derive(Clone, Debug)] pub struct VhostUserBlkConfig { pub wce: bool, - pub vu_cfg: VhostUserConfig, + pub vu_cfg: VuConfig, } impl VhostUserBlkConfig { @@ -597,7 +603,7 @@ impl VhostUserBlkConfig { wce = wce_str.parse().map_err(Error::ParseVuBlkWceParam)?; } - let vu_cfg = VhostUserConfig { + let vu_cfg = VuConfig { sock: sock.to_string(), num_queues, queue_size, diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index bd3cf901d..613c95c02 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -43,6 +43,7 @@ use vm_memory::GuestAddress; use vm_memory::{Address, GuestMemoryMmap, GuestUsize}; #[cfg(feature = "pci_support")] use vm_virtio::transport::VirtioPciDevice; +use vm_virtio::vhost_user::VhostUserConfig; use vm_virtio::{VirtioSharedMemory, VirtioSharedMemoryList}; use vmm_sys_util::eventfd::EventFd; @@ -801,11 +802,14 @@ impl DeviceManager { // Add vhost-user-net if required if let Some(vhost_user_net_list_cfg) = &vm_info.vm_cfg.vhost_user_net { for vhost_user_net_cfg in vhost_user_net_list_cfg.iter() { - let vhost_user_net_device = vm_virtio::vhost_user::Net::new( - vhost_user_net_cfg.mac, - vhost_user_net_cfg.vu_cfg.clone(), - ) - .map_err(DeviceManagerError::CreateVhostUserNet)?; + let vu_cfg = VhostUserConfig { + sock: vhost_user_net_cfg.vu_cfg.sock.clone(), + num_queues: vhost_user_net_cfg.vu_cfg.num_queues, + queue_size: vhost_user_net_cfg.vu_cfg.queue_size, + }; + let vhost_user_net_device = + vm_virtio::vhost_user::Net::new(vhost_user_net_cfg.mac, vu_cfg) + .map_err(DeviceManagerError::CreateVhostUserNet)?; devices.push(Box::new(vhost_user_net_device) as Box); } @@ -821,11 +825,14 @@ impl DeviceManager { // Add vhost-user-blk if required if let Some(vhost_user_blk_list_cfg) = &vm_info.vm_cfg.vhost_user_blk { for vhost_user_blk_cfg in vhost_user_blk_list_cfg.iter() { - let vhost_user_blk_device = vm_virtio::vhost_user::Blk::new( - vhost_user_blk_cfg.wce, - vhost_user_blk_cfg.vu_cfg.clone(), - ) - .map_err(DeviceManagerError::CreateVhostUserBlk)?; + let vu_cfg = VhostUserConfig { + sock: vhost_user_blk_cfg.vu_cfg.sock.clone(), + num_queues: vhost_user_blk_cfg.vu_cfg.num_queues, + queue_size: vhost_user_blk_cfg.vu_cfg.queue_size, + }; + let vhost_user_blk_device = + vm_virtio::vhost_user::Blk::new(vhost_user_blk_cfg.wce, vu_cfg) + .map_err(DeviceManagerError::CreateVhostUserBlk)?; devices.push(Box::new(vhost_user_blk_device) as Box); }