libvirt/SOURCES/libvirt-qemuMonitorTestProc...

81 lines
3.3 KiB
Diff

From 881e24d9b7545122a4b74f4545135bffe98fab4c Mon Sep 17 00:00:00 2001
Message-Id: <881e24d9b7545122a4b74f4545135bffe98fab4c@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Sun, 26 Apr 2020 13:04:04 -0400
Subject: [PATCH] qemuMonitorTestProcessCommandDefaultValidate: Output
validator output to stderr
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Trying to squeeze the validator output into the monitor reply message
doesn't make sense and doesn't work well as it's not well formed JSON:
54) qemuMonitorJSONAddNetdev ... libvirt: error : internal error: cannot parse json { "error": { "desc": "failed to validate arguments of 'netdev_add' against QAPI schema: {
ERROR: variant 'test' for discriminator 'type' not found
", "class": "UnexpectedCommand" } }: lexical error: invalid character inside string.
ev_add' against QAPI schema: { ERROR: variant 'test' for
(right here) ------^
FAILED
Output it to stderr if requested and just note that schema validation
failed in the error message:
54) qemuMonitorJSONAddNetdev ...
failed to validate arguments of 'netdev_add' against QAPI schema
args:
{
"id": "net0",
"type": "test"
}
validator output:
{
ERROR: variant 'test' for discriminator 'type' not found
libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'netdev_add': failed to validate arguments of 'netdev_add' against QAPI schema (to see debug output use VIR_TEST_DEBUG=2)
FAILED
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 5a13eb165559039bda2c1e0e4149dba0e0af820e)
Required on 8.2.1 branch due to adding caps_5.0.0.x86_64.replies
Prerequisite for https://bugzilla.redhat.com/1802592
Signed-off-by: Laine Stump <laine@redhat.com>
Message-Id: <20200426170415.18328-2-laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
tests/qemumonitortestutils.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index b29e5d8cd2..b72f186374 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -537,10 +537,19 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test,
}
if (testQEMUSchemaValidate(args, schemaroot, test->qapischema, &debug) < 0) {
+ if (virTestGetDebug() == 2) {
+ g_autofree char *argstr = virJSONValueToString(args, true);
+ fprintf(stderr,
+ "\nfailed to validate arguments of '%s' against QAPI schema\n"
+ "args:\n%s\nvalidator output:\n %s\n",
+ cmdname, NULLSTR(argstr), virBufferCurrentContent(&debug));
+ }
+
if (qemuMonitorReportError(test,
"failed to validate arguments of '%s' "
- "against QAPI schema: %s",
- cmdname, virBufferCurrentContent(&debug)) == 0)
+ "against QAPI schema "
+ "(to see debug output use VIR_TEST_DEBUG=2)",
+ cmdname) == 0)
return 1;
return -1;
}
--
2.26.2