mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-21 19:02:30 +00:00
vmm,memory_manager: Deny resizing only if the ram amount has changed
Similarly to the previous commit restricting the cpu resizing error only to the situations where the vcpu amount has changed, let's do the same with the memory and be consistent throughout our code base. Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
parent
2c8045343c
commit
f049867cd9
@ -1605,10 +1605,6 @@ impl MemoryManager {
|
||||
/// use case never adds a new region as the whole hotpluggable memory has
|
||||
/// already been allocated at boot time.
|
||||
pub fn resize(&mut self, desired_ram: u64) -> Result<Option<Arc<GuestRegionMmap>>, Error> {
|
||||
if !self.dynamic {
|
||||
return Err(Error::ResizingNotSupported);
|
||||
}
|
||||
|
||||
if self.user_provided_zones {
|
||||
error!(
|
||||
"Not allowed to resize guest memory when backed with user \
|
||||
@ -1621,12 +1617,20 @@ impl MemoryManager {
|
||||
match self.hotplug_method {
|
||||
HotplugMethod::VirtioMem => {
|
||||
if desired_ram >= self.boot_ram {
|
||||
if !self.dynamic {
|
||||
return Err(Error::ResizingNotSupported);
|
||||
}
|
||||
|
||||
self.virtio_mem_resize(DEFAULT_MEMORY_ZONE, desired_ram - self.boot_ram)?;
|
||||
self.current_ram = desired_ram;
|
||||
}
|
||||
}
|
||||
HotplugMethod::Acpi => {
|
||||
if desired_ram > self.current_ram {
|
||||
if !self.dynamic {
|
||||
return Err(Error::ResizingNotSupported);
|
||||
}
|
||||
|
||||
region =
|
||||
Some(self.hotplug_ram_region((desired_ram - self.current_ram) as usize)?);
|
||||
self.current_ram = desired_ram;
|
||||
|
Loading…
x
Reference in New Issue
Block a user