diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 742632f6deec0449fc67230715c7e76208bce16d..4de12280208df2f3e848ee2109423ed50d9cd550 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -371,6 +371,10 @@ struct _qemuDomainObjPrivate { * RESUME event handler to use it */ virDomainRunningReason runningReason; + /* qemuProcessStopCPUs stores the reason for pausing vCPUs here for the + * STOP event handler to use it */ + virDomainPausedReason pausedReason; + /* true if libvirt remembers the original owner for files */ bool rememberOwner; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index dc7317b7238e4487c935cc4119d09d9f346bffb1..a142e30f88f7d591bc3c3380f03fc09ef9643849 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -646,14 +646,17 @@ qemuProcessHandleStop(qemuMonitorPtr mon ATTRIBUTE_UNUSED, { virQEMUDriverPtr driver = opaque; virObjectEventPtr event = NULL; - virDomainPausedReason reason = VIR_DOMAIN_PAUSED_UNKNOWN; + virDomainPausedReason reason; virDomainEventSuspendedDetailType detail = VIR_DOMAIN_EVENT_SUSPENDED_PAUSED; virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + qemuDomainObjPrivatePtr priv = vm->privateData; virObjectLock(vm); - if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) { - qemuDomainObjPrivatePtr priv = vm->privateData; + reason = priv->pausedReason; + priv->pausedReason = VIR_DOMAIN_PAUSED_UNKNOWN; + + if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) { if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT) { if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) { @@ -3235,6 +3238,8 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver, VIR_FREE(priv->lockState); + priv->pausedReason = reason; + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) goto cleanup; @@ -3257,6 +3262,9 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver, VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); cleanup: + if (ret < 0) + priv->pausedReason = VIR_DOMAIN_PAUSED_UNKNOWN; + return ret; } @@ -6104,6 +6112,7 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver, priv->monError = false; priv->monStart = 0; priv->runningReason = VIR_DOMAIN_RUNNING_UNKNOWN; + priv->pausedReason = VIR_DOMAIN_PAUSED_UNKNOWN; VIR_DEBUG("Updating guest CPU definition"); if (qemuProcessUpdateGuestCPU(vm->def, priv->qemuCaps, caps, flags) < 0)