提交 b1264776 编写于 作者: P Peter Krempa

qemuAgentGetTimezone: expose 'report_unsupported' argument

Use qemuAgentCommandFull so that callers of qemuAgentGetTimezone can
suppress error reports if the function is not supported by the guest
agent.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 d8ac1717
...@@ -2458,29 +2458,30 @@ qemuAgentGetOSInfo(qemuAgentPtr agent, ...@@ -2458,29 +2458,30 @@ qemuAgentGetOSInfo(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
qemuAgentGetTimezone(qemuAgentPtr agent, qemuAgentGetTimezone(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;
const char *name; const char *name;
int offset; int offset;
int rc;
if (!(cmd = qemuAgentMakeCommand("guest-get-timezone", NULL))) if (!(cmd = qemuAgentMakeCommand("guest-get-timezone", 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",
......
...@@ -163,7 +163,8 @@ int qemuAgentGetOSInfo(qemuAgentPtr mon, ...@@ -163,7 +163,8 @@ int qemuAgentGetOSInfo(qemuAgentPtr mon,
int qemuAgentGetTimezone(qemuAgentPtr mon, int qemuAgentGetTimezone(qemuAgentPtr mon,
virTypedParameterPtr *params, virTypedParameterPtr *params,
int *nparams, int *nparams,
int *maxparams); int *maxparams,
bool report_unsupported);
void qemuAgentSetResponseTimeout(qemuAgentPtr mon, void qemuAgentSetResponseTimeout(qemuAgentPtr mon,
int timeout); int timeout);
...@@ -23026,7 +23026,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, ...@@ -23026,7 +23026,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
goto exitagent; goto exitagent;
} }
if (supportedTypes & VIR_DOMAIN_GUEST_INFO_TIMEZONE) { if (supportedTypes & VIR_DOMAIN_GUEST_INFO_TIMEZONE) {
rc = qemuAgentGetTimezone(agent, params, nparams, &maxparams); rc = qemuAgentGetTimezone(agent, params, nparams, &maxparams, true);
if (rc < 0 && !(rc == -2 && types == 0)) if (rc < 0 && !(rc == -2 && types == 0))
goto exitagent; goto exitagent;
} }
......
...@@ -1244,7 +1244,7 @@ testQemuAgentTimezone(const void *data) ...@@ -1244,7 +1244,7 @@ testQemuAgentTimezone(const void *data)
response_) < 0) \ response_) < 0) \
goto cleanup; \ goto cleanup; \
if (qemuAgentGetTimezone(qemuMonitorTestGetAgent(test), \ if (qemuAgentGetTimezone(qemuMonitorTestGetAgent(test), \
&params_, &nparams_, &maxparams_) < 0) \ &params_, &nparams_, &maxparams_, true) < 0) \
goto cleanup; \ goto cleanup; \
if (nparams_ != 2) { \ if (nparams_ != 2) { \
virReportError(VIR_ERR_INTERNAL_ERROR, \ virReportError(VIR_ERR_INTERNAL_ERROR, \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册