vmm: Don't factorize vhost-user configurations

We want to set different default configurations for vhost-user-net and
vhost-user-blk, which is the reason why the common part corresponding to
the number of queues and the queue size cannot be embedded.

This prepares for the following commit, matching API and CLI behaviors.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2019-12-10 16:40:32 +01:00 committed by Rob Bradford
parent 793327cff8
commit 5e0bbf9c3b
3 changed files with 28 additions and 35 deletions

View File

@ -372,41 +372,39 @@ components:
type: boolean type: boolean
default: false default: false
VhostUserConfig: VhostUserNetConfig:
required: required:
- sock - sock
- num_queues - num_queues
- queue_size - queue_size
- mac
type: object type: object
properties: properties:
sock: sock:
type: string type: string
num_queues: num_queues:
type: integer type: integer
queue:size: queue_size:
type: integer type: integer
VhostUserNetConfig:
required:
- mac
- vu_cfg
type: object
properties:
mac: mac:
type: string type: string
vu_cfg:
$ref: '#/components/schemas/VhostUserConfig'
VhostUserBlkConfig: VhostUserBlkConfig:
required: required:
- sock
- num_queues
- queue_size
- wce - wce
- vu_cfg
type: object type: object
properties: properties:
sock:
type: string
num_queues:
type: integer
queue_size:
type: integer
wce: wce:
type: boolean type: boolean
vu_cfg:
$ref: '#/components/schemas/VhostUserConfig'
VsockConfig: VsockConfig:
required: required:

View File

@ -694,16 +694,11 @@ impl DeviceConfig {
} }
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct VuConfig { pub struct VhostUserNetConfig {
pub sock: String, pub sock: String,
pub num_queues: usize, pub num_queues: usize,
pub queue_size: u16, pub queue_size: u16,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct VhostUserNetConfig {
pub mac: MacAddr, pub mac: MacAddr,
pub vu_cfg: VuConfig,
} }
impl VhostUserNetConfig { impl VhostUserNetConfig {
@ -749,13 +744,12 @@ impl VhostUserNetConfig {
.map_err(Error::ParseVuQueueSizeParam)?; .map_err(Error::ParseVuQueueSizeParam)?;
} }
let vu_cfg = VuConfig { Ok(VhostUserNetConfig {
sock: sock.to_string(), sock: sock.to_string(),
num_queues, num_queues,
queue_size, queue_size,
}; mac,
})
Ok(VhostUserNetConfig { mac, vu_cfg })
} }
} }
@ -800,8 +794,10 @@ impl VsockConfig {
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct VhostUserBlkConfig { pub struct VhostUserBlkConfig {
pub sock: String,
pub num_queues: usize,
pub queue_size: u16,
pub wce: bool, pub wce: bool,
pub vu_cfg: VuConfig,
} }
impl VhostUserBlkConfig { impl VhostUserBlkConfig {
@ -844,13 +840,12 @@ impl VhostUserBlkConfig {
wce = wce_str.parse().map_err(Error::ParseVuBlkWceParam)?; wce = wce_str.parse().map_err(Error::ParseVuBlkWceParam)?;
} }
let vu_cfg = VuConfig { Ok(VhostUserBlkConfig {
sock: sock.to_string(), sock: sock.to_string(),
num_queues, num_queues,
queue_size, queue_size,
}; wce,
})
Ok(VhostUserBlkConfig { wce, vu_cfg })
} }
} }

View File

@ -1162,9 +1162,9 @@ impl DeviceManager {
if let Some(vhost_user_net_list_cfg) = &vm_info.vm_cfg.lock().unwrap().vhost_user_net { if let Some(vhost_user_net_list_cfg) = &vm_info.vm_cfg.lock().unwrap().vhost_user_net {
for vhost_user_net_cfg in vhost_user_net_list_cfg.iter() { for vhost_user_net_cfg in vhost_user_net_list_cfg.iter() {
let vu_cfg = VhostUserConfig { let vu_cfg = VhostUserConfig {
sock: vhost_user_net_cfg.vu_cfg.sock.clone(), sock: vhost_user_net_cfg.sock.clone(),
num_queues: vhost_user_net_cfg.vu_cfg.num_queues, num_queues: vhost_user_net_cfg.num_queues,
queue_size: vhost_user_net_cfg.vu_cfg.queue_size, queue_size: vhost_user_net_cfg.queue_size,
}; };
let vhost_user_net_device = let vhost_user_net_device =
vm_virtio::vhost_user::Net::new(vhost_user_net_cfg.mac, vu_cfg) vm_virtio::vhost_user::Net::new(vhost_user_net_cfg.mac, vu_cfg)
@ -1188,9 +1188,9 @@ impl DeviceManager {
if let Some(vhost_user_blk_list_cfg) = &vm_info.vm_cfg.lock().unwrap().vhost_user_blk { if let Some(vhost_user_blk_list_cfg) = &vm_info.vm_cfg.lock().unwrap().vhost_user_blk {
for vhost_user_blk_cfg in vhost_user_blk_list_cfg.iter() { for vhost_user_blk_cfg in vhost_user_blk_list_cfg.iter() {
let vu_cfg = VhostUserConfig { let vu_cfg = VhostUserConfig {
sock: vhost_user_blk_cfg.vu_cfg.sock.clone(), sock: vhost_user_blk_cfg.sock.clone(),
num_queues: vhost_user_blk_cfg.vu_cfg.num_queues, num_queues: vhost_user_blk_cfg.num_queues,
queue_size: vhost_user_blk_cfg.vu_cfg.queue_size, queue_size: vhost_user_blk_cfg.queue_size,
}; };
let vhost_user_blk_device = let vhost_user_blk_device =
vm_virtio::vhost_user::Blk::new(vhost_user_blk_cfg.wce, vu_cfg) vm_virtio::vhost_user::Blk::new(vhost_user_blk_cfg.wce, vu_cfg)