main, vmm: Remove deprecated --vhost-user-net

This has been superseded by using --net with vhost_user=true and
socket=<socket>

Fixes: #678

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-02-21 16:00:25 +00:00 committed by Samuel Ortiz
parent ffd816ebfa
commit 374ac77c63
4 changed files with 0 additions and 240 deletions

View File

@ -509,7 +509,6 @@ mod unit_tests {
iommu: false,
},
devices: None,
vhost_user_net: None,
vsock: None,
iommu: false,
};
@ -1233,101 +1232,6 @@ mod unit_tests {
});
}
#[test]
fn test_valid_vm_config_vunet() {
vec![
// This test is expected to fail because the default MAC address is
// randomly generated. There's no way we can have twice the same
// default value.
(
vec![
"cloud-hypervisor",
"--vhost-user-net",
"sock=/path/to/sock/1",
"sock=/path/to/sock/2",
],
r#"{
"vhost_user_net": [
{"sock": "/path/to/sock/1"},
{"sock": "/path/to/sock/2"}
]
}"#,
false,
),
(
vec![
"cloud-hypervisor",
"--vhost-user-net",
"sock=/path/to/sock/1,mac=12:34:56:78:90:ab",
"sock=/path/to/sock/2,mac=12:34:56:78:90:cd",
],
r#"{
"vhost_user_net": [
{"sock": "/path/to/sock/1", "mac": "12:34:56:78:90:ab"},
{"sock": "/path/to/sock/2", "mac": "12:34:56:78:90:cd"}
]
}"#,
true,
),
(
vec![
"cloud-hypervisor",
"--vhost-user-net",
"sock=/path/to/sock,mac=12:34:56:78:90:ab,num_queues=4",
],
r#"{
"vhost_user_net": [
{"sock": "/path/to/sock", "mac": "12:34:56:78:90:ab", "num_queues": 4}
]
}"#,
true,
),
(
vec![
"cloud-hypervisor",
"--vhost-user-net",
"sock=/path/to/sock,mac=12:34:56:78:90:ab,num_queues=4,queue_size=128",
],
r#"{
"vhost_user_net": [
{"sock": "/path/to/sock", "mac": "12:34:56:78:90:ab", "num_queues": 4, "queue_size": 128}
]
}"#,
true,
),
(
vec![
"cloud-hypervisor",
"--vhost-user-net",
"sock=/path/to/sock,mac=12:34:56:78:90:ab,num_queues=2,queue_size=256",
],
r#"{
"vhost_user_net": [
{"sock": "/path/to/sock", "mac": "12:34:56:78:90:ab"}
]
}"#,
true,
),
(
vec![
"cloud-hypervisor",
"--vhost-user-net",
"sock=/path/to/sock,mac=12:34:56:78:90:ab",
],
r#"{
"vhost_user_net": [
{"sock": "/path/to/sock", "mac": "12:34:56:78:90:ab", "num_queues": 2, "queue_size": 256}
]
}"#,
true,
),
]
.iter()
.for_each(|(cli, openapi, equal)| {
compare_vm_config_cli_vs_json(cli, openapi, *equal);
});
}
#[test]
fn test_valid_vm_config_vsock() {
vec![

View File

@ -204,10 +204,6 @@ components:
type: array
items:
$ref: '#/components/schemas/DeviceConfig'
vhost_user_net:
type: array
items:
$ref: '#/components/schemas/VhostUserNetConfig'
vsock:
type: array
items:
@ -405,22 +401,6 @@ components:
type: boolean
default: false
VhostUserNetConfig:
required:
- sock
type: object
properties:
sock:
type: string
num_queues:
type: integer
default: 2
queue_size:
type: integer
default: 256
mac:
type: string
VsockConfig:
required:
- cid

View File

@ -121,7 +121,6 @@ pub struct VmParams<'a> {
pub serial: &'a str,
pub console: &'a str,
pub devices: Option<Vec<&'a str>>,
pub vhost_user_net: Option<Vec<&'a str>>,
pub vsock: Option<Vec<&'a str>>,
}
@ -142,8 +141,6 @@ impl<'a> VmParams<'a> {
let fs: Option<Vec<&str>> = args.values_of("fs").map(|x| x.collect());
let pmem: Option<Vec<&str>> = args.values_of("pmem").map(|x| x.collect());
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 vsock: Option<Vec<&str>> = args.values_of("vsock").map(|x| x.collect());
VmParams {
@ -159,7 +156,6 @@ impl<'a> VmParams<'a> {
serial,
console,
devices,
vhost_user_net,
vsock,
}
}
@ -926,82 +922,6 @@ impl DeviceConfig {
}
}
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct VhostUserNetConfig {
pub sock: String,
#[serde(default = "default_vunetconfig_num_queues")]
pub num_queues: usize,
#[serde(default = "default_vunetconfig_queue_size")]
pub queue_size: u16,
#[serde(default = "default_vunetconfig_mac")]
pub mac: MacAddr,
}
fn default_vunetconfig_num_queues() -> usize {
DEFAULT_NUM_QUEUES_VUNET
}
fn default_vunetconfig_queue_size() -> u16 {
DEFAULT_QUEUE_SIZE_VUNET
}
fn default_vunetconfig_mac() -> MacAddr {
MacAddr::local_random()
}
impl VhostUserNetConfig {
pub fn parse(vhost_user_net: &str) -> Result<Self> {
error!("Using deprecated --vhost-user-net syntax. Use --net with vhost_user=true,socket=<socket path>");
// Split the parameters based on the comma delimiter
let params_list: Vec<&str> = vhost_user_net.split(',').collect();
let mut mac_str: &str = "";
let mut sock: &str = "";
let mut num_queues_str: &str = "";
let mut queue_size_str: &str = "";
for param in params_list.iter() {
if param.starts_with("mac=") {
mac_str = &param[4..];
} else if param.starts_with("sock=") {
sock = &param[5..];
} else if param.starts_with("num_queues=") {
num_queues_str = &param[11..];
} else if param.starts_with("queue_size=") {
queue_size_str = &param[11..];
}
}
let mut mac: MacAddr = default_vunetconfig_mac();
let mut num_queues: usize = default_vunetconfig_num_queues();
let mut queue_size: u16 = default_vunetconfig_queue_size();
if !mac_str.is_empty() {
mac = MacAddr::parse_str(mac_str).map_err(Error::ParseVuNetMacParam)?;
}
if sock.is_empty() {
return Err(Error::ParseVuSockParam);
}
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)?;
}
Ok(VhostUserNetConfig {
sock: sock.to_string(),
num_queues,
queue_size,
mac,
})
}
}
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct VsockConfig {
pub cid: u64,
@ -1061,7 +981,6 @@ pub struct VmConfig {
#[serde(default = "ConsoleConfig::default_console")]
pub console: ConsoleConfig,
pub devices: Option<Vec<DeviceConfig>>,
pub vhost_user_net: Option<Vec<VhostUserNetConfig>>,
pub vsock: Option<Vec<VsockConfig>>,
#[serde(default)]
pub iommu: bool,
@ -1150,15 +1069,6 @@ impl VmConfig {
devices = Some(device_config_list);
}
let mut vhost_user_net: Option<Vec<VhostUserNetConfig>> = None;
if let Some(vhost_user_net_list) = &vm_params.vhost_user_net {
let mut vhost_user_net_config_list = Vec::new();
for item in vhost_user_net_list.iter() {
vhost_user_net_config_list.push(VhostUserNetConfig::parse(item)?);
}
vhost_user_net = Some(vhost_user_net_config_list);
}
let mut vsock: Option<Vec<VsockConfig>> = None;
if let Some(vsock_list) = &vm_params.vsock {
let mut vsock_config_list = Vec::new();
@ -1192,7 +1102,6 @@ impl VmConfig {
serial,
console,
devices,
vhost_user_net,
vsock,
iommu,
})

View File

@ -856,9 +856,6 @@ impl DeviceManager {
// Add virtio-pmem if required
devices.append(&mut self.make_virtio_pmem_devices()?);
// Add virtio-vhost-user-net if required
devices.append(&mut self.make_virtio_vhost_user_net_devices()?);
// Add virtio-vsock if required
devices.append(&mut self.make_virtio_vsock_devices()?);
@ -1265,36 +1262,6 @@ impl DeviceManager {
Ok(devices)
}
fn make_virtio_vhost_user_net_devices(
&mut self,
) -> DeviceManagerResult<Vec<(VirtioDeviceArc, bool)>> {
let mut devices = Vec::new();
// Add vhost-user-net if required
if let Some(vhost_user_net_list_cfg) = &self.config.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.sock.clone(),
num_queues: vhost_user_net_cfg.num_queues,
queue_size: vhost_user_net_cfg.queue_size,
};
let vhost_user_net_device = Arc::new(Mutex::new(
vm_virtio::vhost_user::Net::new(vhost_user_net_cfg.mac, vu_cfg)
.map_err(DeviceManagerError::CreateVhostUserNet)?,
));
devices.push((
Arc::clone(&vhost_user_net_device) as Arc<Mutex<dyn vm_virtio::VirtioDevice>>,
false,
));
self.migratable_devices
.push(Arc::clone(&vhost_user_net_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