mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Create virtio-mem device with appropriate NUMA node
Now that virtio-mem device accept a guest NUMA node as parameter, we retrieve this information from the list of NUMA nodes. Based on the memory zone associated with the virtio-mem device, we obtain the NUMA node identifier, which we provide to the virtio-mem device. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -212,11 +212,12 @@ pub enum Error {
|
||||
}
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct NumaNode {
|
||||
memory_regions: Vec<Arc<GuestRegionMmap>>,
|
||||
cpus: Vec<u8>,
|
||||
distances: BTreeMap<u32, u8>,
|
||||
memory_zones: Vec<String>,
|
||||
}
|
||||
|
||||
impl NumaNode {
|
||||
@@ -231,6 +232,10 @@ impl NumaNode {
|
||||
pub fn distances(&self) -> &BTreeMap<u32, u8> {
|
||||
&self.distances
|
||||
}
|
||||
|
||||
pub fn memory_zones(&self) -> &Vec<String> {
|
||||
&self.memory_zones
|
||||
}
|
||||
}
|
||||
|
||||
pub type NumaNodes = BTreeMap<u32, NumaNode>;
|
||||
@@ -317,6 +322,11 @@ impl Vm {
|
||||
.validate()
|
||||
.map_err(Error::ConfigValidation)?;
|
||||
|
||||
// Create NUMA nodes based on NumaConfig.
|
||||
#[cfg(feature = "acpi")]
|
||||
let numa_nodes =
|
||||
Self::create_numa_nodes(config.lock().unwrap().numa.clone(), &memory_manager)?;
|
||||
|
||||
let device_manager = DeviceManager::new(
|
||||
vm.clone(),
|
||||
config.clone(),
|
||||
@@ -325,6 +335,8 @@ impl Vm {
|
||||
&reset_evt,
|
||||
vmm_path,
|
||||
seccomp_action.clone(),
|
||||
#[cfg(feature = "acpi")]
|
||||
numa_nodes.clone(),
|
||||
)
|
||||
.map_err(Error::DeviceManager)?;
|
||||
|
||||
@@ -352,11 +364,6 @@ impl Vm {
|
||||
.transpose()
|
||||
.map_err(Error::InitramfsFile)?;
|
||||
|
||||
// Create NUMA nodes based on NumaConfig.
|
||||
#[cfg(feature = "acpi")]
|
||||
let numa_nodes =
|
||||
Self::create_numa_nodes(config.lock().unwrap().numa.clone(), &memory_manager)?;
|
||||
|
||||
Ok(Vm {
|
||||
kernel,
|
||||
initramfs,
|
||||
@@ -395,16 +402,13 @@ impl Vm {
|
||||
return Err(Error::InvalidNumaConfig);
|
||||
}
|
||||
|
||||
let mut node = NumaNode {
|
||||
memory_regions: Vec::new(),
|
||||
cpus: Vec::new(),
|
||||
distances: BTreeMap::new(),
|
||||
};
|
||||
let mut node = NumaNode::default();
|
||||
|
||||
if let Some(memory_zones) = &config.memory_zones {
|
||||
for memory_zone in memory_zones.iter() {
|
||||
if let Some(mm_zone) = mm_zones.get(memory_zone) {
|
||||
node.memory_regions.extend(mm_zone.regions().clone());
|
||||
node.memory_zones.push(memory_zone.clone());
|
||||
} else {
|
||||
error!("Unknown memory zone '{}'", memory_zone);
|
||||
return Err(Error::InvalidNumaConfig);
|
||||
|
||||
Reference in New Issue
Block a user