render / rpms / libvirt

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