]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: agent: cleanup agent error flag correctly
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Wed, 16 Nov 2016 13:43:03 +0000 (16:43 +0300)
committerMaxim Nestratov <mnestratov@virtuozzo.com>
Wed, 23 Nov 2016 08:14:44 +0000 (11:14 +0300)
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
src/qemu/qemu_process.c

index 1ecb243b8a88c605216c3c5367e2351e950932ce..ab030fe4f67df16fdb5c13dd3f0477a5cd8be90f 100644 (file)
@@ -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,
index d3a2cbd92a369f9608dd9449da2a6261348c728f..cb9eb229824ab7b9b0178c86943e5bf406686372 100644 (file)
@@ -151,6 +151,7 @@ qemuProcessHandleAgentEOF(qemuAgentPtr agent,
 
     qemuAgentClose(agent);
     priv->agent = NULL;
+    priv->agentError = false;
 
     virObjectUnlock(vm);
     return;
@@ -5995,8 +5996,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);