mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
qemuAgentGetHostname: expose 'report_unsupported' argument
Use qemuAgentCommandFull in qemuAgentGetHostname so that we can suppress error reports if the caller will not require them. Callers for now always require error reporting but will be fixed later. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
280aa14dd8
commit
3332e5211a
@ -1716,24 +1716,32 @@ qemuAgentUpdateCPUInfo(unsigned int nvcpus,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* qemuAgentGetHostname:
|
||||||
|
*
|
||||||
|
* Gets the guest hostname using the guest agent.
|
||||||
|
*
|
||||||
|
* Returns 0 on success and fills @hostname. On error -1 is returned with an
|
||||||
|
* error reported and if '@report_unsupported' is false -2 is returned if the
|
||||||
|
* guest agent does not support the command without reporting an error
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
qemuAgentGetHostname(qemuAgentPtr agent,
|
qemuAgentGetHostname(qemuAgentPtr agent,
|
||||||
char **hostname)
|
char **hostname,
|
||||||
|
bool report_unsupported)
|
||||||
{
|
{
|
||||||
g_autoptr(virJSONValue) cmd = qemuAgentMakeCommand("guest-get-host-name", NULL);
|
g_autoptr(virJSONValue) cmd = qemuAgentMakeCommand("guest-get-host-name", NULL);
|
||||||
g_autoptr(virJSONValue) reply = NULL;
|
g_autoptr(virJSONValue) reply = NULL;
|
||||||
virJSONValuePtr data = NULL;
|
virJSONValuePtr data = NULL;
|
||||||
const char *result = NULL;
|
const char *result = NULL;
|
||||||
|
int rc;
|
||||||
|
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) {
|
if ((rc = qemuAgentCommandFull(agent, cmd, &reply, agent->timeout,
|
||||||
if (qemuAgentErrorCommandUnsupported(reply))
|
report_unsupported)) < 0)
|
||||||
return -2;
|
return rc;
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(data = virJSONValueObjectGet(reply, "return"))) {
|
if (!(data = virJSONValueObjectGet(reply, "return"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
@ -129,7 +129,8 @@ int qemuAgentUpdateCPUInfo(unsigned int nvcpus,
|
|||||||
|
|
||||||
int
|
int
|
||||||
qemuAgentGetHostname(qemuAgentPtr mon,
|
qemuAgentGetHostname(qemuAgentPtr mon,
|
||||||
char **hostname);
|
char **hostname,
|
||||||
|
bool report_unsupported);
|
||||||
|
|
||||||
int qemuAgentGetTime(qemuAgentPtr mon,
|
int qemuAgentGetTime(qemuAgentPtr mon,
|
||||||
long long *seconds,
|
long long *seconds,
|
||||||
|
@ -20237,7 +20237,7 @@ qemuDomainGetHostnameAgent(virQEMUDriverPtr driver,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
agent = qemuDomainObjEnterAgent(vm);
|
agent = qemuDomainObjEnterAgent(vm);
|
||||||
ignore_value(qemuAgentGetHostname(agent, hostname));
|
ignore_value(qemuAgentGetHostname(agent, hostname, true));
|
||||||
qemuDomainObjExitAgent(vm, agent);
|
qemuDomainObjExitAgent(vm, agent);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -23031,7 +23031,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
|
|||||||
goto exitagent;
|
goto exitagent;
|
||||||
}
|
}
|
||||||
if (supportedTypes & VIR_DOMAIN_GUEST_INFO_HOSTNAME) {
|
if (supportedTypes & VIR_DOMAIN_GUEST_INFO_HOSTNAME) {
|
||||||
rc = qemuAgentGetHostname(agent, &hostname);
|
rc = qemuAgentGetHostname(agent, &hostname, true);
|
||||||
if (rc < 0 && !(rc == -2 && types == 0))
|
if (rc < 0 && !(rc == -2 && types == 0))
|
||||||
goto exitagent;
|
goto exitagent;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user