提交 597bba39 编写于 作者: J Julio Faracco 提交者: John Ferlan

qemu: implementing qemuAgentGetHostname() function.

This commit implements the function qemuAgentGetHostname() that uses
the QEMU guest agent command 'guest-get-host-name' to retrieve the
guest hostname of virtual machine running the QEMU-GA.
Signed-off-by: NJulio Faracco <jcfaracco@gmail.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 cce98133
......@@ -1683,6 +1683,50 @@ qemuAgentUpdateCPUInfo(unsigned int nvcpus,
}
int
qemuAgentGetHostname(qemuAgentPtr mon,
char **hostname)
{
int ret = -1;
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
virJSONValuePtr data = NULL;
const char *result = NULL;
cmd = qemuAgentMakeCommand("guest-get-host-name",
NULL);
if (!cmd)
return ret;
if (qemuAgentCommand(mon, cmd, &reply, true,
VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
goto cleanup;
if (!(data = virJSONValueObjectGet(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed return value"));
goto cleanup;
}
if (!(result = virJSONValueObjectGetString(data, "host-name"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("'host-name' missing in guest-get-host-name reply"));
goto cleanup;
}
if (VIR_STRDUP(*hostname, result) < 0)
goto cleanup;
ret = 0;
cleanup:
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
}
int
qemuAgentGetTime(qemuAgentPtr mon,
long long *seconds,
......
......@@ -105,6 +105,10 @@ int qemuAgentUpdateCPUInfo(unsigned int nvcpus,
qemuAgentCPUInfoPtr cpuinfo,
int ncpuinfo);
int
qemuAgentGetHostname(qemuAgentPtr mon,
char **hostname);
int qemuAgentGetTime(qemuAgentPtr mon,
long long *seconds,
unsigned int *nseconds);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册