|
|
9c6c51 |
From a2e308060512eb7d4ee00f7baddb7394d6e9e4e6 Mon Sep 17 00:00:00 2001
|
|
|
9c6c51 |
Message-Id: <a2e308060512eb7d4ee00f7baddb7394d6e9e4e6@dist-git>
|
|
|
9c6c51 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9c6c51 |
Date: Mon, 10 Sep 2018 19:41:53 +0200
|
|
|
9c6c51 |
Subject: [PATCH] qemu: Pass running reason to RESUME event handler
|
|
|
9c6c51 |
MIME-Version: 1.0
|
|
|
9c6c51 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9c6c51 |
Content-Transfer-Encoding: 8bit
|
|
|
9c6c51 |
|
|
|
9c6c51 |
Whenever we get the RESUME event from QEMU, we change the state of the
|
|
|
9c6c51 |
affected domain to VIR_DOMAIN_RUNNING with VIR_DOMAIN_RUNNING_UNPAUSED
|
|
|
9c6c51 |
reason. This is fine if the domain is resumed unexpectedly, but when we
|
|
|
9c6c51 |
sent "cont" to QEMU we usually have a better reason for the state
|
|
|
9c6c51 |
change. The better reason is used in qemuProcessStartCPUs which also
|
|
|
9c6c51 |
sets the domain state to running if qemuMonitorStartCPUs reports
|
|
|
9c6c51 |
success. Thus we may end up with two state updates in a row, but the
|
|
|
9c6c51 |
final reason is correct.
|
|
|
9c6c51 |
|
|
|
9c6c51 |
This patch is a preparation for dropping the state change done in
|
|
|
9c6c51 |
qemuMonitorStartCPUs for which we need to pass the actual running reason
|
|
|
9c6c51 |
to the RESUME event handler and use it there instead of
|
|
|
9c6c51 |
VIR_DOMAIN_RUNNING_UNPAUSED.
|
|
|
9c6c51 |
|
|
|
9c6c51 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9c6c51 |
Reviewed-by: John Ferlan <jferlan@redhat.com>
|
|
|
9c6c51 |
(cherry picked from commit 5dab984ed0cd0332e59d719420ab2f9d009b952f)
|
|
|
9c6c51 |
|
|
|
9c6c51 |
https://bugzilla.redhat.com/show_bug.cgi?id=1634758
|
|
|
9c6c51 |
https://bugzilla.redhat.com/show_bug.cgi?id=1634759
|
|
|
9c6c51 |
|
|
|
9c6c51 |
Conflicts:
|
|
|
9c6c51 |
src/qemu/qemu_domain.h
|
|
|
9c6c51 |
- nodenames code is not backported
|
|
|
9c6c51 |
|
|
|
9c6c51 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9c6c51 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
9c6c51 |
---
|
|
|
9c6c51 |
src/qemu/qemu_domain.h | 4 ++++
|
|
|
9c6c51 |
src/qemu/qemu_process.c | 23 +++++++++++++++++------
|
|
|
9c6c51 |
2 files changed, 21 insertions(+), 6 deletions(-)
|
|
|
9c6c51 |
|
|
|
9c6c51 |
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
|
|
|
9c6c51 |
index e748d78adb..6a96f27a5f 100644
|
|
|
9c6c51 |
--- a/src/qemu/qemu_domain.h
|
|
|
9c6c51 |
+++ b/src/qemu/qemu_domain.h
|
|
|
9c6c51 |
@@ -363,6 +363,10 @@ struct _qemuDomainObjPrivate {
|
|
|
9c6c51 |
|
|
|
9c6c51 |
/* true if qemu-pr-helper process is running for the domain */
|
|
|
9c6c51 |
bool prDaemonRunning;
|
|
|
9c6c51 |
+
|
|
|
9c6c51 |
+ /* qemuProcessStartCPUs stores the reason for starting vCPUs here for the
|
|
|
9c6c51 |
+ * RESUME event handler to use it */
|
|
|
9c6c51 |
+ virDomainRunningReason runningReason;
|
|
|
9c6c51 |
};
|
|
|
9c6c51 |
|
|
|
9c6c51 |
# define QEMU_DOMAIN_PRIVATE(vm) \
|
|
|
9c6c51 |
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
|
9c6c51 |
index 26979faa72..7325bc4c90 100644
|
|
|
9c6c51 |
--- a/src/qemu/qemu_process.c
|
|
|
9c6c51 |
+++ b/src/qemu/qemu_process.c
|
|
|
9c6c51 |
@@ -692,21 +692,28 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
|
|
9c6c51 |
virQEMUDriverPtr driver = opaque;
|
|
|
9c6c51 |
virObjectEventPtr event = NULL;
|
|
|
9c6c51 |
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
|
9c6c51 |
+ qemuDomainObjPrivatePtr priv;
|
|
|
9c6c51 |
+ virDomainRunningReason reason = VIR_DOMAIN_RUNNING_UNPAUSED;
|
|
|
9c6c51 |
|
|
|
9c6c51 |
virObjectLock(vm);
|
|
|
9c6c51 |
- if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
|
|
|
9c6c51 |
- qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
9c6c51 |
|
|
|
9c6c51 |
+ priv = vm->privateData;
|
|
|
9c6c51 |
+ if (priv->runningReason != VIR_DOMAIN_RUNNING_UNKNOWN) {
|
|
|
9c6c51 |
+ reason = priv->runningReason;
|
|
|
9c6c51 |
+ priv->runningReason = VIR_DOMAIN_RUNNING_UNKNOWN;
|
|
|
9c6c51 |
+ }
|
|
|
9c6c51 |
+
|
|
|
9c6c51 |
+ if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
|
|
|
9c6c51 |
if (priv->gotShutdown) {
|
|
|
9c6c51 |
VIR_DEBUG("Ignoring RESUME event after SHUTDOWN");
|
|
|
9c6c51 |
goto unlock;
|
|
|
9c6c51 |
}
|
|
|
9c6c51 |
|
|
|
9c6c51 |
- VIR_DEBUG("Transitioned guest %s out of paused into resumed state",
|
|
|
9c6c51 |
- vm->def->name);
|
|
|
9c6c51 |
+ VIR_DEBUG("Transitioned guest %s out of paused into resumed state, "
|
|
|
9c6c51 |
+ "reason '%s'",
|
|
|
9c6c51 |
+ vm->def->name, virDomainRunningReasonTypeToString(reason));
|
|
|
9c6c51 |
|
|
|
9c6c51 |
- virDomainObjSetState(vm, VIR_DOMAIN_RUNNING,
|
|
|
9c6c51 |
- VIR_DOMAIN_RUNNING_UNPAUSED);
|
|
|
9c6c51 |
+ virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason);
|
|
|
9c6c51 |
event = virDomainEventLifecycleNewFromObj(vm,
|
|
|
9c6c51 |
VIR_DOMAIN_EVENT_RESUMED,
|
|
|
9c6c51 |
VIR_DOMAIN_EVENT_RESUMED_UNPAUSED);
|
|
|
9c6c51 |
@@ -3051,6 +3058,8 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm,
|
|
|
9c6c51 |
}
|
|
|
9c6c51 |
VIR_FREE(priv->lockState);
|
|
|
9c6c51 |
|
|
|
9c6c51 |
+ priv->runningReason = reason;
|
|
|
9c6c51 |
+
|
|
|
9c6c51 |
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
|
|
9c6c51 |
goto release;
|
|
|
9c6c51 |
|
|
|
9c6c51 |
@@ -3068,6 +3077,7 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm,
|
|
|
9c6c51 |
return ret;
|
|
|
9c6c51 |
|
|
|
9c6c51 |
release:
|
|
|
9c6c51 |
+ priv->runningReason = VIR_DOMAIN_RUNNING_UNKNOWN;
|
|
|
9c6c51 |
if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0)
|
|
|
9c6c51 |
VIR_WARN("Unable to release lease on %s", vm->def->name);
|
|
|
9c6c51 |
VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
|
|
|
9c6c51 |
@@ -5928,6 +5938,7 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver,
|
|
|
9c6c51 |
priv->monError = false;
|
|
|
9c6c51 |
priv->monStart = 0;
|
|
|
9c6c51 |
priv->gotShutdown = false;
|
|
|
9c6c51 |
+ priv->runningReason = VIR_DOMAIN_RUNNING_UNKNOWN;
|
|
|
9c6c51 |
|
|
|
9c6c51 |
VIR_DEBUG("Updating guest CPU definition");
|
|
|
9c6c51 |
if (qemuProcessUpdateGuestCPU(vm->def, priv->qemuCaps, caps, flags) < 0)
|
|
|
9c6c51 |
--
|
|
|
9c6c51 |
2.19.1
|
|
|
9c6c51 |
|