mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
qemuAgentGetFSInfo: expose 'report_unsupported' argument
Use qemuAgentCommandFull so that callers of qemuAgentGetFSInfo can suppress error reports if the function is not supported by the guest agent. Since this patch removes the last use of qemuAgentErrorCommandUnsupported the whole function is deleted as well. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
b126477685
commit
c3a7f46fe3
@ -993,31 +993,6 @@ qemuAgentStringifyErrorClass(const char *klass)
|
|||||||
return "unknown QEMU command error";
|
return "unknown QEMU command error";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Checks whether the agent reply msg is an error caused by an unsupported
|
|
||||||
* command.
|
|
||||||
*
|
|
||||||
* Returns true when reply is CommandNotFound or CommandDisabled
|
|
||||||
* false otherwise
|
|
||||||
*/
|
|
||||||
static bool
|
|
||||||
qemuAgentErrorCommandUnsupported(virJSONValuePtr reply)
|
|
||||||
{
|
|
||||||
const char *klass;
|
|
||||||
virJSONValuePtr error;
|
|
||||||
|
|
||||||
if (!reply)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
error = virJSONValueObjectGet(reply, "error");
|
|
||||||
|
|
||||||
if (!error)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
klass = virJSONValueObjectGetString(error, "class");
|
|
||||||
return STREQ_NULLABLE(klass, "CommandNotFound") ||
|
|
||||||
STREQ_NULLABLE(klass, "CommandDisabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ignoring OOM in this method, since we're already reporting
|
/* Ignoring OOM in this method, since we're already reporting
|
||||||
* a more important error
|
* a more important error
|
||||||
*
|
*
|
||||||
@ -1959,12 +1934,14 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Returns: number of entries in '@info' on success
|
/* Returns: number of entries in '@info' 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
|
||||||
qemuAgentGetFSInfo(qemuAgentPtr agent,
|
qemuAgentGetFSInfo(qemuAgentPtr agent,
|
||||||
qemuAgentFSInfoPtr **info)
|
qemuAgentFSInfoPtr **info,
|
||||||
|
bool report_unsupported)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -1973,16 +1950,15 @@ qemuAgentGetFSInfo(qemuAgentPtr agent,
|
|||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
size_t ndata = 0;
|
size_t ndata = 0;
|
||||||
qemuAgentFSInfoPtr *info_ret = NULL;
|
qemuAgentFSInfoPtr *info_ret = NULL;
|
||||||
|
int rc;
|
||||||
|
|
||||||
cmd = qemuAgentMakeCommand("guest-get-fsinfo", NULL);
|
cmd = qemuAgentMakeCommand("guest-get-fsinfo", NULL);
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) {
|
if ((rc = qemuAgentCommandFull(agent, cmd, &reply, agent->timeout,
|
||||||
if (qemuAgentErrorCommandUnsupported(reply))
|
report_unsupported)) < 0)
|
||||||
ret = -2;
|
return rc;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(data = virJSONValueObjectGet(reply, "return"))) {
|
if (!(data = virJSONValueObjectGet(reply, "return"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
@ -98,7 +98,9 @@ int qemuAgentShutdown(qemuAgentPtr mon,
|
|||||||
int qemuAgentFSFreeze(qemuAgentPtr mon,
|
int qemuAgentFSFreeze(qemuAgentPtr mon,
|
||||||
const char **mountpoints, unsigned int nmountpoints);
|
const char **mountpoints, unsigned int nmountpoints);
|
||||||
int qemuAgentFSThaw(qemuAgentPtr mon);
|
int qemuAgentFSThaw(qemuAgentPtr mon);
|
||||||
int qemuAgentGetFSInfo(qemuAgentPtr mon, qemuAgentFSInfoPtr **info);
|
int qemuAgentGetFSInfo(qemuAgentPtr mon,
|
||||||
|
qemuAgentFSInfoPtr **info,
|
||||||
|
bool report_unsupported);
|
||||||
|
|
||||||
int qemuAgentSuspend(qemuAgentPtr mon,
|
int qemuAgentSuspend(qemuAgentPtr mon,
|
||||||
unsigned int target);
|
unsigned int target);
|
||||||
|
@ -21883,7 +21883,7 @@ qemuDomainGetFSInfoAgent(virQEMUDriverPtr driver,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
agent = qemuDomainObjEnterAgent(vm);
|
agent = qemuDomainObjEnterAgent(vm);
|
||||||
ret = qemuAgentGetFSInfo(agent, info);
|
ret = qemuAgentGetFSInfo(agent, info, true);
|
||||||
qemuDomainObjExitAgent(vm, agent);
|
qemuDomainObjExitAgent(vm, agent);
|
||||||
|
|
||||||
endjob:
|
endjob:
|
||||||
@ -23041,7 +23041,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
|
|||||||
goto exitagent;
|
goto exitagent;
|
||||||
|
|
||||||
if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) {
|
if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) {
|
||||||
rc = qemuAgentGetFSInfo(agent, &agentfsinfo);
|
rc = qemuAgentGetFSInfo(agent, &agentfsinfo, true);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
if (!(rc == -2 && types == 0))
|
if (!(rc == -2 && types == 0))
|
||||||
goto exitagent;
|
goto exitagent;
|
||||||
|
@ -254,7 +254,7 @@ testQemuAgentGetFSInfo(const void *data)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((ninfo = qemuAgentGetFSInfo(qemuMonitorTestGetAgent(test),
|
if ((ninfo = qemuAgentGetFSInfo(qemuMonitorTestGetAgent(test),
|
||||||
&info)) < 0)
|
&info, true)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (ninfo != 3) {
|
if (ninfo != 3) {
|
||||||
@ -326,7 +326,7 @@ testQemuAgentGetFSInfo(const void *data)
|
|||||||
"}") < 0)
|
"}") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuAgentGetFSInfo(qemuMonitorTestGetAgent(test), &info) >= 0) {
|
if (qemuAgentGetFSInfo(qemuMonitorTestGetAgent(test), &info, true) >= 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"agent get-fsinfo command should have failed");
|
"agent get-fsinfo command should have failed");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user