vmm: memory_manager: Only send the GED notification for the ACPI method

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz 2020-03-23 08:20:15 +01:00 committed by Sebastien Boeuf
parent 15d9ec0149
commit 41d7b3a387
2 changed files with 16 additions and 9 deletions

View File

@ -527,23 +527,24 @@ impl MemoryManager {
}
pub fn resize(&mut self, desired_ram: u64) -> Result<bool, Error> {
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)
}
}

View File

@ -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,12 +563,18 @@ impl Vm {
.update_memory()
.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
// result (true or false, happened or not), so that if the VM reboots it