From 5e0bbf9c3bf6dd241b13f4034b5211906d6846c7 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Tue, 10 Dec 2019 16:40:32 +0100 Subject: [PATCH] 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 --- vmm/src/api/openapi/cloud-hypervisor.yaml | 26 +++++++++++------------ vmm/src/config.rs | 25 +++++++++------------- vmm/src/device_manager.rs | 12 +++++------ 3 files changed, 28 insertions(+), 35 deletions(-) diff --git a/vmm/src/api/openapi/cloud-hypervisor.yaml b/vmm/src/api/openapi/cloud-hypervisor.yaml index b577f30e6..e99ae1569 100644 --- a/vmm/src/api/openapi/cloud-hypervisor.yaml +++ b/vmm/src/api/openapi/cloud-hypervisor.yaml @@ -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: diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 73ceeae48..4be606a6c 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -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, + }) } } diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 2ef20b930..077509188 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -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)