mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-02 11:35:46 +00:00
vmm: Add 'memory_zones' option to NumaConfig
This new option provides a new way to describe the memory associated with a NUMA node. This is the first step before we can remove the 'guest_numa_node' option from the --memory-zone parameter. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
5d7215915f
commit
dc42324351
@ -248,3 +248,19 @@ impl FromStr for TupleTwoIntegers {
|
|||||||
Ok(TupleTwoIntegers(list))
|
Ok(TupleTwoIntegers(list))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct StringList(pub Vec<String>);
|
||||||
|
|
||||||
|
pub enum StringListParseError {
|
||||||
|
InvalidValue(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromStr for StringList {
|
||||||
|
type Err = StringListParseError;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||||
|
let string_list: Vec<String> = s.trim().split(':').map(|e| e.to_owned()).collect();
|
||||||
|
|
||||||
|
Ok(StringList(string_list))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -754,6 +754,10 @@ components:
|
|||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/NumaDistance'
|
$ref: '#/components/schemas/NumaDistance'
|
||||||
|
memory_zones:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
|
||||||
VmResize:
|
VmResize:
|
||||||
type: object
|
type: object
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use net_util::MacAddr;
|
use net_util::MacAddr;
|
||||||
use option_parser::{
|
use option_parser::{
|
||||||
ByteSized, IntegerList, OptionParser, OptionParserError, Toggle, TupleTwoIntegers,
|
ByteSized, IntegerList, OptionParser, OptionParserError, StringList, Toggle, TupleTwoIntegers,
|
||||||
};
|
};
|
||||||
use std::convert::From;
|
use std::convert::From;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
@ -1235,14 +1235,21 @@ pub struct NumaConfig {
|
|||||||
pub cpus: Option<Vec<u8>>,
|
pub cpus: Option<Vec<u8>>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub distances: Option<Vec<NumaDistance>>,
|
pub distances: Option<Vec<NumaDistance>>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub memory_zones: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NumaConfig {
|
impl NumaConfig {
|
||||||
pub const SYNTAX: &'static str = "Settings related to a given NUMA node \
|
pub const SYNTAX: &'static str = "Settings related to a given NUMA node \
|
||||||
\"id=<node_id>,cpus=<cpus_id>,distances=<list_of_distances_to_destination_nodes>\"";
|
\"id=<node_id>,cpus=<cpus_id>,distances=<list_of_distances_to_destination_nodes>,\
|
||||||
|
memory_zones=<list_of_memory_zones>\"";
|
||||||
pub fn parse(numa: &str) -> Result<Self> {
|
pub fn parse(numa: &str) -> Result<Self> {
|
||||||
let mut parser = OptionParser::new();
|
let mut parser = OptionParser::new();
|
||||||
parser.add("id").add("cpus").add("distances");
|
parser
|
||||||
|
.add("id")
|
||||||
|
.add("cpus")
|
||||||
|
.add("distances")
|
||||||
|
.add("memory_zones");
|
||||||
parser.parse(numa).map_err(Error::ParseNuma)?;
|
parser.parse(numa).map_err(Error::ParseNuma)?;
|
||||||
|
|
||||||
let id = parser
|
let id = parser
|
||||||
@ -1264,11 +1271,16 @@ impl NumaConfig {
|
|||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
});
|
});
|
||||||
|
let memory_zones = parser
|
||||||
|
.convert::<StringList>("memory_zones")
|
||||||
|
.map_err(Error::ParseNuma)?
|
||||||
|
.map(|v| v.0);
|
||||||
|
|
||||||
Ok(NumaConfig {
|
Ok(NumaConfig {
|
||||||
id,
|
id,
|
||||||
cpus,
|
cpus,
|
||||||
distances,
|
distances,
|
||||||
|
memory_zones,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user