]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Fix possible race when pausing guest
authorPeter Krempa <pkrempa@redhat.com>
Thu, 1 Nov 2012 14:45:47 +0000 (15:45 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 2 Nov 2012 19:18:46 +0000 (20:18 +0100)
When pausing the guest while migration is running (to speed up
convergence) the virDomainSuspend API checks if the migration job is
active before entering the job. This could cause a possible race if the
virDomainSuspend is called while the job is active but ends before the
Suspend API enters the job (this would require that the migration is
aborted). This would cause a incorrect event to be emitted.

src/qemu/qemu_driver.c

index 549a8fc9ff5eb97e3af0f38ebfce32349444be5b..7480765167945c08b69193fe68ed392a0448ce92 100644 (file)
@@ -1661,14 +1661,6 @@ static int qemudDomainSuspend(virDomainPtr dom) {
 
     priv = vm->privateData;
 
-    if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT) {
-        reason = VIR_DOMAIN_PAUSED_MIGRATION;
-        eventDetail = VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED;
-    } else {
-        reason = VIR_DOMAIN_PAUSED_USER;
-        eventDetail = VIR_DOMAIN_EVENT_SUSPENDED_PAUSED;
-    }
-
     if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_SUSPEND) < 0)
         goto cleanup;
 
@@ -1678,6 +1670,14 @@ static int qemudDomainSuspend(virDomainPtr dom) {
         goto endjob;
     }
 
+    if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT) {
+        reason = VIR_DOMAIN_PAUSED_MIGRATION;
+        eventDetail = VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED;
+    } else {
+        reason = VIR_DOMAIN_PAUSED_USER;
+        eventDetail = VIR_DOMAIN_EVENT_SUSPENDED_PAUSED;
+    }
+
     state = virDomainObjGetState(vm, NULL);
     if (state == VIR_DOMAIN_PMSUSPENDED) {
         virReportError(VIR_ERR_OPERATION_INVALID,