mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
qemuMonitorJSONCheckError: Allow suppressing of error reporting
In some cases we'll need to check whether there was an error but avoid reporting an actual libvirt error. Rename qemuMonitorJSONCheckError to qemuMonitorJSONCheckErrorFull with a new flag to suppress the error reporting and add a wrapper with the original name so that callers don't need to be fixed. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
cda31f3dba
commit
103bfbfd74
@ -388,8 +388,9 @@ qemuMonitorJSONCommandName(virJSONValuePtr cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuMonitorJSONCheckError(virJSONValuePtr cmd,
|
qemuMonitorJSONCheckErrorFull(virJSONValuePtr cmd,
|
||||||
virJSONValuePtr reply)
|
virJSONValuePtr reply,
|
||||||
|
bool report)
|
||||||
{
|
{
|
||||||
if (virJSONValueObjectHasKey(reply, "error")) {
|
if (virJSONValueObjectHasKey(reply, "error")) {
|
||||||
virJSONValuePtr error = virJSONValueObjectGet(reply, "error");
|
virJSONValuePtr error = virJSONValueObjectGet(reply, "error");
|
||||||
@ -400,6 +401,9 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd,
|
|||||||
VIR_DEBUG("unable to execute QEMU command %s: %s",
|
VIR_DEBUG("unable to execute QEMU command %s: %s",
|
||||||
NULLSTR(cmdstr), NULLSTR(replystr));
|
NULLSTR(cmdstr), NULLSTR(replystr));
|
||||||
|
|
||||||
|
if (!report)
|
||||||
|
return -1;
|
||||||
|
|
||||||
/* Only send the user the command name + friendly error */
|
/* Only send the user the command name + friendly error */
|
||||||
if (!error)
|
if (!error)
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -418,6 +422,10 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd,
|
|||||||
|
|
||||||
VIR_DEBUG("Neither 'return' nor 'error' is set in the JSON reply %s: %s",
|
VIR_DEBUG("Neither 'return' nor 'error' is set in the JSON reply %s: %s",
|
||||||
NULLSTR(cmdstr), NULLSTR(replystr));
|
NULLSTR(cmdstr), NULLSTR(replystr));
|
||||||
|
|
||||||
|
if (!report)
|
||||||
|
return -1;
|
||||||
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unable to execute QEMU command '%s'"),
|
_("unable to execute QEMU command '%s'"),
|
||||||
qemuMonitorJSONCommandName(cmd));
|
qemuMonitorJSONCommandName(cmd));
|
||||||
@ -427,6 +435,14 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuMonitorJSONCheckError(virJSONValuePtr cmd,
|
||||||
|
virJSONValuePtr reply)
|
||||||
|
{
|
||||||
|
return qemuMonitorJSONCheckErrorFull(cmd, reply, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuMonitorJSONCheckReply(virJSONValuePtr cmd,
|
qemuMonitorJSONCheckReply(virJSONValuePtr cmd,
|
||||||
virJSONValuePtr reply,
|
virJSONValuePtr reply,
|
||||||
|
Loading…
Reference in New Issue
Block a user