mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Retrieve new memory region when memory is extended
Whenever the memory is resized, it's important to retrieve the new region to pass it down to the device manager, this way it can decide what to do with it. Also, there's no need to use a boolean as we can instead use an Option to carry the information about the region. In case of virtio-mem, there will be no region since the whole memory has been reserved up front by the VMM at boot. This means only the ACPI hotplug will return a region and is the only method that requires the memory to be updated from the device manager. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
+8
-7
@@ -606,17 +606,18 @@ impl Vm {
|
||||
}
|
||||
|
||||
if let Some(desired_memory) = desired_memory {
|
||||
if self
|
||||
let new_region = self
|
||||
.memory_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.resize(desired_memory)
|
||||
.map_err(Error::MemoryManager)?
|
||||
{
|
||||
.map_err(Error::MemoryManager)?;
|
||||
|
||||
if let Some(new_region) = &new_region {
|
||||
self.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.update_memory()
|
||||
.update_memory(&new_region)
|
||||
.map_err(Error::DeviceManager)?;
|
||||
|
||||
let memory_config = &self.config.lock().unwrap().memory;
|
||||
@@ -632,9 +633,9 @@ impl Vm {
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
// will be running with the last configure memory size.
|
||||
// We update the VM config regardless of the actual guest resize
|
||||
// operation result (happened or not), so that if the VM reboots
|
||||
// it will be running with the last configure memory size.
|
||||
self.config.lock().unwrap().memory.size = desired_memory;
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user