diff --git a/src/main.rs b/src/main.rs index 72a85cf10..a64b0a0c5 100755 --- a/src/main.rs +++ b/src/main.rs @@ -233,19 +233,6 @@ fn create_app<'a, 'b>( .min_values(1) .group("vm-config"), ) - .arg( - Arg::with_name("vhost-user-blk") - .long("vhost-user-blk") - .help( - "Vhost user Block parameters \"sock=,\ - num_queues=,\ - queue_size=, \ - wce=\"", - ) - .takes_value(true) - .min_values(1) - .group("vm-config"), - ) .arg( Arg::with_name("v") .short("v") @@ -523,7 +510,6 @@ mod unit_tests { }, devices: None, vhost_user_net: None, - vhost_user_blk: None, vsock: None, iommu: false, }; @@ -1342,110 +1328,6 @@ mod unit_tests { }); } - #[test] - fn test_valid_vm_config_vublk() { - vec![ - ( - vec![ - "cloud-hypervisor", - "--vhost-user-blk", - "sock=/path/to/sock/1", - "sock=/path/to/sock/2", - ], - r#"{ - "vhost_user_blk": [ - {"sock": "/path/to/sock/1"}, - {"sock": "/path/to/sock/2"} - ] - }"#, - true, - ), - ( - vec![ - "cloud-hypervisor", - "--vhost-user-blk", - "sock=/path/to/sock/1", - "sock=/path/to/sock/2", - ], - r#"{ - "vhost_user_blk": [ - {"sock": "/path/to/sock/1"} - ] - }"#, - false, - ), - ( - vec![ - "cloud-hypervisor", - "--vhost-user-blk", - "sock=/path/to/sock/1,num_queues=4", - ], - r#"{ - "vhost_user_blk": [ - {"sock": "/path/to/sock/1", "num_queues": 4} - ] - }"#, - true, - ), - ( - vec![ - "cloud-hypervisor", - "--vhost-user-blk", - "sock=/path/to/sock/1,num_queues=4,queue_size=1024", - ], - r#"{ - "vhost_user_blk": [ - {"sock": "/path/to/sock/1", "num_queues": 4, "queue_size": 1024} - ] - }"#, - true, - ), - ( - vec![ - "cloud-hypervisor", - "--vhost-user-blk", - "sock=/path/to/sock/1,num_queues=4,queue_size=1024,wce=true", - ], - r#"{ - "vhost_user_blk": [ - {"sock": "/path/to/sock/1", "num_queues": 4, "queue_size": 1024, "wce": true} - ] - }"#, - true, - ), - ( - vec![ - "cloud-hypervisor", - "--vhost-user-blk", - "sock=/path/to/sock/1,num_queues=1,queue_size=128,wce=true", - ], - r#"{ - "vhost_user_blk": [ - {"sock": "/path/to/sock/1"} - ] - }"#, - true, - ), - ( - vec![ - "cloud-hypervisor", - "--vhost-user-blk", - "sock=/path/to/sock/1", - ], - r#"{ - "vhost_user_blk": [ - {"sock": "/path/to/sock/1", "num_queues": 1, "queue_size": 128, "wce": true} - ] - }"#, - true, - ), - ] - .iter() - .for_each(|(cli, openapi, equal)| { - compare_vm_config_cli_vs_json(cli, openapi, *equal); - }); - } - #[test] fn test_valid_vm_config_vsock() { vec![ diff --git a/vmm/src/api/openapi/cloud-hypervisor.yaml b/vmm/src/api/openapi/cloud-hypervisor.yaml index df6757811..eb244829f 100644 --- a/vmm/src/api/openapi/cloud-hypervisor.yaml +++ b/vmm/src/api/openapi/cloud-hypervisor.yaml @@ -208,10 +208,6 @@ components: type: array items: $ref: '#/components/schemas/VhostUserNetConfig' - vhost_user_blk: - type: array - items: - $ref: '#/components/schemas/VhostUserBlkConfig' vsock: type: array items: @@ -425,23 +421,6 @@ components: mac: type: string - VhostUserBlkConfig: - required: - - sock - type: object - properties: - sock: - type: string - num_queues: - type: integer - default: 1 - queue_size: - type: integer - default: 128 - wce: - type: boolean - default: true - VsockConfig: required: - cid diff --git a/vmm/src/config.rs b/vmm/src/config.rs index a66a1fecd..a0125561a 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -122,7 +122,6 @@ pub struct VmParams<'a> { pub console: &'a str, pub devices: Option>, pub vhost_user_net: Option>, - pub vhost_user_blk: Option>, pub vsock: Option>, } @@ -145,8 +144,6 @@ impl<'a> VmParams<'a> { let devices: Option> = args.values_of("device").map(|x| x.collect()); let vhost_user_net: Option> = args.values_of("vhost-user-net").map(|x| x.collect()); - let vhost_user_blk: Option> = - args.values_of("vhost-user-blk").map(|x| x.collect()); let vsock: Option> = args.values_of("vsock").map(|x| x.collect()); VmParams { @@ -163,7 +160,6 @@ impl<'a> VmParams<'a> { console, devices, vhost_user_net, - vhost_user_blk, vsock, } } @@ -1045,79 +1041,6 @@ impl VsockConfig { } } -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct VhostUserBlkConfig { - pub sock: String, - #[serde(default = "default_vublkconfig_num_queues")] - pub num_queues: usize, - #[serde(default = "default_vublkconfig_queue_size")] - pub queue_size: u16, - #[serde(default = "default_vublkconfig_wce")] - pub wce: bool, -} - -fn default_vublkconfig_num_queues() -> usize { - DEFAULT_NUM_QUEUES_VUBLK -} - -fn default_vublkconfig_queue_size() -> u16 { - DEFAULT_QUEUE_SIZE_VUBLK -} - -fn default_vublkconfig_wce() -> bool { - true -} - -impl VhostUserBlkConfig { - pub fn parse(vhost_user_blk: &str) -> Result { - error!("Using deprecated --vhost-user-blk syntax. Use --disk with vhost_user=true,socket="); - // Split the parameters based on the comma delimiter - let params_list: Vec<&str> = vhost_user_blk.split(',').collect(); - - let mut sock: &str = ""; - let mut num_queues_str: &str = ""; - let mut queue_size_str: &str = ""; - let mut wce_str: &str = ""; - - for param in params_list.iter() { - if param.starts_with("sock=") { - sock = ¶m[5..]; - } else if param.starts_with("num_queues=") { - num_queues_str = ¶m[11..]; - } else if param.starts_with("queue_size=") { - queue_size_str = ¶m[11..]; - } else if param.starts_with("wce=") { - wce_str = ¶m[4..]; - } - } - - let mut num_queues: usize = default_vublkconfig_num_queues(); - let mut queue_size: u16 = default_vublkconfig_queue_size(); - let mut wce: bool = default_vublkconfig_wce(); - - if !num_queues_str.is_empty() { - num_queues = num_queues_str - .parse() - .map_err(Error::ParseVuNumQueuesParam)?; - } - if !queue_size_str.is_empty() { - queue_size = queue_size_str - .parse() - .map_err(Error::ParseVuQueueSizeParam)?; - } - if !wce_str.is_empty() { - wce = wce_str.parse().map_err(Error::ParseVuBlkWceParam)?; - } - - Ok(VhostUserBlkConfig { - sock: sock.to_string(), - num_queues, - queue_size, - wce, - }) - } -} - #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] pub struct VmConfig { #[serde(default)] @@ -1139,7 +1062,6 @@ pub struct VmConfig { pub console: ConsoleConfig, pub devices: Option>, pub vhost_user_net: Option>, - pub vhost_user_blk: Option>, pub vsock: Option>, #[serde(default)] pub iommu: bool, @@ -1250,15 +1172,6 @@ impl VmConfig { vsock = Some(vsock_config_list); } - let mut vhost_user_blk: Option> = None; - if let Some(vhost_user_blk_list) = &vm_params.vhost_user_blk { - let mut vhost_user_blk_config_list = Vec::new(); - for item in vhost_user_blk_list.iter() { - vhost_user_blk_config_list.push(VhostUserBlkConfig::parse(item)?); - } - vhost_user_blk = Some(vhost_user_blk_config_list); - } - let mut kernel: Option = None; if let Some(k) = vm_params.kernel { kernel = Some(KernelConfig { @@ -1280,7 +1193,6 @@ impl VmConfig { console, devices, vhost_user_net, - vhost_user_blk, vsock, iommu, }) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index df08ac93a..67f096a57 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -859,9 +859,6 @@ impl DeviceManager { // Add virtio-vhost-user-net if required devices.append(&mut self.make_virtio_vhost_user_net_devices()?); - // Add virtio-vhost-user-blk if required - devices.append(&mut self.make_virtio_vhost_user_blk_devices()?); - // Add virtio-vsock if required devices.append(&mut self.make_virtio_vsock_devices()?); @@ -1298,36 +1295,6 @@ impl DeviceManager { Ok(devices) } - fn make_virtio_vhost_user_blk_devices( - &mut self, - ) -> DeviceManagerResult> { - let mut devices = Vec::new(); - // Add vhost-user-blk if required - if let Some(vhost_user_blk_list_cfg) = &self.config.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.sock.clone(), - num_queues: vhost_user_blk_cfg.num_queues, - queue_size: vhost_user_blk_cfg.queue_size, - }; - let vhost_user_blk_device = Arc::new(Mutex::new( - vm_virtio::vhost_user::Blk::new(vhost_user_blk_cfg.wce, vu_cfg) - .map_err(DeviceManagerError::CreateVhostUserBlk)?, - )); - - devices.push(( - Arc::clone(&vhost_user_blk_device) as Arc>, - false, - )); - - self.migratable_devices - .push(Arc::clone(&vhost_user_blk_device) as Arc>); - } - } - - Ok(devices) - } - fn make_virtio_vsock_devices(&mut self) -> DeviceManagerResult> { let mut devices = Vec::new(); // Add vsock if required