1
0

qemuAgentGetOSInfo: expose 'report_unsupported' argument

Use qemuAgentCommandFull so that callers of qemuAgentGetOSInfo can
suppress error reports if the function is not supported by the guest
agent.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2020-03-16 08:37:13 +01:00
parent de1d822691
commit d8ac171718
4 changed files with 14 additions and 12 deletions

View File

@ -2404,27 +2404,28 @@ qemuAgentGetUsers(qemuAgentPtr agent,
} }
/* Returns: 0 on success /* Returns: 0 on success
* -2 when agent command is not supported by the agent * -2 when agent command is not supported by the agent and
* -1 otherwise * 'report_unsupported' is false (libvirt error is not reported)
* -1 otherwise (libvirt error is reported)
*/ */
int int
qemuAgentGetOSInfo(qemuAgentPtr agent, qemuAgentGetOSInfo(qemuAgentPtr agent,
virTypedParameterPtr *params, virTypedParameterPtr *params,
int *nparams, int *nparams,
int *maxparams) int *maxparams,
bool report_unsupported)
{ {
g_autoptr(virJSONValue) cmd = NULL; g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL; g_autoptr(virJSONValue) reply = NULL;
virJSONValuePtr data = NULL; virJSONValuePtr data = NULL;
int rc;
if (!(cmd = qemuAgentMakeCommand("guest-get-osinfo", NULL))) if (!(cmd = qemuAgentMakeCommand("guest-get-osinfo", NULL)))
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 = virJSONValueObjectGetObject(reply, "return"))) { if (!(data = virJSONValueObjectGetObject(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",

View File

@ -157,7 +157,8 @@ int qemuAgentGetUsers(qemuAgentPtr mon,
int qemuAgentGetOSInfo(qemuAgentPtr mon, int qemuAgentGetOSInfo(qemuAgentPtr mon,
virTypedParameterPtr *params, virTypedParameterPtr *params,
int *nparams, int *nparams,
int *maxparams); int *maxparams,
bool report_unsupported);
int qemuAgentGetTimezone(qemuAgentPtr mon, int qemuAgentGetTimezone(qemuAgentPtr mon,
virTypedParameterPtr *params, virTypedParameterPtr *params,

View File

@ -23021,7 +23021,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
goto exitagent; goto exitagent;
} }
if (supportedTypes & VIR_DOMAIN_GUEST_INFO_OS) { if (supportedTypes & VIR_DOMAIN_GUEST_INFO_OS) {
rc = qemuAgentGetOSInfo(agent, params, nparams, &maxparams); rc = qemuAgentGetOSInfo(agent, params, nparams, &maxparams, true);
if (rc < 0 && !(rc == -2 && types == 0)) if (rc < 0 && !(rc == -2 && types == 0))
goto exitagent; goto exitagent;
} }

View File

@ -1139,7 +1139,7 @@ testQemuAgentOSInfo(const void *data)
/* get osinfo */ /* get osinfo */
if (qemuAgentGetOSInfo(qemuMonitorTestGetAgent(test), if (qemuAgentGetOSInfo(qemuMonitorTestGetAgent(test),
&params, &nparams, &maxparams) < 0) &params, &nparams, &maxparams, true) < 0)
goto cleanup; goto cleanup;
if (nparams != 8) { if (nparams != 8) {
@ -1184,7 +1184,7 @@ testQemuAgentOSInfo(const void *data)
/* get users with domain */ /* get users with domain */
if (qemuAgentGetOSInfo(qemuMonitorTestGetAgent(test), if (qemuAgentGetOSInfo(qemuMonitorTestGetAgent(test),
&params, &nparams, &maxparams) < 0) &params, &nparams, &maxparams, true) < 0)
goto cleanup; goto cleanup;
if (nparams != 10) { if (nparams != 10) {