Description of problem: There is memory leak in virsh when connection is closed. Version-Release number of selected component: # rpm -q libvirt libvirt-1.3.2-1.fc24_v1.3.1_79_g63e15ad.x86_64 How reproducible: 100% Steps to Reproduce: 1. # valgrind --leak-check=full virsh event --all --loop ==2669== Memcheck, a memory error detector ==2669== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==2669== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==2669== Command: virsh event --all --loop ==2669== 2. Stop libvirtd service # systemctl stop libvirtd 3. Check the output of valgrind: ...... ==2669== error: Disconnected from qemu:///system due to I/O error events received: 0 error: internal error: client socket is closed error: One or more references were leaked after disconnect from the hypervisor ==2669== ==2669== HEAP SUMMARY: ==2669== in use at exit: 138,889 bytes in 1,717 blocks ==2669== total heap usage: 3,359 allocs, 1,642 frees, 3,526,517 bytes allocated ==2669== ==2669== 81 bytes in 1 blocks are definitely lost in loss record 730 of 781 ==2669== at 0x4C2DC50: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==2669== by 0x69C2DFF: xmlSaveUri (uri.c:1068) ==2669== by 0x5560976: virURIFormat (viruri.c:256) ==2669== by 0x5616B7B: virConnectGetURI (libvirt-host.c:261) ==2669== by 0x12D66A: virshCatchDisconnect (virsh.c:109) ==2669== by 0x563A642: remoteClientCloseFunc (remote_driver.c:550) ==2669== by 0x565F907: virNetClientCloseLocked (virnetclient.c:693) ==2669== by 0x5660D2D: virNetClientIncomingEvent (virnetclient.c:1872) ==2669== by 0x55194E5: UnknownInlinedFun (vireventpoll.c:509) ==2669== by 0x55194E5: virEventPollRunOnce (vireventpoll.c:658) ==2669== by 0x5517C00: virEventRunDefaultImpl (virevent.c:314) ==2669== by 0x160B04: vshEventLoop (vsh.c:1864) ==2669== by 0x555B841: virThreadHelper (virthread.c:206) ==2669== ==2669== LEAK SUMMARY: ==2669== definitely lost: 81 bytes in 1 blocks ==2669== indirectly lost: 0 bytes in 0 blocks ==2669== possibly lost: 0 bytes in 0 blocks ==2669== still reachable: 138,808 bytes in 1,716 blocks ==2669== suppressed: 0 bytes in 0 blocks ==2669== Reachable blocks (those to which a pointer was found) are not shown. ==2669== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==2669== ==2669== For counts of detected and suppressed errors, rerun with: -v ==2669== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) Actual results: As step3 shown, there is memory leak in virsh when connection is closed No memory leak.
Upstream patch: https://www.redhat.com/archives/libvir-list/2016-March/msg00131.html
Fixed by: commit 34111a60f894b86f416434f0ec39c37999af4998 Author: Ján Tomko <jtomko> CommitDate: 2016-03-04 08:08:16 +0100 tools: do not leak uri in disconnect handler Commit 035947e introduced a call to virConnectGetURI without a matching free() in virshCatchDisconnect. Also fix vshAdmCatchDisconnect where it was copied by commit 6dd7e42. https://bugzilla.redhat.com/show_bug.cgi?id=1303891 git describe: v1.3.2-62-g34111a6