mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
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)
This commit is contained in:
parent
892107de19
commit
60f3065e0f
@ -1403,25 +1403,32 @@ qemuAgentArbitraryCommand(qemuAgentPtr mon,
|
|||||||
int timeout)
|
int timeout)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virJSONValuePtr cmd;
|
virJSONValuePtr cmd = NULL;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
|
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
if (timeout < VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN)
|
if (timeout < VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN) {
|
||||||
return ret;
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
|
_("guest agent timeout '%d' is "
|
||||||
cmd = virJSONValueFromString(cmd_str);
|
"less than the minimum '%d'"),
|
||||||
if (!cmd)
|
timeout, VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN);
|
||||||
return ret;
|
goto cleanup;
|
||||||
|
|
||||||
ret = qemuAgentCommand(mon, cmd, &reply, timeout);
|
|
||||||
|
|
||||||
if (ret == 0) {
|
|
||||||
ret = qemuAgentCheckError(cmd, reply);
|
|
||||||
if (!(*result = virJSONValueToString(reply, false)))
|
|
||||||
ret = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(cmd = virJSONValueFromString(cmd_str)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
cleanup:
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
virJSONValueFree(reply);
|
virJSONValueFree(reply);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -14877,16 +14877,12 @@ qemuDomainAgentCommand(virDomainPtr domain,
|
|||||||
qemuDomainObjEnterAgent(vm);
|
qemuDomainObjEnterAgent(vm);
|
||||||
ret = qemuAgentArbitraryCommand(priv->agent, cmd, &result, timeout);
|
ret = qemuAgentArbitraryCommand(priv->agent, cmd, &result, timeout);
|
||||||
qemuDomainObjExitAgent(vm);
|
qemuDomainObjExitAgent(vm);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
VIR_FREE(result);
|
||||||
_("Failed to execute agent command"));
|
|
||||||
goto endjob;
|
|
||||||
}
|
|
||||||
|
|
||||||
endjob:
|
endjob:
|
||||||
if (qemuDomainObjEndJob(driver, vm) == 0) {
|
if (qemuDomainObjEndJob(driver, vm) == 0)
|
||||||
vm = NULL;
|
vm = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user