mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-03-20 07:58:55 +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:
parent
d04e0dc9e1
commit
ffd816ebfa
118
src/main.rs
118
src/main.rs
@ -233,19 +233,6 @@ fn create_app<'a, 'b>(
|
|||||||
.min_values(1)
|
.min_values(1)
|
||||||
.group("vm-config"),
|
.group("vm-config"),
|
||||||
)
|
)
|
||||||
.arg(
|
|
||||||
Arg::with_name("vhost-user-blk")
|
|
||||||
.long("vhost-user-blk")
|
|
||||||
.help(
|
|
||||||
"Vhost user Block parameters \"sock=<socket_path>,\
|
|
||||||
num_queues=<number_of_queues>,\
|
|
||||||
queue_size=<size_of_each_queue>, \
|
|
||||||
wce=<true|false, default true>\"",
|
|
||||||
)
|
|
||||||
.takes_value(true)
|
|
||||||
.min_values(1)
|
|
||||||
.group("vm-config"),
|
|
||||||
)
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("v")
|
Arg::with_name("v")
|
||||||
.short("v")
|
.short("v")
|
||||||
@ -523,7 +510,6 @@ mod unit_tests {
|
|||||||
},
|
},
|
||||||
devices: None,
|
devices: None,
|
||||||
vhost_user_net: None,
|
vhost_user_net: None,
|
||||||
vhost_user_blk: None,
|
|
||||||
vsock: None,
|
vsock: None,
|
||||||
iommu: false,
|
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]
|
#[test]
|
||||||
fn test_valid_vm_config_vsock() {
|
fn test_valid_vm_config_vsock() {
|
||||||
vec![
|
vec![
|
||||||
|
@ -208,10 +208,6 @@ components:
|
|||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/VhostUserNetConfig'
|
$ref: '#/components/schemas/VhostUserNetConfig'
|
||||||
vhost_user_blk:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/VhostUserBlkConfig'
|
|
||||||
vsock:
|
vsock:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
@ -425,23 +421,6 @@ components:
|
|||||||
mac:
|
mac:
|
||||||
type: string
|
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:
|
VsockConfig:
|
||||||
required:
|
required:
|
||||||
- cid
|
- cid
|
||||||
|
@ -122,7 +122,6 @@ pub struct VmParams<'a> {
|
|||||||
pub console: &'a str,
|
pub console: &'a str,
|
||||||
pub devices: Option<Vec<&'a str>>,
|
pub devices: Option<Vec<&'a str>>,
|
||||||
pub vhost_user_net: 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>>,
|
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 devices: Option<Vec<&str>> = args.values_of("device").map(|x| x.collect());
|
||||||
let vhost_user_net: Option<Vec<&str>> =
|
let vhost_user_net: Option<Vec<&str>> =
|
||||||
args.values_of("vhost-user-net").map(|x| x.collect());
|
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());
|
let vsock: Option<Vec<&str>> = args.values_of("vsock").map(|x| x.collect());
|
||||||
|
|
||||||
VmParams {
|
VmParams {
|
||||||
@ -163,7 +160,6 @@ impl<'a> VmParams<'a> {
|
|||||||
console,
|
console,
|
||||||
devices,
|
devices,
|
||||||
vhost_user_net,
|
vhost_user_net,
|
||||||
vhost_user_blk,
|
|
||||||
vsock,
|
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)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
pub struct VmConfig {
|
pub struct VmConfig {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@ -1139,7 +1062,6 @@ pub struct VmConfig {
|
|||||||
pub console: ConsoleConfig,
|
pub console: ConsoleConfig,
|
||||||
pub devices: Option<Vec<DeviceConfig>>,
|
pub devices: Option<Vec<DeviceConfig>>,
|
||||||
pub vhost_user_net: Option<Vec<VhostUserNetConfig>>,
|
pub vhost_user_net: Option<Vec<VhostUserNetConfig>>,
|
||||||
pub vhost_user_blk: Option<Vec<VhostUserBlkConfig>>,
|
|
||||||
pub vsock: Option<Vec<VsockConfig>>,
|
pub vsock: Option<Vec<VsockConfig>>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub iommu: bool,
|
pub iommu: bool,
|
||||||
@ -1250,15 +1172,6 @@ impl VmConfig {
|
|||||||
vsock = Some(vsock_config_list);
|
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;
|
let mut kernel: Option<KernelConfig> = None;
|
||||||
if let Some(k) = vm_params.kernel {
|
if let Some(k) = vm_params.kernel {
|
||||||
kernel = Some(KernelConfig {
|
kernel = Some(KernelConfig {
|
||||||
@ -1280,7 +1193,6 @@ impl VmConfig {
|
|||||||
console,
|
console,
|
||||||
devices,
|
devices,
|
||||||
vhost_user_net,
|
vhost_user_net,
|
||||||
vhost_user_blk,
|
|
||||||
vsock,
|
vsock,
|
||||||
iommu,
|
iommu,
|
||||||
})
|
})
|
||||||
|
@ -859,9 +859,6 @@ impl DeviceManager {
|
|||||||
// Add virtio-vhost-user-net if required
|
// Add virtio-vhost-user-net if required
|
||||||
devices.append(&mut self.make_virtio_vhost_user_net_devices()?);
|
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
|
// Add virtio-vsock if required
|
||||||
devices.append(&mut self.make_virtio_vsock_devices()?);
|
devices.append(&mut self.make_virtio_vsock_devices()?);
|
||||||
|
|
||||||
@ -1298,36 +1295,6 @@ impl DeviceManager {
|
|||||||
Ok(devices)
|
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)>> {
|
fn make_virtio_vsock_devices(&mut self) -> DeviceManagerResult<Vec<(VirtioDeviceArc, bool)>> {
|
||||||
let mut devices = Vec::new();
|
let mut devices = Vec::new();
|
||||||
// Add vsock if required
|
// Add vsock if required
|
||||||
|
Loading…
x
Reference in New Issue
Block a user