vmm: For --disk error if socket and path is specified

This is an error as the path should be specfied by the unmanaged
backend.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-03-13 10:28:39 +00:00
parent 7e599b4450
commit 4579afa091
2 changed files with 10 additions and 4 deletions

View File

@ -653,12 +653,12 @@ mod unit_tests {
vec![
"cloud-hypervisor",
"--disk",
"path=/path/to/disk/1,vhost_user=true,socket=/tmp/socket1",
"vhost_user=true,socket=/tmp/socket1",
"path=/path/to/disk/2",
],
r#"{
"disks": [
{"path": "/path/to/disk/1", "vhost_user":true, "vhost_socket":"/tmp/socket1"},
{"vhost_user":true, "vhost_socket":"/tmp/socket1"},
{"path": "/path/to/disk/2"}
]
}"#,
@ -668,12 +668,12 @@ mod unit_tests {
vec![
"cloud-hypervisor",
"--disk",
"path=/path/to/disk/1,vhost_user=true,socket=/tmp/socket1,wce=true",
"vhost_user=true,socket=/tmp/socket1,wce=true",
"path=/path/to/disk/2",
],
r#"{
"disks": [
{"path": "/path/to/disk/1", "vhost_user":true, "vhost_socket":"/tmp/socket1", "wce":true},
{"vhost_user":true, "vhost_socket":"/tmp/socket1", "wce":true},
{"path": "/path/to/disk/2"}
]
}"#,

View File

@ -49,6 +49,8 @@ pub enum Error {
ParseDiskVhostParam(std::str::ParseBoolError),
/// Failed parsing disk wce parameter.
ParseDiskWceParam(std::str::ParseBoolError),
/// Both socket and path specified
ParseDiskSocketAndPath,
/// Failed parsing random number generator parameters.
ParseRngParams,
/// Failed parsing network ip parameter.
@ -453,6 +455,10 @@ impl DiskConfig {
path = Some(PathBuf::from(path_str))
}
if vhost_socket.as_ref().and(path.as_ref()).is_some() {
return Err(Error::ParseDiskSocketAndPath);
}
Ok(DiskConfig {
path,
readonly: parse_on_off(readonly_str)?,