[libvirt] [PATCH 1/2] qemuTestDriverInit: init the driver lock too

Michal Privoznik mprivozn at redhat.com
Tue Sep 22 14:39:04 UTC 2015


Even though usage of the lock is limited to a very few cases,
it's still needed. Therefore we should initialize it too.
Otherwise we may get some random test failures:

==1204== Conditional jump or move depends on uninitialised value(s)
==1204==    at 0xEF7F7CF: pthread_mutex_lock (in /lib64/libpthread-2.20.so)
==1204==    by 0x9CA89A5: virMutexLock (virthread.c:89)
==1204==    by 0x450B2A: qemuDriverLock (qemu_conf.c:83)
==1204==    by 0x45549C: virQEMUDriverGetConfig (qemu_conf.c:869)
==1204==    by 0x448E29: qemuDomainDeviceDefPostParse (qemu_domain.c:1240)
==1204==    by 0x9CC9B13: virDomainDeviceDefPostParse (domain_conf.c:4224)
==1204==    by 0x9CC9B91: virDomainDefPostParseDeviceIterator (domain_conf.c:4251)
==1204==    by 0x9CC7843: virDomainDeviceInfoIterateInternal (domain_conf.c:3440)
==1204==    by 0x9CC9C25: virDomainDefPostParse (domain_conf.c:4276)
==1204==    by 0x9CEEE03: virDomainDefParseXML (domain_conf.c:16400)
==1204==    by 0x9CEF5B4: virDomainDefParseNode (domain_conf.c:16582)
==1204==    by 0x9CEF423: virDomainDefParse (domain_conf.c:16529)

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 tests/testutilsqemu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index cec2f6c..2f2be12 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -531,6 +531,7 @@ qemuTestParseCapabilities(const char *capsFile)
 
 void qemuTestDriverFree(virQEMUDriver *driver)
 {
+    virMutexDestroy(&driver->lock);
     virQEMUCapsCacheFree(driver->qemuCapsCache);
     virObjectUnref(driver->xmlopt);
     virObjectUnref(driver->caps);
@@ -567,9 +568,12 @@ int qemuTestCapsCacheInsert(virQEMUCapsCachePtr cache, const char *binary,
 
 int qemuTestDriverInit(virQEMUDriver *driver)
 {
+    if (virMutexInit(&driver->lock) < 0)
+        return -1;
+
     driver->config = virQEMUDriverConfigNew(false);
     if (!driver->config)
-        return -1;
+        goto error;
 
     driver->caps = testQemuCapsInit();
     if (!driver->caps)
-- 
2.4.9




More information about the libvir-list mailing list