From 211786ab42eee9942d9ad660a0efbf26a7008d5a Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 17 Jan 2020 16:48:46 +0000 Subject: [PATCH] vmm: Only generate GED interrupt when the number of vCPUs has changed Avoid activity in the the guest OS if the number of vCPUs has not changed. Signed-off-by: Rob Bradford --- vmm/src/cpu.rs | 8 ++++---- vmm/src/vm.rs | 13 ++++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) 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; }