Managing Virtual Machine Memory Parameters
This section describes how to configure memory parameters available for virtual machines:
- Memory size
- Video memory size
- Memory hotplugging
- Memory guarantees
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:
| |
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.
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).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:
| |
To check that the new value has been successfully set, use this command:
| |
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
| |
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., MyVM):
Make sure the VM is stopped.
Enable memory hotplugging for the VM:
1# prlctl set MyVM --mem-hotplug onStart the VM.
Now virtual machine RAM size can be increased and decreased with the prlctl set --memsize command without rebooting the VM.
Configuring Virtual Machine Memory Guarantees
A memory guarantee is a percentage of virtual machine’s RAM that the VM is guaranteed to have.
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:
| |
To revert to the default setting, run
| |
prlctl start. Starting such VMs differently (e.g., using virsh) will result in memory guarantees not being applied.