From bba5ef3a5970af4acad30360d9d9f2139d9f0017 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 21 Feb 2020 16:08:25 +0000 Subject: [PATCH] vmm: Remove deprecated CPU syntax Remove the old way of specifying the number of vCPUs to use. Fixes: #678 Signed-off-by: Rob Bradford --- vmm/src/config.rs | 60 ++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 348db4acf..d4108de89 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -201,45 +201,37 @@ pub struct CpusConfig { impl CpusConfig { pub fn parse(cpus: &str) -> Result { - if let Ok(legacy_vcpu_count) = cpus.parse::() { - error!("Using deprecated vCPU syntax. Use --cpus boot=[,max= = cpus.split(',').collect(); + // Split the parameters based on the comma delimiter + let params_list: Vec<&str> = cpus.split(',').collect(); - let mut boot_str: &str = ""; - let mut max_str: &str = ""; + let mut boot_str: &str = ""; + let mut max_str: &str = ""; - for param in params_list.iter() { - if param.starts_with("boot=") { - boot_str = ¶m["boot=".len()..]; - } else if param.starts_with("max=") { - max_str = ¶m["max=".len()..]; - } else { - return Err(Error::ParseCpusUnknownParam); - } - } - - let boot_vcpus: u8 = boot_str.parse().map_err(Error::ParseCpusParams)?; - let max_vcpus = if max_str != "" { - max_str.parse().map_err(Error::ParseCpusParams)? + for param in params_list.iter() { + if param.starts_with("boot=") { + boot_str = ¶m["boot=".len()..]; + } else if param.starts_with("max=") { + max_str = ¶m["max=".len()..]; } else { - boot_vcpus - }; - - if max_vcpus < boot_vcpus { - return Err(Error::ParseCpusMaxLowerThanBoot); + return Err(Error::ParseCpusUnknownParam); } - - Ok(CpusConfig { - boot_vcpus, - max_vcpus, - }) } + + let boot_vcpus: u8 = boot_str.parse().map_err(Error::ParseCpusParams)?; + let max_vcpus = if max_str != "" { + max_str.parse().map_err(Error::ParseCpusParams)? + } else { + boot_vcpus + }; + + if max_vcpus < boot_vcpus { + return Err(Error::ParseCpusMaxLowerThanBoot); + } + + Ok(CpusConfig { + boot_vcpus, + max_vcpus, + }) } }