3.7. Managing Virtual Machines Memory Parameters¶
This section describes how to configure memory parameters available for virtual machines:
- memory size,
- video memory size,
- memory hotplugging,
- memory guarantees.
3.7.1. Configuring Virtual Machine Memory Size¶
To increase or reduce the amount of memory that will be available to the virtual machine, use the
--memsize option of the
prlctl set command. The following example shows how to increase the RAM of the virtual machine
MyVM from 1GB to 2GB and check that the new value has been successfully set:
# prlctl list -i MyVM | grep memory memory 1024Mb # prlctl set MyVM --memsize 2048 Set the memsize parameter to 2048Mb The VM has been successfully configured. # prlctl list -i MyVM | grep memory memory 2048Mb
The changes are saved in the VM configuration file and applied to the VM on start. If the VM is running, it will need to be rebooted. To be able to increase or reduce virtual machine RAM size without reboot, enable memory hotplugging as described in Enabling Virtual Machine Memory Hotplugging.
The value set with
prlctl --memsize is not reported inside the VM as physical or other RAM size. A user logged in to the guest OS will see as much physical RAM as can be obtained by fully deflating the balloon (see MaxNumaSize in Enabling Virtual Machine Memory Hotplugging). The balloon size is not reported inside the VM as well. However, if the balloon is not fully deflated, a part of the reported physical RAM will appear to be occupied at all times (by what is in fact the balloon).
3.7.2. Configuring Virtual Machine Video Memory Size¶
To set the amount of video memory to be available to the virtual machine’s video card, use the
--videosize option of the
prlctl set command. Assuming that the current video memory size of the virtual machine
MyVM is set to 32 MB, you can increase it to 64 MB by running the following command:
# prlctl set MyVM --videosize 64
To check that the new value has been successfully set, use this command:
# prlctl list -i MyVM | grep video video 64Mb
3.7.3. Enabling Virtual Machine Memory Hotplugging¶
Memory hotplugging allows increasing or reducing virtual machine RAM size on the fly, without the need to reboot the VM. Memory hotplugging is implemented as a combination of ballooning and addition/removal of virtual DIMM slots.
The algorithm is as follows. When a command to increase VM memory size to RAM_size is run (as described in Configuring Virtual Machine Memory Size), the memory is first expanded by deflating the VM’s balloon. The balloon deflation limit, MaxNumaSize, is calculated automatically according to the formula
MaxNumaSize = (RAM_size + 4GB) rounded up to a multiple of 4GB
If fully deflating the balloon is not enough to obtain RAM_size (that is, RAM_size exceeds MaxNumaSize), then memory is further expanded by adding virtual DIMM slots (up to twice the MaxNumaSize) and MaxNumaSize is set equal to RAM_size (that is, the maximum balloon size grows as well). When a command to decrease VM memory size is run, the memory is shrunk by inflating the VM’s balloon. The added virtual DIMM slots remain until VM restart. After restart, the VM has memory equal to RAM_size.
This feature is only supported for virtual machines with at least 1GB of RAM and is disabled by default. To enable it for a virtual machine (e.g.,
Make sure the VM is stopped.
# prlctl set MyVM --mem-hotplug on
Start the VM.
Now virtual machine RAM size can be increased and decreased with the
prlctl set --memsize command without rebooting the VM.
3.7.4. Configuring Virtual Machine Memory Guarantees¶
A memory guarantee is a percentage of virtual machine’s RAM that said VM is guaranteed to have.
The total memory guaranteed to all running virtual environments on the host must not exceed host’s physical RAM size. If starting a virtual environment with a memory guarantee would increase the total memory guarantee on the host beyond host’s physical RAM size, said virtual environment will not start. If setting a memory guarantee for a running virtual environment would increase the total memory guarantee on the host beyond host’s physical RAM size, said memory guarantee will not be set.
For virtual machines, the memory guarantee value is set to 80% by default. To change the default value, use the
prlctl set --memguarantee command. For example:
# prlctl set MyVM --memguarantee 60
To revert to the default setting, run
# prlctl set MyVM --memguarantee auto
Virtual machines with memory guarantees can only be started with
prlctl start. Starting such VMs differently (e.g., using
virsh) will result in memory guarantees not being applied.