From 4579afa0919b2556c911767da45d0d3b45b8320c Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 13 Mar 2020 10:28:39 +0000 Subject: [PATCH] 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 --- src/main.rs | 8 ++++---- vmm/src/config.rs | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 03e3e3db1..2d96374f9 100755 --- a/src/main.rs +++ b/src/main.rs @@ -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"} ] }"#, diff --git a/vmm/src/config.rs b/vmm/src/config.rs index e656524b6..5613865f8 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -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)?,