mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Update NUMA nodes based on NumaConfig
Relying on the list of CPUs defined through the NumaConfig, this patch will update the internal list of CPUs attached to each NUMA node. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
+25
-2
@@ -24,8 +24,8 @@ extern crate vm_allocator;
|
||||
extern crate vm_memory;
|
||||
|
||||
use crate::config::{
|
||||
DeviceConfig, DiskConfig, FsConfig, HotplugMethod, NetConfig, PmemConfig, ValidationError,
|
||||
VmConfig, VsockConfig,
|
||||
DeviceConfig, DiskConfig, FsConfig, HotplugMethod, NetConfig, NumaConfig, PmemConfig,
|
||||
ValidationError, VmConfig, VsockConfig,
|
||||
};
|
||||
use crate::cpu;
|
||||
use crate::device_manager::{self, get_win_size, Console, DeviceManager, DeviceManagerError};
|
||||
@@ -311,6 +311,11 @@ impl Vm {
|
||||
.transpose()
|
||||
.map_err(Error::InitramfsFile)?;
|
||||
|
||||
// Update NUMA based on NumaConfig.
|
||||
if let Some(numa_cfg) = config.lock().unwrap().numa.clone() {
|
||||
Self::update_numa(numa_cfg, &memory_manager)?;
|
||||
}
|
||||
|
||||
Ok(Vm {
|
||||
kernel,
|
||||
initramfs,
|
||||
@@ -328,6 +333,24 @@ impl Vm {
|
||||
})
|
||||
}
|
||||
|
||||
fn update_numa(
|
||||
configs: Vec<NumaConfig>,
|
||||
memory_manager: &Arc<Mutex<MemoryManager>>,
|
||||
) -> Result<()> {
|
||||
let mut mm = memory_manager.lock().unwrap();
|
||||
let numa_nodes = mm.numa_nodes_mut();
|
||||
|
||||
for config in configs.iter() {
|
||||
if let Some(cpus) = &config.cpus {
|
||||
if let Some(node) = numa_nodes.get_mut(&config.id) {
|
||||
node.cpus_mut().extend(cpus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn new(
|
||||
config: Arc<Mutex<VmConfig>>,
|
||||
exit_evt: EventFd,
|
||||
|
||||
Reference in New Issue
Block a user