qemu: Pass stop reason from qemuProcessStopCPUs to stop handler

Similar to commit [1] which saves and passes the running reason to
the RESUME event handler, during qemuProcessStopCPUs let's save and pass
the pause reason in the domain private data so that the STOP event
handler can use it.

[1] 5dab984ed : qemu: Pass running reason to RESUME event handler

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This commit is contained in:
Nikolay Shirokovskiy 2018-10-09 16:41:51 +03:00
parent b701e45be5
commit 93c7d13eec
2 changed files with 16 additions and 3 deletions

View File

@ -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;

View File

@ -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);
virObjectLock(vm);
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
qemuDomainObjPrivatePtr priv = vm->privateData;
virObjectLock(vm);
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)