From 0b483ddcb317670eddfa8f09849441d82da54478 Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Thu, 23 Mar 2017 18:22:15 +0100 Subject: [PATCH] docs: Improve documentation related to memory locking --- docs/formatdomain.html.in | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index f671838e15..aae5e9c071 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -937,14 +937,21 @@
locked
When set and supported by the hypervisor, memory pages belonging to the domain will be locked in host's memory and the host will not - be allowed to swap them out. For QEMU/KVM this requires - hard_limit memory tuning - element to be used and set to the maximum memory configured for the - domain plus any memory consumed by the QEMU process itself. Beware of - setting the memory limit too high (and thus allowing the domain to lock - most of the host's memory). Doing so may be dangerous to both the - domain and the host itself since the host's kernel may run out of - memory. Since 1.0.6
+ be allowed to swap them out, which might be required for some + workloads such as real-time. For QEMU/KVM guests, the memory used by + the QEMU process itself will be locked too: unlike guest memory, this + is an amount libvirt has no way of figuring out in advance, so it has + to remove the limit on locked memory altogether. Thus, enabling this + option opens up to a potential security risk: the host will be unable + to reclaim the locked memory back from the guest when it's running out + of memory, which means a malicious guest allocating large amounts of + locked memory could cause a denial-of-service attach on the host. + Because of this, using this option is discouraged unless your workload + demands it; even then, it's highly recommended to set an + hard_limit (see + memory tuning) on memory allocation + suitable for the specific environment at the same time to mitigate + the risks described above. Since 1.0.6
source
In this attribute you can switch to file memorybacking or keep default anonymous.
access
@@ -989,12 +996,18 @@
hard_limit
The optional hard_limit element is the maximum memory the guest can use. The units for this value are kibibytes (i.e. blocks - of 1024 bytes). However, users of QEMU and KVM are strongly - advised not to set this limit as domain may get killed by the kernel - if the guess is too low. To determine the memory needed for a process - to run is an + of 1024 bytes). Users of QEMU and KVM are strongly advised not to set + this limit as domain may get killed by the kernel if the guess is too + low, and determining the memory needed for a process to run is an - undecidable problem.
+ undecidable problem; that said, if you already set + locked in + memory backing because your + workload demands it, you'll have to take into account the specifics of + your deployment and figure out a value for hard_limit that + balances the risk of your guest being killed because the limit was set + too low and the risk of your host crashing because it cannot reclaim + the memory used by the guest due to locked. Good luck!
soft_limit
The optional soft_limit element is the memory limit to enforce during memory contention. The units for this value are -- 2.47.2