提交 103bfbfd 编写于 作者: P Peter Krempa

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 cda31f3d
...@@ -388,8 +388,9 @@ qemuMonitorJSONCommandName(virJSONValuePtr cmd) ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册