KVM virsh memtune example

memtune domain [--hard-limit size] [--soft-limit size] [--swap-hard-limit size] [--min-guarantee size] [[--config] [--live] | [--current]]

Allows you to display or set the domain memory parameters. Without flags, the current settings are displayed; with a flag, the appropriate limit is adjusted if supported by the hypervisor. LXC and QEMU/KVM support --hard-limit, --soft-limit, and --swap-hard-limit. --min-guarantee is supported only by ESX hypervisor. Each of these limits are scaled integers, with a default of kibibytes (blocks of 1024 bytes) if no suffix is present. Libvirt rounds up to the nearest kibibyte. Some hypervisors require a larger granularity than KiB, and requests that are not an even multiple will be rounded up. For example, vSphere/ESX rounds the parameter up to mebibytes (1024 kibibytes).

If --live is specified, affect a running guest.
If --config is specified, affect the next boot of a persistent guest.
If --current is specified, affect the current guest state.
Both --live and --config flags may be given, but --current is exclusive.

If no flag is specified, behavior is different depending on hypervisor.

For QEMU/KVM, the parameters are applied to the QEMU process as a whole. Thus, when counting them, one needs to add up guest RAM, guest video RAM, and some memory overhead of QEMU itself. The last piece is hard to determine so one needs guess and try.

For LXC, the displayed hard_limit value is the current memory setting from the XML or the results from a virsh setmem command.

--hard-limit The maximum memory the guest can use.

--soft-limit The memory limit to enforce during memory contention.

--swap-hard-limit The maximum memory plus swap the guest can use. This has to be more than hard-limit value provided.

--min-guarantee The guaranteed minimum memory allocation for the guest.

Specifying -1 as a value for these limits is interpreted as unlimited.

# virsh memtune fedora-27     
hard_limit     : unlimited
soft_limit     : unlimited
swap_hard_limit: unlimited

# virsh memtune fedora-27 --soft-limit 2G

# virsh memtune fedora-27                
hard_limit     : unlimited
soft_limit     : 2097152
swap_hard_limit: unlimited
Edit

Pub: 05 Jan 2018 10:47 UTC

Views: 1036