From: Peter Krempa Date: Thu, 1 Nov 2012 14:45:47 +0000 (+0100) Subject: qemu: Fix possible race when pausing guest X-Git-Tag: v0.10.2.2~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=beb086f63877165afce0e0076436bd446434fc7f;p=thirdparty%2Flibvirt.git qemu: Fix possible race when pausing guest 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. (cherry picked from commit d0fc6dc8315b3172501e6fe09c8aed12598de47e) --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 90ee99f4b1..100f06ccb7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1570,14 +1570,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; @@ -1587,6 +1579,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,