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