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
default: false
VhostUserConfig:
VhostUserNetConfig:
required:
- sock
- num_queues
- queue_size
- mac
type: object
properties:
sock:
type: string
num_queues:
type: integer
queue:size:
queue_size:
type: integer
VhostUserNetConfig:
required:
- mac
- vu_cfg
type: object
properties:
mac:
type: string
vu_cfg:
$ref: '#/components/schemas/VhostUserConfig'
VhostUserBlkConfig:
required:
- sock
- num_queues
- queue_size
- wce
- vu_cfg
type: object
properties:
sock:
type: string
num_queues:
type: integer
queue_size:
type: integer
wce:
type: boolean
vu_cfg:
$ref: '#/components/schemas/VhostUserConfig'
VsockConfig:
required:

View File

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

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 {
for vhost_user_net_cfg in vhost_user_net_list_cfg.iter() {
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,
sock: vhost_user_net_cfg.sock.clone(),
num_queues: vhost_user_net_cfg.num_queues,
queue_size: vhost_user_net_cfg.queue_size,
};
let vhost_user_net_device =
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 {
for vhost_user_blk_cfg in vhost_user_blk_list_cfg.iter() {
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,
sock: vhost_user_blk_cfg.sock.clone(),
num_queues: vhost_user_blk_cfg.num_queues,
queue_size: vhost_user_blk_cfg.queue_size,
};
let vhost_user_blk_device =
vm_virtio::vhost_user::Blk::new(vhost_user_blk_cfg.wce, vu_cfg)