]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix locking in qemudDomainMemoryStats
authorAdam Litke <agl@us.ibm.com>
Mon, 8 Mar 2010 14:15:44 +0000 (15:15 +0100)
committerDaniel Veillard <veillard@redhat.com>
Mon, 8 Mar 2010 14:15:44 +0000 (15:15 +0100)
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.

* src/qemu/qemu_driver.c: in qemudDomainMemoryStats() add missing
  calls to qemuDomainObjBeginJob/qemuDomainObjEndJob

src/qemu/qemu_driver.c

index 02068c46ede0d9884130a18768a7db4d55e0ccb9..57f3b2cb58db8085c7c74501bd7274a219e120b0 100644 (file)
@@ -7708,6 +7708,9 @@ qemudDomainMemoryStats (virDomainPtr dom,
         goto cleanup;
     }
 
+    if (qemuDomainObjBeginJob(vm) < 0)
+        goto cleanup;
+
     if (virDomainObjIsActive(vm)) {
         qemuDomainObjPrivatePtr priv = vm->privateData;
         qemuDomainObjEnterMonitor(vm);
@@ -7718,6 +7721,9 @@ qemudDomainMemoryStats (virDomainPtr dom,
                         "%s", _("domain is not running"));
     }
 
+    if (qemuDomainObjEndJob(vm) == 0)
+        vm = NULL;
+
 cleanup:
     if (vm)
         virDomainObjUnlock(vm);