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 <limit> --soft-limit <limit> --swap-hard-limit <limit> --min-guarantee <quantity>
Options
Table 2.1. 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 <limit>
optional
Maximum memory the guest domain can use.
Limit is in kilobytes.
Applies to QEMU and LXC only.
--soft-limit <limit>
optional
A soft limit is enforced when the host is running short on free resources or during resource contention. The guest domains' resources are then reduced to the soft-limit as an attempt to regain free resources.
Limit is in kilobytes.
Applies to QEMU and LXC only.
--swap-hard-limit <limit>
optional
Maximum swap memory the guest domain can use.
Limit is in kilobytes.
Applies to QEMU and LXC only.
--min-guarantee <quantity>
optional
Minimum amount of memory required to start a guest domain.
Quantity is in kilobytes.
VMware ESX and vSphere only.

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