Sometimes after domain restart agent is unavailabe even
if it is up and running in guest. Diagnostic message is
"QEMU guest agent is not available due to an error"
that is 'priv->agentError' is set. Investiagion shows that
'priv->agent' is not NULL, so error flag is set probably
during domain shutdown process and not cleaned up eventually.
The patch is quite simple - just clean up error flag unconditionally
upon domain stop.
Other hunks address other cases when error flag is not cleaned up.
1. processSerialChangedEvent. We need to clean error flag
unconditionally here too. For example if upon first 'connected' event we
fail to connect and set error flag and then connect on second
'connected' event then error flag will remain set erroneously
and make agent unavailable.
2. qemuProcessHandleAgentEOF. If error flag is set and we get
EOF we need to change state (and diagnostic) from 'error' to
'not connected'.
---
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_process.c | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ae1b9fe..c2a6336 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4467,8 +4467,8 @@ processSerialChangedEvent(virQEMUDriverPtr driver,
if (priv->agent) {
qemuAgentClose(priv->agent);
priv->agent = NULL;
- priv->agentError = false;
}
+ priv->agentError = false;
}
event = virDomainEventAgentLifecycleNewFromObj(vm, newstate,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 34f8b04..ffc8126 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -151,6 +151,7 @@ qemuProcessHandleAgentEOF(qemuAgentPtr agent,
qemuAgentClose(agent);
priv->agent = NULL;
+ priv->agentError = false;
virObjectUnlock(vm);
return;
@@ -5963,8 +5964,8 @@ void qemuProcessStop(virQEMUDriverPtr driver,
if (priv->agent) {
qemuAgentClose(priv->agent);
priv->agent = NULL;
- priv->agentError = false;
}
+ priv->agentError = false;
if (priv->mon) {
qemuMonitorClose(priv->mon);
--
1.8.3.1