On Thu, May 21, 2009 at 11:05:15AM +0100, Daniel P. Berrange wrote:
On Thu, May 21, 2009 at 10:46:11AM +0200, Daniel Veillard wrote:
> On Thu, May 21, 2009 at 05:25:35PM +0900, Ryota Ozaki wrote:
> > Yes, I also checked that.
> >
> > BTW, is the schema file used by libvirtd or drivers? This is just interest.
>
> We don't use them in the libvirt code themselves (though it would
> be relatively trivial to ask libxml2 to validate instances with them),
> but some are used byt the test suite. I'm not sure the storage schemas
> are used though, but we try to keep them up to date when the XML
> input and output code is updated.
I think it could be nice to add a flag to the various DefineXML/CreateXML
methods VIR_DOMAIN_XML_VALIDATE, to tell the parser that the app wants
strict validation. We shouldn't turn on validation by default though,
because that makes back compatability harder for applications, because
they have to make sure never to use new XML attributes/elements with
old libvirt installs.
Unfortunately
virDomainDefineXML
virNetworkCreateXML
virNetworkDefineXML
don't have flags for validation, so the approach will be limited to
a subset.
One thing we could do is a generic
virValidateXML(const char *xmlDesc, unsigned int flags);
possibly with a conn parameter too for error reporting,
as long as we keep all top level nodes for each xml descriptions
different then, it's trivial to know what schemas to use for validation
(or we could build a generic schemas importing all the others).
That will be just a wrapper around xmlRelaxNGValidateDoc() and related
calls, with a compile time detection, in case libxml2 was built without
schemas validation.
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/