From ad3790a0ea9d03a7c8f5a361f830eee1159dafb2 Mon Sep 17 00:00:00 2001 From: Pascal Scholz Date: Mon, 20 Jul 2026 14:28:57 +0200 Subject: [PATCH] vmm: Update memory zones We consume `zone_updates` from `VmReceiveMigrationData` and `RestoreConfig` to remap already existing `MemoryZone`s to different host NUMA nodes. For now, we do not support further changes, such as altering the size of the respective `MemoryZone`s. These changes allow to migrate a VM to a host that has the capacity to host the same `MemoryZone`s on a different NUMA layout. Signed-off-by: Pascal Scholz On-behalf-of: SAP pascal.scholz@sap.com --- vmm/src/lib.rs | 10 ++++++++++ vmm/src/vm.rs | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index d3feb182a..d6ff2ae24 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -1178,6 +1178,7 @@ impl Vmm { T: Read, { let mode = receive_data_migration.memory_mode; + let zone_updates = &receive_data_migration.zone_updates; // Read in config data along with memory manager data let mut data: Vec = Vec::new(); @@ -1222,6 +1223,10 @@ impl Vmm { &vm_migration_config.common_cpuid, )?; + update_memory_zones(zone_updates, &vm_migration_config.vm_config).map_err(|e| { + MigratableError::MigrateReceive(anyhow!("Error updating memory zones: {e:?}")) + })?; + let config = vm_migration_config.vm_config.clone(); self.vm_config = Some(vm_migration_config.vm_config); self.console_info = Some( @@ -2518,6 +2523,11 @@ impl RequestHandler for Vmm { .iommufd_fd = Some(iommufd_fd); } + update_memory_zones(&restore_cfg.zone_updates, &vm_config).map_err(|e| { + error!("VM Restore failed: {e:?}"); + VmError::ApplyMemoryZoneUpdate(e) + })?; + self.vm_restore( source_url, vm_config, diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 281066308..14e934f41 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -120,7 +120,7 @@ use crate::vm_config::{ }; use crate::{ CPU_MANAGER_SNAPSHOT_ID, DEVICE_MANAGER_SNAPSHOT_ID, GuestMemoryMmap, - MEMORY_MANAGER_SNAPSHOT_ID, PciDeviceInfo, acpi, cpu, + MEMORY_MANAGER_SNAPSHOT_ID, MemoryZoneUpdateError, PciDeviceInfo, acpi, cpu, }; /// Errors associated with VM management @@ -399,6 +399,10 @@ pub enum Error { #[cfg(feature = "fw_cfg")] #[error("Error using fw_cfg while disabled")] FwCfgDisabled, + + /// Cannot apply NUMA memory zone updates + #[error("Error applying memory zone updates")] + ApplyMemoryZoneUpdate(#[source] MemoryZoneUpdateError), } pub type Result = result::Result;