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@xxxxxxxxxx> --- src/qemu/qemu_monitor_json.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 31eb01006c..c18cef5c1a 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -388,8 +388,9 @@ qemuMonitorJSONCommandName(virJSONValuePtr cmd) } static int -qemuMonitorJSONCheckError(virJSONValuePtr cmd, - virJSONValuePtr reply) +qemuMonitorJSONCheckErrorFull(virJSONValuePtr cmd, + virJSONValuePtr reply, + bool report) { if (virJSONValueObjectHasKey(reply, "error")) { virJSONValuePtr error = virJSONValueObjectGet(reply, "error"); @@ -400,6 +401,9 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd, VIR_DEBUG("unable to execute QEMU command %s: %s", NULLSTR(cmdstr), NULLSTR(replystr)); + if (!report) + return -1; + /* Only send the user the command name + friendly error */ if (!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", NULLSTR(cmdstr), NULLSTR(replystr)); + + if (!report) + return -1; + virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to execute QEMU command '%s'"), qemuMonitorJSONCommandName(cmd)); @@ -427,6 +435,14 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd, } +static int +qemuMonitorJSONCheckError(virJSONValuePtr cmd, + virJSONValuePtr reply) +{ + return qemuMonitorJSONCheckErrorFull(cmd, reply, true); +} + + static int qemuMonitorJSONCheckReply(virJSONValuePtr cmd, virJSONValuePtr reply, -- 2.24.1