Product SiteDocumentation Site

2.53. memtune

Allows you to display or set the memory parameters for a guest domain
Usage
memtune --domain domain-identifier --hard-limit kb --soft-limit kb --swap-hard-limit kb --min-guarantee kb
Options
Name Required? Description
--domain domain-identifier
required
The name, id, or UUID of the guest domain
The word "--domain" itself is optional.
--hard-limit kb
optional
Maximum memory the guest domain can use, in kilobytes. QEMU and LXC only.
--soft-limit kb
optional
Minimum memory guaranteed for the guest domain during contention, in kilobytes. QEMU and LXC only.
--swap-hard-limit kb
optional
Maximum swap memory the guest domain can use, in kilobytes. QEMU and LXC only.
--min-guarantee kb
optional
Minimum amount of memory required to start a guest domain, in kilobytes. VMware ESX and vSphere only.
Table 2.1. Options

Availability
Available from libvirt 0.8.5 onwards
Platform or Hypervisor specific notes
QEMU and LXC
The --hard-limit, --soft-limit, and --swap-hard-limit parameters are only used by QEMU and LXC.
VMware ESX and vSphere
The --min-guarantee parameter is only used by VMware ESX and vSphere.
Examples
Without flags the current settings are displayed:
virsh # memtune domain-id
This command sets the memory hard limit:
virsh # memtune domain-id --hard-limit kilobytes
This command sets the memory soft limit:
virsh # memtune domain-id --soft-limit kilobytes
This command sets the swap hard limit:
virsh # memtune domain-id --swap-hard-limit kilobytes
Adding the following lines to a guest domain xml file will set the given values for the memory tunables:
<memtune>
  <hard_limit>131072</hard_limit>
  <soft_limit>65536</soft_limit>
  <swap_hard_limit>262144</swap_hard_limit>
</memtune>
Example in context
We run the memtune command giving only a guest domain first, to see what the present values for the domain are:
virsh # memtune lxcbb1
hard_limit     : 131072
soft_limit     : 65536
swap_hard_limit: 262144
This shows the value for hard_limit is 131072, which means 128MB of memory. To change it to 256MB, we run the memtune command again giving it the new value (256 x 1024 = 262144):
virsh # memtune lxcbb1 --hard-limit 262144
Then verify the change has taken effect:
virsh # memtune lxcbb1
hard_limit     : 262144
soft_limit     : 65536
swap_hard_limit: 262144
See also