diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 7eae968dc..a1e67f47d 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -661,11 +661,11 @@ impl CpuManager { self.activate_vcpus(self.boot_vcpus(), Some(entry_addr)) } - pub fn resize(&mut self, desired_vcpus: u8) -> Result<()> { + pub fn resize(&mut self, desired_vcpus: u8) -> Result { match desired_vcpus.cmp(&self.present_vcpus()) { - cmp::Ordering::Greater => self.activate_vcpus(desired_vcpus, None), - cmp::Ordering::Less => self.mark_vcpus_for_removal(desired_vcpus), - _ => Ok(()), + cmp::Ordering::Greater => self.activate_vcpus(desired_vcpus, None).and(Ok(true)), + cmp::Ordering::Less => self.mark_vcpus_for_removal(desired_vcpus).and(Ok(true)), + _ => Ok(false), } } diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 28f8f9323..e6e37c40b 100755 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -485,14 +485,17 @@ impl Vm { pub fn resize(&mut self, desired_vcpus: Option, desired_memory: Option) -> Result<()> { if let Some(desired_vcpus) = desired_vcpus { - self.cpu_manager + if self + .cpu_manager .lock() .unwrap() .resize(desired_vcpus) - .map_err(Error::CpuManager)?; - self.devices - .notify_hotplug(HotPlugNotificationFlags::CPU_DEVICES_CHANGED) - .map_err(Error::DeviceManager)?; + .map_err(Error::CpuManager)? + { + self.devices + .notify_hotplug(HotPlugNotificationFlags::CPU_DEVICES_CHANGED) + .map_err(Error::DeviceManager)?; + } self.config.lock().unwrap().cpus.boot_vcpus = desired_vcpus; }