diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index b9738bf1d9..1e03e67351 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -114,6 +114,8 @@ struct _qemuAgent { qemuAgentEvent await_event; }; +static int qemuAgentCheckError(virJSONValuePtr cmd, virJSONValuePtr reply); + static virClassPtr qemuAgentClass; static void qemuAgentDispose(void *obj); @@ -1013,6 +1015,7 @@ qemuAgentCommand(qemuAgentPtr mon, } } else { *reply = msg.rxObject; + ret = qemuAgentCheckError(cmd, *reply); } } @@ -1279,9 +1282,6 @@ int qemuAgentShutdown(qemuAgentPtr mon, ret = qemuAgentCommand(mon, cmd, &reply, VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK); - if (reply && ret == 0) - ret = qemuAgentCheckError(cmd, reply); - virJSONValueFree(cmd); virJSONValueFree(reply); return ret; @@ -1310,8 +1310,7 @@ int qemuAgentFSFreeze(qemuAgentPtr mon) return -1; if (qemuAgentCommand(mon, cmd, &reply, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0 || - qemuAgentCheckError(cmd, reply) < 0) + VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) goto cleanup; if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) { @@ -1348,8 +1347,7 @@ int qemuAgentFSThaw(qemuAgentPtr mon) return -1; if (qemuAgentCommand(mon, cmd, &reply, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0 || - qemuAgentCheckError(cmd, reply) < 0) + VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) goto cleanup; if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) { @@ -1388,9 +1386,6 @@ qemuAgentSuspend(qemuAgentPtr mon, ret = qemuAgentCommand(mon, cmd, &reply, VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK); - if (reply && ret == 0) - ret = qemuAgentCheckError(cmd, reply); - virJSONValueFree(cmd); virJSONValueFree(reply); return ret; @@ -1421,9 +1416,6 @@ qemuAgentArbitraryCommand(qemuAgentPtr mon, if ((ret = qemuAgentCommand(mon, cmd, &reply, timeout)) < 0) goto cleanup; - if ((ret = qemuAgentCheckError(cmd, reply)) < 0) - goto cleanup; - if (!(*result = virJSONValueToString(reply, false))) ret = -1; @@ -1451,9 +1443,6 @@ qemuAgentFSTrim(qemuAgentPtr mon, ret = qemuAgentCommand(mon, cmd, &reply, VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK); - if (reply && ret == 0) - ret = qemuAgentCheckError(cmd, reply); - virJSONValueFree(cmd); virJSONValueFree(reply); return ret;