]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuDomainSendKey: Relax the qemu driver locking
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 24 Jan 2013 09:39:06 +0000 (10:39 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 25 Jan 2013 06:39:19 +0000 (07:39 +0100)
Currently, there is no reason to hold qemu driver locked
throughout whole API execution. Moreover, we can use the
new qemuDomObjFromDomain() internal API to lookup domain then.

src/qemu/qemu_driver.c

index d47b7960255124c2a8c5603cc0edfd8190612bdd..5b9215939b81cd588bec7a9be6630b3a9b2e573a 100644 (file)
@@ -2411,19 +2411,12 @@ static int qemuDomainSendKey(virDomainPtr domain,
         }
     }
 
-    qemuDriverLock(driver);
-    vm = virDomainFindByUUID(&driver->domains, domain->uuid);
-    if (!vm) {
-        char uuidstr[VIR_UUID_STRING_BUFLEN];
-        virUUIDFormat(domain->uuid, uuidstr);
-        virReportError(VIR_ERR_NO_DOMAIN,
-                       _("no domain with matching uuid '%s'"), uuidstr);
+    if (!(vm = qemuDomObjFromDomain(domain)))
         goto cleanup;
-    }
 
     priv = vm->privateData;
 
-    if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+    if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
         goto cleanup;
 
     if (!virDomainObjIsActive(vm)) {
@@ -2432,9 +2425,9 @@ static int qemuDomainSendKey(virDomainPtr domain,
         goto endjob;
     }
 
-    qemuDomainObjEnterMonitorWithDriver(driver, vm);
+    qemuDomainObjEnterMonitor(driver, vm);
     ret = qemuMonitorSendKey(priv->mon, holdtime, keycodes, nkeycodes);
-    qemuDomainObjExitMonitorWithDriver(driver, vm);
+    qemuDomainObjExitMonitor(driver, vm);
 
 endjob:
     if (qemuDomainObjEndJob(driver, vm) == 0)
@@ -2443,7 +2436,6 @@ endjob:
 cleanup:
     if (vm)
         virObjectUnlock(vm);
-    qemuDriverUnlock(driver);
     return ret;
 }