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:
parent
9ba9c0819a
commit
231bbe2d5d
2 changed files with 5 additions and 2 deletions
|
|
@ -2202,7 +2202,11 @@ impl NumaConfig {
|
|||
let guest_numa_id = parser
|
||||
.convert::<u32>("guest_numa_id")
|
||||
.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
|
||||
.convert::<IntegerList>("cpus")
|
||||
.map_err(Error::ParseNuma)?
|
||||
|
|
|
|||
|
|
@ -676,7 +676,6 @@ pub struct NumaDistance {
|
|||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub struct NumaConfig {
|
||||
#[serde(default)]
|
||||
pub guest_numa_id: u32,
|
||||
#[serde(default)]
|
||||
pub cpus: Option<Vec<u32>>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue