From 7fd76eff0524b9e0f703d479a4b4fd65d217a9ca Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 31 Mar 2022 14:36:37 +0100 Subject: [PATCH] vmm: Don't error if live resizing is not possible The introduction of a error if live resizing is not possible is a regression compared to the original behaviour where the new size would be stored in the config and reflected in the next boot. This behaviour was also inconsistent with the effect of resizing with no VM booted. Instead of generating an error allow the code to go ahead and update the config so that the new size will be available upon the reboot. Signed-off-by: Rob Bradford --- vmm/src/cpu.rs | 5 +---- vmm/src/memory_manager.rs | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 44848ee93..66cde477b 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -122,9 +122,6 @@ pub enum Error { /// Failed to translate guest virtual address. TranslateVirtualAddress(hypervisor::HypervisorCpuError), - /// CPU hotplug/unplug not supported - ResizingNotSupported, - #[cfg(all(feature = "amx", target_arch = "x86_64"))] /// "Failed to setup AMX. AmxEnable(anyhow::Error), @@ -1134,7 +1131,7 @@ impl CpuManager { } if !self.dynamic { - return Err(Error::ResizingNotSupported); + return Ok(false); } match desired_vcpus.cmp(&self.present_vcpus()) { diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index 0dfbbe939..6309e55d3 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -307,9 +307,6 @@ pub enum Error { /// Failed to allocate MMIO address AllocateMmioAddress, - - /// Memory resizing not supported - ResizingNotSupported, } const ENABLE_FLAG: usize = 0; @@ -1618,7 +1615,7 @@ impl MemoryManager { HotplugMethod::VirtioMem => { if desired_ram >= self.boot_ram { if !self.dynamic { - return Err(Error::ResizingNotSupported); + return Ok(region); } self.virtio_mem_resize(DEFAULT_MEMORY_ZONE, desired_ram - self.boot_ram)?; @@ -1628,7 +1625,7 @@ impl MemoryManager { HotplugMethod::Acpi => { if desired_ram > self.current_ram { if !self.dynamic { - return Err(Error::ResizingNotSupported); + return Ok(region); } region =