summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Krempa <pkrempa@redhat.com>2013-06-03 15:58:31 +0200
committerMartin Kletzander <mkletzan@redhat.com>2014-04-09 18:10:37 +0200
commit60f3065e0f59831359e4399ba4d23449aab02a8b (patch)
treeb6efacb1f2edfe4980620b88b948eca3dae5210d
parent892107de19b7fc67f8bf14053060c207902c6069 (diff)
downloadlibvirt-60f3065e0f59831359e4399ba4d23449aab02a8b.tar.gz
qemu: Properly report guest agent errors on command passthrough
The code for arbitrary guest agent passthrough was horribly broken since introduction. Fix it to correctly report errors. (cherry picked from commit 6e5b36d5d2fbe3c207651ab653b552dcae6af888)
-rw-r--r--src/qemu/qemu_agent.c31
-rw-r--r--src/qemu/qemu_driver.c10
2 files changed, 22 insertions, 19 deletions
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 3e26cf14a6..b9738bf1d9 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1403,25 +1403,32 @@ qemuAgentArbitraryCommand(qemuAgentPtr mon,
int timeout)
{
int ret = -1;
- virJSONValuePtr cmd;
+ virJSONValuePtr cmd = NULL;
virJSONValuePtr reply = NULL;
*result = NULL;
- if (timeout < VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN)
- return ret;
+ if (timeout < VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("guest agent timeout '%d' is "
+ "less than the minimum '%d'"),
+ timeout, VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN);
+ goto cleanup;
+ }
- cmd = virJSONValueFromString(cmd_str);
- if (!cmd)
- return ret;
+ if (!(cmd = virJSONValueFromString(cmd_str)))
+ goto cleanup;
+
+ if ((ret = qemuAgentCommand(mon, cmd, &reply, timeout)) < 0)
+ goto cleanup;
- ret = qemuAgentCommand(mon, cmd, &reply, timeout);
+ if ((ret = qemuAgentCheckError(cmd, reply)) < 0)
+ goto cleanup;
- if (ret == 0) {
- ret = qemuAgentCheckError(cmd, reply);
- if (!(*result = virJSONValueToString(reply, false)))
- ret = -1;
- }
+ if (!(*result = virJSONValueToString(reply, false)))
+ ret = -1;
+
+cleanup:
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8b2459f5f7..723f67b632 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14877,16 +14877,12 @@ qemuDomainAgentCommand(virDomainPtr domain,
qemuDomainObjEnterAgent(vm);
ret = qemuAgentArbitraryCommand(priv->agent, cmd, &result, timeout);
qemuDomainObjExitAgent(vm);
- if (ret < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to execute agent command"));
- goto endjob;
- }
+ if (ret < 0)
+ VIR_FREE(result);
endjob:
- if (qemuDomainObjEndJob(driver, vm) == 0) {
+ if (qemuDomainObjEndJob(driver, vm) == 0)
vm = NULL;
- }
cleanup:
if (vm)