mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
main, vmm: Remove deprecated --vhost-user-blk
This has been superseded by using --disk with vhost_user=true and socket=<socket> Fixes: #678 Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
committed by
Samuel Ortiz
parent
d04e0dc9e1
commit
ffd816ebfa
@@ -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
|
||||
|
||||
@@ -122,7 +122,6 @@ pub struct VmParams<'a> {
|
||||
pub console: &'a str,
|
||||
pub devices: Option<Vec<&'a str>>,
|
||||
pub vhost_user_net: Option<Vec<&'a str>>,
|
||||
pub vhost_user_blk: Option<Vec<&'a str>>,
|
||||
pub vsock: Option<Vec<&'a str>>,
|
||||
}
|
||||
|
||||
@@ -145,8 +144,6 @@ impl<'a> VmParams<'a> {
|
||||
let devices: Option<Vec<&str>> = args.values_of("device").map(|x| x.collect());
|
||||
let vhost_user_net: Option<Vec<&str>> =
|
||||
args.values_of("vhost-user-net").map(|x| x.collect());
|
||||
let vhost_user_blk: Option<Vec<&str>> =
|
||||
args.values_of("vhost-user-blk").map(|x| x.collect());
|
||||
let vsock: Option<Vec<&str>> = 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<Self> {
|
||||
error!("Using deprecated --vhost-user-blk syntax. Use --disk with vhost_user=true,socket=<socket path>");
|
||||
// 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<Vec<DeviceConfig>>,
|
||||
pub vhost_user_net: Option<Vec<VhostUserNetConfig>>,
|
||||
pub vhost_user_blk: Option<Vec<VhostUserBlkConfig>>,
|
||||
pub vsock: Option<Vec<VsockConfig>>,
|
||||
#[serde(default)]
|
||||
pub iommu: bool,
|
||||
@@ -1250,15 +1172,6 @@ impl VmConfig {
|
||||
vsock = Some(vsock_config_list);
|
||||
}
|
||||
|
||||
let mut vhost_user_blk: Option<Vec<VhostUserBlkConfig>> = 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<KernelConfig> = 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,
|
||||
})
|
||||
|
||||
@@ -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<Vec<(VirtioDeviceArc, bool)>> {
|
||||
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<Mutex<dyn vm_virtio::VirtioDevice>>,
|
||||
false,
|
||||
));
|
||||
|
||||
self.migratable_devices
|
||||
.push(Arc::clone(&vhost_user_blk_device) as Arc<Mutex<dyn Migratable>>);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(devices)
|
||||
}
|
||||
|
||||
fn make_virtio_vsock_devices(&mut self) -> DeviceManagerResult<Vec<(VirtioDeviceArc, bool)>> {
|
||||
let mut devices = Vec::new();
|
||||
// Add vsock if required
|
||||
|
||||
Reference in New Issue
Block a user