]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: fix a dead-lock problem
authorHu Tao <hutao@cn.fujitsu.com>
Tue, 12 Apr 2011 10:29:27 +0000 (18:29 +0800)
committerWen Congyang <wency@cn.fujitsu.com>
Wed, 13 Apr 2011 01:43:16 +0000 (09:43 +0800)
In qemuDomainObjBeginJobWithDriver, when virCondWaitUntil timeouts,
the function tries to call qemuDriverLock with virDomainObj locked,
this causes the dead-lock problem. This patch fixes this.

src/qemu/qemu_domain.c

index c2a1f9a0ad115909f94e95fa1e19491d658d87c4..a947b4e08a28eb3ac464b16816f724b9a897d76a 100644 (file)
@@ -506,15 +506,17 @@ int qemuDomainObjBeginJobWithDriver(struct qemud_driver *driver,
 
     while (priv->jobActive) {
         if (virCondWaitUntil(&priv->jobCond, &obj->lock, then) < 0) {
-            /* Safe to ignore value since ref count was incremented above */
-            ignore_value(virDomainObjUnref(obj));
             if (errno == ETIMEDOUT)
                 qemuReportError(VIR_ERR_OPERATION_TIMEOUT,
                                 "%s", _("cannot acquire state change lock"));
             else
                 virReportSystemError(errno,
                                      "%s", _("cannot acquire job mutex"));
+            virDomainObjUnlock(obj);
             qemuDriverLock(driver);
+            virDomainObjLock(obj);
+            /* Safe to ignore value since ref count was incremented above */
+            ignore_value(virDomainObjUnref(obj));
             return -1;
         }
     }