[libvirt] Fix locking in qemudDomainMemoryStats

Adam Litke agl at us.ibm.com
Fri Mar 5 20:13:05 UTC 2010

When adding domainMemoryStats API support for the qemu driver, I didn't
follow the locking rules exactly.  The job condition must be held when
executing monitor commands.  This corrects the segfaults I was seeing
when calling domainMemoryStats in a multi-threaded environment.

If this patch is accepted, I would also consider it a candidate for the
0.7.6 stable patch stream (if such a thing exists).  Thanks.

Signed-off-by: Adam Litke <agl at us.ibm.com>

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b8b7916..a9023da 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7526,6 +7526,9 @@ qemudDomainMemoryStats (virDomainPtr dom,
         goto cleanup;
+    if (qemuDomainObjBeginJob(vm) < 0)
+        goto cleanup;
     if (virDomainObjIsActive(vm)) {
         qemuDomainObjPrivatePtr priv = vm->privateData;
@@ -7536,6 +7539,9 @@ qemudDomainMemoryStats (virDomainPtr dom,
                         "%s", _("domain is not running"));
+    if (qemuDomainObjEndJob(vm) == 0)
+        vm = NULL;
     if (vm)


More information about the libvir-list mailing list