mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Enforce guest_numa_id on NUMA nodes
The documentation says guest_numa_id is required to be unique and therefore the parser() giving default value for non-existing guest_numa_id with .unwrap_or(0) is dangerous. Return a validation error if guest_numa_id is not provided instead of silently defaulting to 0. Signed-off-by: Saravanan D <saravanand@crusoe.ai>
This commit is contained in:
committed by
Rob Bradford
parent
9ba9c0819a
commit
231bbe2d5d
@@ -2202,7 +2202,11 @@ impl NumaConfig {
|
|||||||
let guest_numa_id = parser
|
let guest_numa_id = parser
|
||||||
.convert::<u32>("guest_numa_id")
|
.convert::<u32>("guest_numa_id")
|
||||||
.map_err(Error::ParseNuma)?
|
.map_err(Error::ParseNuma)?
|
||||||
.unwrap_or(0);
|
.ok_or_else(|| {
|
||||||
|
Error::ParseNuma(OptionParserError::InvalidValue(
|
||||||
|
"guest_numa_id is required for all NUMA nodes".to_string(),
|
||||||
|
))
|
||||||
|
})?;
|
||||||
let cpus = parser
|
let cpus = parser
|
||||||
.convert::<IntegerList>("cpus")
|
.convert::<IntegerList>("cpus")
|
||||||
.map_err(Error::ParseNuma)?
|
.map_err(Error::ParseNuma)?
|
||||||
|
|||||||
@@ -676,7 +676,6 @@ pub struct NumaDistance {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
pub struct NumaConfig {
|
pub struct NumaConfig {
|
||||||
#[serde(default)]
|
|
||||||
pub guest_numa_id: u32,
|
pub guest_numa_id: u32,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub cpus: Option<Vec<u32>>,
|
pub cpus: Option<Vec<u32>>,
|
||||||
|
|||||||
Reference in New Issue
Block a user