Use qemuAgentCommandFull so that callers of qemuAgentGetUsers can suppress error reports if the function is not supported by the guest agent. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_agent.c | 17 +++++++++-------- src/qemu/qemu_agent.h | 3 ++- src/qemu/qemu_driver.c | 2 +- tests/qemuagenttest.c | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 7de1fe496a..261fc67021 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2319,29 +2319,30 @@ qemuAgentSetUserPassword(qemuAgentPtr agent, } /* Returns: 0 on success - * -2 when agent command is not supported by the agent - * -1 otherwise + * -2 when agent command is not supported by the agent and + * 'report_unsupported' is false (libvirt error is not reported) + * -1 otherwise (libvirt error is reported) */ int qemuAgentGetUsers(qemuAgentPtr agent, virTypedParameterPtr *params, int *nparams, - int *maxparams) + int *maxparams, + bool report_unsupported) { g_autoptr(virJSONValue) cmd = NULL; g_autoptr(virJSONValue) reply = NULL; virJSONValuePtr data = NULL; size_t ndata; size_t i; + int rc; if (!(cmd = qemuAgentMakeCommand("guest-get-users", NULL))) return -1; - if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) { - if (qemuAgentErrorCommandUnsupported(reply)) - return -2; - return -1; - } + if ((rc = qemuAgentCommandFull(agent, cmd, &reply, agent->timeout, + report_unsupported)) < 0) + return rc; if (!(data = virJSONValueObjectGetArray(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h index 7cf38d7091..3702abf593 100644 --- a/src/qemu/qemu_agent.h +++ b/src/qemu/qemu_agent.h @@ -151,7 +151,8 @@ int qemuAgentSetUserPassword(qemuAgentPtr mon, int qemuAgentGetUsers(qemuAgentPtr mon, virTypedParameterPtr *params, int *nparams, - int *maxparams); + int *maxparams, + bool report_unsupported); int qemuAgentGetOSInfo(qemuAgentPtr mon, virTypedParameterPtr *params, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5e1f3efa7d..1347514b6c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -22907,7 +22907,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, * 'unsupported' errors and gather as much information as we can. In all * other cases, abort on error. */ if (supportedTypes & VIR_DOMAIN_GUEST_INFO_USERS) { - rc = qemuAgentGetUsers(agent, params, nparams, &maxparams); + rc = qemuAgentGetUsers(agent, params, nparams, &maxparams, true); if (rc < 0 && !(rc == -2 && types == 0)) goto exitagent; } diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index 86fbfbaa4c..dee9068ce5 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -1040,7 +1040,7 @@ testQemuAgentUsers(const void *data) /* get users */ if (qemuAgentGetUsers(qemuMonitorTestGetAgent(test), - ¶ms, &nparams, &maxparams) < 0) + ¶ms, &nparams, &maxparams, true) < 0) goto cleanup; if (virTypedParamsGetUInt(params, nparams, "user.count", &count) < 0) @@ -1069,7 +1069,7 @@ testQemuAgentUsers(const void *data) /* get users with domain */ if (qemuAgentGetUsers(qemuMonitorTestGetAgent(test), - ¶ms, &nparams, &maxparams) < 0) + ¶ms, &nparams, &maxparams, true) < 0) goto cleanup; if (virTypedParamsGetUInt(params, nparams, "user.count", &count) < 0) -- 2.24.1