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 Section 3.7.1, “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., MyVM):

  1. Make sure the VM is stopped.
  2. Run

    # prlctl set MyVM --mem-hotplug on
  3. Start the VM.

Now virtual machine RAM size can be increased and decreased with the prlctl set --memsize command without rebooting the VM.