agentError is used for 2 different cases:
1. agent monitor is failed to start
2. io error in agent monitor
Actually to check for the first case we don't need the
flag at all. NULL agent is always error for old qemu
(QEMU_CAPS_VSERPORT_CHANGE is not supported), while
for modern qemu it is an error only if channel is in
connected state.
---
src/qemu/qemu_domain.c | 37 +++++++++++++++++++++++--------------
src/qemu/qemu_process.c | 1 -
2 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 9b1a32e..cd788c8 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5046,6 +5046,7 @@ qemuDomainAgentAvailable(virDomainObjPtr vm,
bool reportError)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
+ virDomainChrDefPtr config;
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
if (reportError) {
@@ -5062,22 +5063,30 @@ qemuDomainAgentAvailable(virDomainObjPtr vm,
}
return false;
}
- if (!priv->agent) {
- if (qemuFindAgentConfig(vm->def)) {
- if (reportError) {
- virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s",
- _("QEMU guest agent is not connected"));
- }
- return false;
- } else {
- if (reportError) {
- virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
- _("QEMU guest agent is not configured"));
- }
- return false;
+
+ if (priv->agent)
+ return true;
+
+ config = qemuFindAgentConfig(vm->def);
+
+ if (!config) {
+ if (reportError) {
+ virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+ _("QEMU guest agent is not configured"));
}
+ } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VSERPORT_CHANGE) &&
+ config->state != VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED) {
+ if (reportError) {
+ virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s",
+ _("QEMU guest agent is not connected"));
+ }
+ } else if (reportError) {
+ virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s",
+ _("QEMU guest agent is not "
+ "available due to an error"));
}
- return true;
+
+ return false;
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d7c9ce3..78d530f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -267,7 +267,6 @@ qemuConnectAgent(virQEMUDriverPtr driver, virDomainObjPtr vm)
cleanup:
if (!priv->agent) {
VIR_WARN("Cannot connect to QEMU guest agent for %s",
vm->def->name);
- priv->agentError = true;
virResetLastError();
}
--
1.8.3.1