Increase a VM’s available memory with virsh

If you try to increase the amount of available memory using the obvious command it fails with an error message:

# virsh setmem <vm name> 16G --live
error: invalid argument: cannot set memory higher than max memory

The physical host in this case has 128G RAM and 32 CPUs. Plenty of capacity. To increase the maximum amount of memory that can be allocated to the VM:

# virsh setmaxmem <vm name> 16G --config

There are also –live and –current options which claim to affect the running/current domain. These options do not actually work. You have to use the –config option (changes take effect after next boot) and then power off the machine by logging in and running “poweroff”.

Once the machine is off set the actual memory with:

# virsh setmem <vm name> 16G --config

Then start the vm:

# virsh start <vm name>

Once the VM starts up it will have more memory.

Hope you find this useful.

Share Button

3 thoughts on “Increase a VM’s available memory with virsh

  1. Thanks for this. I had a libvirt VM that I bought up using Vagrant. I had it set to 2GB of ram on VirtualBox, but totally forgot to add a section for libvirt+kvm. Vagrant can’t adjust machines after you bring them up apparently :( This worked perfectly though. Thanks!

  2. Thanks, that is very helpful. The “maximum memory” is weird. Why do the system requires one “maximum memory”, then a “real memory”?

Leave a Reply

Your email address will not be published. Required fields are marked *