Blame SOURCES/libvirt-qemuMonitorTestProcessCommandDefaultValidate-Output-validator-output-to-stderr.patch

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