On 02/24/2014 08:00 AM, Stefan Hajnoczi wrote:
What is the right way to check for enough free memory and memory
usage of a specific vm?
I would approach it in terms of guest RAM allocation plus QEMU overhead:
host_ram >= num_guests * guest_ram_size + num_guests * qemu_overhead
The qemu_overhead is the question mark. It depends on the QEMU features
the guests have enabled and number of devices.
QEMU also does not have a strict policy on predictable memory
consumption, which makes it hard to give a formula for it.
In fact, at one point libvirt tried to put an automatic cap on the
memory usable by qemu by multiplying RAM size and accounting for a
margin of overhead, but no matter what heuristics we tried, we still got
complaints from users that their guests were killed when they ran out of
memory, and so we ended up reverting the automatic limits from libvirt.
(You can still enforce a limit as an end user, although the libvirt
documentation no longer recommends attempting that, for as long as the
qemu allocation remains unpredictable.)