Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1607253

Summary: Restart nova-compute service caused libvirtd memleak
Product: Red Hat Enterprise Linux 7 Reporter: chhu
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Status: CLOSED NOTABUG QA Contact: chhu
Severity: medium Docs Contact:
Priority: high    
Version: 7.6CC: chhu, fjin, lmen, tburke, xuzhang, yalzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-09-12 13:24:10 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:
Attachments:
Description Flags
libvird memleak when restart nova-compute service none

Description chhu 2018-07-23 05:48:27 UTC
Description of problem:
Restart nova-compute service caused libvirtd memleak

Version-Release number of selected component (if applicable):
libvirt-4.5.0-3.el7.x86_64
qemu-kvm-rhev-2.12.0-7.el7.x86_64

with RHOS13:
openstack-nova-compute-17.0.3-0.20180420001141.el7ost.noarch

How reproducible:
100%

Steps to Reproduce:
1. Start a VM on rhos with volume backend on nfs
2. Stop nova-compute and libvirtd service
3. Start libvirtd via valgrind
/usr/bin/valgrind --quiet --leak-check=full --time-stamp=yes /usr/sbin/libvirtd --listen 2>&1 | tee /home/memleak.log

4. Restart nova-compute service 10 times for causing memory leak of libvirtd
# for i in {1..10}; do systemctl restart openstack-nova-compute.service; sleep 10; done

5. Check there is memleak: libvirtd_restart_nova.memleak

==00:00:07:55.857 23009== 1,936 bytes in 2 blocks are definitely lost in loss record 4,355 of 4,498
==00:00:07:55.857 23009==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
==00:00:07:55.857 23009==    by 0x6E0FEE1: xmlGetGlobalState (in /usr/lib64/libxml2.so.2.9.1)
==00:00:07:55.857 23009==    by 0x6E0F6D4: __xmlIndentTreeOutput (in /usr/lib64/libxml2.so.2.9.1)
==00:00:07:55.857 23009==    by 0x538F889: virDomainDefFormatInternal (domain_conf.c:27347)
==00:00:07:55.857 23009==    by 0x284875B0: qemuDomainDefFormatBufInternal (qemu_domain.c:7268)
==00:00:07:55.857 23009==    by 0x28487BB4: qemuDomainDefFormatXMLInternal (qemu_domain.c:7298)
==00:00:07:55.857 23009==    by 0x28503C86: qemuDomainGetXMLDesc (qemu_driver.c:7083)
==00:00:07:55.857 23009==    by 0x54CAD2C: virDomainGetXMLDesc (libvirt-domain.c:2588)
==00:00:07:55.857 23009==    by 0x158689: remoteDispatchDomainGetXMLDesc (remote_daemon_dispatch_stubs.h:6663)
==00:00:07:55.857 23009==    by 0x158689: remoteDispatchDomainGetXMLDescHelper (remote_daemon_dispatch_stubs.h:6637)
==00:00:07:55.857 23009==    by 0x5405D34: virNetServerProgramDispatchCall (virnetserverprogram.c:437)
==00:00:07:55.857 23009==    by 0x5405D34: virNetServerProgramDispatch (virnetserverprogram.c:304)
==00:00:07:55.857 23009==    by 0x540C50C: virNetServerProcessMsg (virnetserver.c:143)
==00:00:07:55.857 23009==    by 0x540C50C: virNetServerHandleJob (virnetserver.c:164)
==00:00:07:55.857 23009==    by 0x53441A0: virThreadPoolWorker (virthreadpool.c:167)
==00:00:07:55.857 23009==
==00:00:07:55.857 23009== 1,936 bytes in 2 blocks are definitely lost in loss record 4,356 of 4,498
==00:00:07:55.857 23009==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
==00:00:07:55.857 23009==    by 0x6E0FEE1: xmlGetGlobalState (in /usr/lib64/libxml2.so.2.9.1)
==00:00:07:55.857 23009==    by 0x6E0F4D4: __xmlDefaultSAXHandler (in /usr/lib64/libxml2.so.2.9.1)
==00:00:07:55.857 23009==    by 0x6E69468: xmlDefaultSAXHandlerInit (in /usr/lib64/libxml2.so.2.9.1)
==00:00:07:55.857 23009==    by 0x6D9C601: xmlInitParserCtxt (in /usr/lib64/libxml2.so.2.9.1)
==00:00:07:55.857 23009==    by 0x6D9CDAB: xmlNewParserCtxt (in /usr/lib64/libxml2.so.2.9.1)
==00:00:07:55.857 23009==    by 0x534FB11: virXMLParseHelper (virxml.c:802)
==00:00:07:55.857 23009==    by 0x53D22AA: virCPUDefListParse (cpu_conf.c:1004)
==00:00:07:55.857 23009==    by 0x284FEE0A: qemuConnectBaselineCPU (qemu_driver.c:13386)
==00:00:07:55.857 23009==    by 0x54EA2E3: virConnectBaselineCPU (libvirt-host.c:1166)
==00:00:07:55.857 23009==    by 0x149EEF: remoteDispatchConnectBaselineCPU (remote_daemon_dispatch_stubs.h:177)
==00:00:07:55.857 23009==    by 0x149EEF: remoteDispatchConnectBaselineCPUHelper (remote_daemon_dispatch_stubs.h:155)
==00:00:07:55.857 23009==    by 0x5405D34: virNetServerProgramDispatchCall (virnetserverprogram.c:437)
==00:00:07:55.857 23009==    by 0x5405D34: virNetServerProgramDispatch (virnetserverprogram.c:304)

Actual results:
In step4,5, there is libvirtd memleak.

Expected results:
In step4,5, there isn't libvirtd memleak.

Additional info:
- libvirtd_restart_nova.memleak
- libvirtd_restart_nova.log

Comment 2 chhu 2018-07-23 05:51:56 UTC
Created attachment 1469853 [details]
libvird memleak when restart nova-compute service

Comment 3 Jiri Denemark 2018-09-06 16:00:57 UTC
Since valgrind was ran with --quiet and there are no debug logs from libvirtd,
it's hard to judge where the reported memory leaks come from. I suspect all of
them are reported from children which were forked at random times while
libvirt was doing something else.

Perhaps --child-silent-after-fork=yes parameter for valgrind would help here.

Comment 4 chhu 2018-09-11 01:44:49 UTC
(In reply to Jiri Denemark from comment #3)
> Since valgrind was ran with --quiet and there are no debug logs from
> libvirtd,
> it's hard to judge where the reported memory leaks come from. I suspect all
> of
> them are reported from children which were forked at random times while
> libvirt was doing something else.
> 
> Perhaps --child-silent-after-fork=yes parameter for valgrind would help here.

Yes, I retested with --child-silent-after-fork=yes, didn't hit memleak in "Description" part.


Detailed informations:
Test with packages:
libvirt-4.5.0-9.el7.x86_64
qemu-kvm-rhev-2.12.0-13.el7.x86_64

with RHOS13 z1:
openstack-nova-compute-17.0.3-0.20180420001141.el7ost.noarch

Test steps:
1. Start a VM in rhos13 from image, with default cinder backend(iscsi)
2. Stop nova-compute and libvird service
3. Start libvirtd via valgrind
4. Restart nova-compute service for causing memory leak 

5. Check the valgrind output.
- with --child-silent-after-fork=yes: no memleak
# /usr/bin/valgrind --quiet --leak-check=full --child-silent-after-fork=yes --time-stamp=yes /usr/sbin/libvirtd --listen 2>&1 | tee /home/memleak.log

- without --child-silent-after-fork=yes: hit memleak in "Description" part