From 188078467db42f50f5b7e7a7969738ebf8aec95c Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 17 Mar 2022 12:33:04 +0000 Subject: [PATCH] vmm: cpu: Deny resizing if CpuManager is not dynamic Signed-off-by: Rob Bradford --- vmm/src/cpu.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 6cf9b300b..a71279d53 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -125,6 +125,9 @@ pub enum Error { #[cfg(all(target_arch = "x86_64", feature = "gdb"))] /// Failed to translate guest virtual address. TranslateVirtualAddress(hypervisor::HypervisorCpuError), + + /// CPU hotplug/unplug not supported + ResizingNotSupported, } pub type Result = result::Result; @@ -1093,6 +1096,10 @@ impl CpuManager { } pub fn resize(&mut self, desired_vcpus: u8) -> Result { + if !self.dynamic { + return Err(Error::ResizingNotSupported); + } + match desired_vcpus.cmp(&self.present_vcpus()) { cmp::Ordering::Greater => { self.create_vcpus(desired_vcpus, None)?;