]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Make sure qemudDomainSetVcpus doesn't hang.
authorChris Lalancette <clalance@redhat.com>
Wed, 10 Mar 2010 20:52:39 +0000 (15:52 -0500)
committerChris Lalancette <clalance@redhat.com>
Thu, 11 Mar 2010 17:44:53 +0000 (12:44 -0500)
The code to add job support into libvirtd caused a problem
in qemudDomainSetVcpus.  In particular, a qemuDomainObjEndJob()
call was added at the end of the function, but a
corresponding qemuDomainObjBeginJob() was not.  Additionally,
a call to qemuDomainObj{Enter,Exit}Monitor() was also missed
in qemudDomainHotplugVcpus().  These missing calls conspired to
cause a hang in the libvirtd process after the command was
finished.  Fix this by adding the missing calls.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
src/qemu/qemu_driver.c

index 3e7db902aad75ed4f186a732c6af9e2e92fb7dfe..be1490e44637ca867911d8e9b8d0ce075cf4271d 100644 (file)
@@ -4514,7 +4514,9 @@ static int qemudDomainHotplugVcpus(virDomainObjPtr vm, unsigned int nvcpus)
     if (nvcpus > vm->def->vcpus) {
         for (i = vm->def->vcpus ; i < nvcpus ; i++) {
             /* Online new CPU */
+            qemuDomainObjEnterMonitor(vm);
             rc = qemuMonitorSetCPU(priv->mon, i, 1);
+            qemuDomainObjExitMonitor(vm);
             if (rc == 0)
                 goto unsupported;
             if (rc < 0)
@@ -4525,7 +4527,9 @@ static int qemudDomainHotplugVcpus(virDomainObjPtr vm, unsigned int nvcpus)
     } else {
         for (i = vm->def->vcpus - 1 ; i >= nvcpus ; i--) {
             /* Offline old CPU */
+            qemuDomainObjEnterMonitor(vm);
             rc = qemuMonitorSetCPU(priv->mon, i, 0);
+            qemuDomainObjExitMonitor(vm);
             if (rc == 0)
                 goto unsupported;
             if (rc < 0)
@@ -4558,18 +4562,21 @@ static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
     vm = virDomainFindByUUID(&driver->domains, dom->uuid);
     qemuDriverUnlock(driver);
 
+    if (qemuDomainObjBeginJob(vm) < 0)
+        goto cleanup;
+
     if (!vm) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
         virUUIDFormat(dom->uuid, uuidstr);
         qemuReportError(VIR_ERR_NO_DOMAIN,
                         _("no domain with matching uuid '%s'"), uuidstr);
-        goto cleanup;
+        goto endjob;
     }
 
     if (!virDomainObjIsActive(vm)) {
         qemuReportError(VIR_ERR_OPERATION_INVALID,
                          "%s", _("domain is not running"));
-        goto cleanup;
+        goto endjob;
     }
 
     if (!(type = virDomainVirtTypeToString(vm->def->virtType))) {