virQEMUCapsInitQMP: Don't dispose locked @vm

When creating qemu capabilities, a dummy virDomainObj is created just
because our monitor code expects that. However, the object is created
locked already. Then, under cleanup label, we simply unref the object
which results in whole domain object to be disposed. The object lock
is destroyed subsequently, but hey - it's still locked:

==24845== Thread #14's call to pthread_mutex_destroy failed
==24845==    with error code 16 (EBUSY: Device or resource busy)
==24845==    at 0x4C3024E: pthread_mutex_destroy (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==24845==    by 0x531F72E: virMutexDestroy (virthread.c:83)
==24845==    by 0x5302977: virObjectLockableDispose (virobject.c:237)
==24845==    by 0x5302A89: virObjectUnref (virobject.c:265)
==24845==    by 0x1DD37866: virQEMUCapsInitQMP (qemu_capabilities.c:3397)
==24845==    by 0x1DD37CC6: virQEMUCapsNewForBinary (qemu_capabilities.c:3481)
==24845==    by 0x1DD381E2: virQEMUCapsCacheLookup (qemu_capabilities.c:3609)
==24845==    by 0x1DD30F8A: virQEMUCapsInitGuest (qemu_capabilities.c:744)
==24845==    by 0x1DD31889: virQEMUCapsInit (qemu_capabilities.c:1020)
==24845==    by 0x1DD7DD36: virQEMUDriverCreateCapabilities (qemu_conf.c:888)
==24845==    by 0x1DDC57C0: qemuStateInitialize (qemu_driver.c:803)
==24845==    by 0x53DC743: virStateInitialize (libvirt.c:777)
==24845==

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 954427c35477752a4ef1789035f298fc9e7287e9)
This commit is contained in:
Michal Privoznik 2015-03-10 14:23:43 +01:00 committed by Cole Robinson
parent 0f9ee86062
commit 55576d3512

View File

@ -41,6 +41,7 @@
#include "qemu_monitor.h"
#include "virstring.h"
#include "qemu_hostdev.h"
#include "qemu_domain.h"
#include <fcntl.h>
#include <sys/stat.h>
@ -3394,7 +3395,7 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
if (monpath)
ignore_value(unlink(monpath));
VIR_FREE(monpath);
virObjectUnref(vm);
qemuDomObjEndAPI(&vm);
virObjectUnref(xmlopt);
if (pid != 0) {