mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 02:55:45 +00:00
vmm: Remove deprecated CPU syntax
Remove the old way of specifying the number of vCPUs to use. Fixes: #678 Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
374ac77c63
commit
bba5ef3a59
@ -201,45 +201,37 @@ pub struct CpusConfig {
|
|||||||
|
|
||||||
impl CpusConfig {
|
impl CpusConfig {
|
||||||
pub fn parse(cpus: &str) -> Result<Self> {
|
pub fn parse(cpus: &str) -> Result<Self> {
|
||||||
if let Ok(legacy_vcpu_count) = cpus.parse::<u8>() {
|
// Split the parameters based on the comma delimiter
|
||||||
error!("Using deprecated vCPU syntax. Use --cpus boot=<boot_vcpus>[,max=<max_vcpus]");
|
let params_list: Vec<&str> = cpus.split(',').collect();
|
||||||
Ok(CpusConfig {
|
|
||||||
boot_vcpus: legacy_vcpu_count,
|
|
||||||
max_vcpus: legacy_vcpu_count,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
// Split the parameters based on the comma delimiter
|
|
||||||
let params_list: Vec<&str> = cpus.split(',').collect();
|
|
||||||
|
|
||||||
let mut boot_str: &str = "";
|
let mut boot_str: &str = "";
|
||||||
let mut max_str: &str = "";
|
let mut max_str: &str = "";
|
||||||
|
|
||||||
for param in params_list.iter() {
|
for param in params_list.iter() {
|
||||||
if param.starts_with("boot=") {
|
if param.starts_with("boot=") {
|
||||||
boot_str = ¶m["boot=".len()..];
|
boot_str = ¶m["boot=".len()..];
|
||||||
} else if param.starts_with("max=") {
|
} else if param.starts_with("max=") {
|
||||||
max_str = ¶m["max=".len()..];
|
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)?
|
|
||||||
} else {
|
} else {
|
||||||
boot_vcpus
|
return Err(Error::ParseCpusUnknownParam);
|
||||||
};
|
|
||||||
|
|
||||||
if max_vcpus < boot_vcpus {
|
|
||||||
return Err(Error::ParseCpusMaxLowerThanBoot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user