Bug 1585155

Summary: QEMU core dumped when hotplug memory exceeding host hugepages and with discard-data=yes
Product: Red Hat Enterprise Linux 7 Reporter: Yumei Huang <yuhuang>
Component: qemu-kvm-rhevAssignee: Igor Mammedov <imammedo>
Status: CLOSED ERRATA QA Contact: Yumei Huang <yuhuang>
Severity: high Docs Contact:
Priority: high    
Version: 7.6CC: chayang, hhuang, jinzhao, juzhang, knoel, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-rhev-2.12.0-20.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1600365 (view as bug list) Environment:
Last Closed: 2019-08-22 09:18:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1600365, 1649160, 1651787    

Description Yumei Huang 2018-06-01 11:32:53 UTC
Description of problem:
Boot a guest, add a memory file backend object with option discard-data=yes, when backend size > host available hugepages, QEMU core dumped.

qemu-kvm: /builddir/build/BUILD/qemu-2.12.0/memory.c:2053: memory_region_get_ram_ptr: Assertion `mr->ram_block' failed.
Aborted (core dumped)


Version-Release number of selected component (if applicable):
qemu-kvm-rhev-2.12.0-2.el7
kernel-3.10.0-891.el7.x86_64

How reproducible:
always

Steps to Reproduce:
1. set hugepages on host

# mount
none on /mnt/kvm_hugepage type hugetlbfs (rw,relatime)

# cat /proc/meminfo  | grep -i huge
AnonHugePages:      8192 kB
HugePages_Total:     512
HugePages_Free:      512
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB


2. Boot a guest

# /usr/libexec/qemu-kvm -m 1024,slots=4,maxmem=32G -smp 16,cores=8,threads=1,sockets=2 -numa node -vnc :0 -monitor stdio

 
3. Hotplug memory, add a memory file backend object with discard-data=yes and size=2G

(qemu) object_add memory-backend-file,id=mem1,size=2G,mem-path=/mnt/kvm_hugepage,discard-data=yes


Actual results:
QEMU core dumped:
(qemu) object_add memory-backend-file,id=mem1,size=2G,mem-path=/mnt/kvm_hugepage,discard-data=yes
qemu-kvm: /builddir/build/BUILD/qemu-2.12.0/memory.c:2053: memory_region_get_ram_ptr: Assertion `mr->ram_block' failed.
Aborted (core dumped)


Expected results:
Instead of core dump, qemu prompt error message.


Additional info:
When set discard-data=no, qemu keep running and prompt error message:

(qemu) object_add memory-backend-file,id=mem1,size=2G,mem-path=/mnt/kvm_hugepage,discard-data=no
unable to map backing store for guest RAM: Cannot allocate memory
(qemu) info status
VM status: running

Comment 3 Miroslav Rezanina 2018-12-06 12:39:17 UTC
Fix included in qemu-kvm-rhev-2.12.0-20.el7

Comment 5 Yumei Huang 2018-12-18 06:51:58 UTC
Verify:
qemu-kvm-rhev-2.12.0-20.el7

Same steps with comment0, after step 3, qemu prompts error message instead of core dump.

(qemu) object_add memory-backend-file,id=mem1,size=2G,mem-path=/mnt/kvm_hugepage,discard-data=yes
unable to map backing store for guest RAM: Cannot allocate memory

Comment 7 errata-xmlrpc 2019-08-22 09:18:46 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2019:2553