提交 5a13eb16 编写于 作者: P Peter Krempa

qemuMonitorTestProcessCommandDefaultValidate: Output validator output to stderr

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 203e802d
...@@ -538,10 +538,19 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test, ...@@ -538,10 +538,19 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test,
args = emptyargs = virJSONValueNewObject(); args = emptyargs = virJSONValueNewObject();
if (testQEMUSchemaValidate(args, schemaroot, test->qapischema, &debug) < 0) { 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, if (qemuMonitorReportError(test,
"failed to validate arguments of '%s' " "failed to validate arguments of '%s' "
"against QAPI schema: %s", "against QAPI schema "
cmdname, virBufferCurrentContent(&debug)) == 0) "(to see debug output use VIR_TEST_DEBUG=2)",
cmdname) == 0)
return 1; return 1;
return -1; return -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册