On Fri, Sep 23, 2022 at 05:42:13PM +0200, Peter Krempa wrote:
Introduce a new config option 'xml_validator' into the daemon
config
file which will allow users to make libvirt daemons use a custom XML
validator.
The rationale is that validators such as 'jing'[1] provide drastically
better error specification when compared to the native libxml2 validator
we use. A drawback though is that jing is written in Java and thus
unusable by libvirt directly and also not a popular package present in
distros.
For power users and developers it still is worth having this feature to
provide better errors in a native way.
I kinda wonder if those users need it integrated in libvirt
though, as opposed to just calling jing themselves when
needed. It feels like a fairly narrow set of users benefitting
here from this change, made even smaller by the fact that those
users have to remember to reconfigure libvirt to enable this.
An example showing the quality of the errors:
XML used:
<vcpu placement='static' current='1'>asdf8</vcpu>
native validator:
error: XML document failed to validate against schema: Unable to validate doc against
/home/pipo/libvirt/src/conf/schemas/domain.rng
Extra element vcpu in interleave
Invalid sequence in interleave
Element domain failed to validate content
jing:
error: XML document failed to validate against schema: Unable to validate doc against
/home/pipo/libvirt/src/conf/schemas/domain.rng
/dev/stdin:6:52: error: character content of element "vcpu" invalid; must be
an integer
No doubt the errors are way better, but a power user
can just invoke this script below themselves if they
ever want to understand a XML problem better.
Example script to make this feature work with jing:
#!/bin/bash
java -jar /home/pipo/git/jing-trang/build/jing.jar $1 /dev/stdin 2>&1 || exit 1
[1]
https://github.com/relaxng/jing-trang
To me this is only compelling if there's an option we can reasonably
wire up out of the box.
With regards,
Daniel
--
|:
https://berrange.com -o-
https://www.flickr.com/photos/dberrange :|
|:
https://libvirt.org -o-
https://fstop138.berrange.com :|
|:
https://entangle-photo.org -o-
https://www.instagram.com/dberrange :|