Red Hat Bugzilla – Bug 1269774
hotplug overcommit memory exceeding host memory cause qemu-kvm progress killed
Last modified: 2017-03-16 05:22:33 EDT
Description of problem:
hotplug overcommit memory exceeding host memory, cause the qemu-kvm progress killed.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. start a qemu-kvm progress, /usr/libexec/qemu-kvm -name rhel7.2-test -m 1G,slots=4,maxmem=4G -numa node -vnc :1 -monitor stdio
2. hotplug 8G memory, which execeed the host memory.
qemu-kvm progress quit. the terminal print "Killed".
(qemu) object_add memory-backend-ram,id=mem1,size=8G
qemu-kvm prevent the behavior, keep running, and print reasonable notice information.
doing regression testing
correct qemu-kvm command line in comments 0(add mlock=on to cli):
/usr/libexec/qemu-kvm -name rhel7.2-test -m 1G,slots=4,maxmem=4G -numa node -vnc :1 -monitor stdio -realtime mlock=on
I've test this with qemu-kvm-rhev-2.1.2-23.el7 and 2.3.0-2.el7, the bug appears in both version. So I think it's not a regression bug.
it works for me, object_add fails with "cannot set up guest memory 'mem1': Cannot allocate memory" error message
Pls, provide access to environment where it reproduces.
what is output of command: sysctl vm.overcommit_memory
on the host where it happens?
(In reply to Igor Mammedov from comment #7)
> what is output of command: sysctl vm.overcommit_memory
> on the host where it happens?
The output is "vm.overcommit_memory = 0".
Here are details:
# free -m
total used free shared buff/cache available
Mem: 7822 116 7599 1 106 7555
Swap: 8063 119 7944
# /usr/libexec/qemu-kvm -name rhel7.2-test -m 1G,slots=4,maxmem=4G -numa node -vnc :1 -monitor stdio -realtime mlock=on
QEMU 2.6.0 monitor - type 'help' for more information
(qemu) object_add memory-backend-ram,id=mem1,size=10G
# sysctl vm.overcommit_memory
vm.overcommit_memory = 0
To avoid running into OOM in this case, you need to disable overcommit to get reliable error on allocation.
That probably would limit amount of host memory you could use (might vary depending on host) but it can't be helped.
Other options might be to use cgroups/ulimit to cap QEMU instance size but I haven't tried.
Anyway it's not something that qemu can fix/handle, it's the way kernel allocates memory by default and handles OOM conditions.
If you fill that it should be changed - reopen and reassign bug to kernel component.
*** Bug 1432332 has been marked as a duplicate of this bug. ***