From 93c7d13eec2f8ea84daec709ab4fbac16c9da6a0 Mon Sep 17 00:00:00 2001 From: Nikolay Shirokovskiy Date: Tue, 9 Oct 2018 16:41:51 +0300 Subject: [PATCH] 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 Signed-off-by: Nikolay Shirokovskiy --- src/qemu/qemu_domain.h | 4 ++++ src/qemu/qemu_process.c | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 742632f6de..4de1228020 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 dc7317b723..a142e30f88 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) -- GitLab