agent: add qemuAgentArbitraryCommand() for general qemu agent command

Add a function qemuAgentArbitraryCommand() for general qemu agent command.

Signed-off-by: MATSUDA Daiki <matsudadik@intellilink.co.jp>
This commit is contained in:
MATSUDA Daiki 2012-08-23 12:29:22 +09:00 committed by Daniel Veillard
parent 05447e3af4
commit ff049d227b
2 changed files with 35 additions and 0 deletions

View File

@ -1410,3 +1410,33 @@ qemuAgentSuspend(qemuAgentPtr mon,
virJSONValueFree(reply);
return ret;
}
int
qemuAgentArbitraryCommand(qemuAgentPtr mon,
const char *cmd_str,
char **result,
int timeout)
{
int ret = -1;
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
*result = NULL;
if (timeout < VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN)
return ret;
cmd = virJSONValueFromString(cmd_str);
if (!cmd)
return ret;
ret = qemuAgentCommand(mon, cmd, &reply, timeout);
if (ret == 0) {
ret = qemuAgentCheckError(cmd, reply);
*result = virJSONValueToString(reply, false);
}
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
}

View File

@ -77,4 +77,9 @@ int qemuAgentFSThaw(qemuAgentPtr mon);
int qemuAgentSuspend(qemuAgentPtr mon,
unsigned int target);
int qemuAgentArbitraryCommand(qemuAgentPtr mon,
const char *cmd,
char **result,
int timeout);
#endif /* __QEMU_AGENT_H__ */