From 41d7b3a387f8fc42ae522646523b6e54c2c0847a Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 23 Mar 2020 08:20:15 +0100 Subject: [PATCH] vmm: memory_manager: Only send the GED notification for the ACPI method Signed-off-by: Samuel Ortiz --- vmm/src/memory_manager.rs | 7 ++++--- vmm/src/vm.rs | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index 232ff86fb..d25f55783 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -527,23 +527,24 @@ impl MemoryManager { } pub fn resize(&mut self, desired_ram: u64) -> Result { - let mut notify_hotplug = false; + let mut resized = false; match self.hotplug_method { HotplugMethod::VirtioMem => { if desired_ram >= self.boot_ram { self.virtiomem_resize(desired_ram - self.boot_ram)?; self.current_ram = desired_ram; + resized = true; } } HotplugMethod::Acpi => { if desired_ram >= self.current_ram { self.hotplug_ram_region((desired_ram - self.current_ram) as usize)?; self.current_ram = desired_ram; - notify_hotplug = true + resized = true; } } } - Ok(notify_hotplug) + Ok(resized) } } diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 2603d534d..95731f0aa 100755 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -26,7 +26,7 @@ extern crate vm_allocator; extern crate vm_memory; extern crate vm_virtio; -use crate::config::{DeviceConfig, DiskConfig, PmemConfig, VmConfig}; +use crate::config::{DeviceConfig, DiskConfig, HotplugMethod, PmemConfig, VmConfig}; use crate::cpu; use crate::device_manager::{get_win_size, Console, DeviceManager, DeviceManagerError}; use crate::memory_manager::{get_host_cpu_phys_bits, Error as MemoryManagerError, MemoryManager}; @@ -563,11 +563,17 @@ impl Vm { .update_memory() .map_err(Error::DeviceManager)?; - self.device_manager - .lock() - .unwrap() - .notify_hotplug(HotPlugNotificationFlags::MEMORY_DEVICES_CHANGED) - .map_err(Error::DeviceManager)?; + let memory_config = &self.config.lock().unwrap().memory; + match memory_config.hotplug_method { + HotplugMethod::Acpi => { + self.device_manager + .lock() + .unwrap() + .notify_hotplug(HotPlugNotificationFlags::MEMORY_DEVICES_CHANGED) + .map_err(Error::DeviceManager)?; + } + HotplugMethod::VirtioMem => {} + } } // We update the VM config regardless of the actual guest resize operation