[Libvir] Availability of the Relax-NG schemas for libvirt XML instances

As hinted previously in the QEmu thread, I developped a Relax-NG schemas to check the XML instances used to define Domains in libvirt. It's in CVS in the docs directory and also available online at http://libvirt.org/libvirt.rng For those not familiar with Relax-NG there is a nice tutorial and docs at http://relaxng.org/ Libxml2 on which libvirt depends has support for Relax-NG so we could easilly add checking at domain creation time within the library, but I decided to not add this at the moment, at least the schemas need to get more testing itself. The simplest to validate existing XML instances is to use the command line tool of libxml2 named xmllint in the following way: paphio:~/libvirt/tests -> xmllint --noout --relaxng ../docs/libvirt.rng xml2sexprdata/xml2sexpr-disk-drv-blkback.xml xml2sexprdata/xml2sexpr-disk-drv-blkback.xml validates paphio:~/libvirt/tests -> The schemas try to validate content as much as possible, but it's not possible to validate really in a complete fashion, for example to validate an IP address I used the following type: <define name='addrIP'> <data type='string'> <param name="pattern">([0-2]?[0-9]?[0-9]\.){3}[0-2]?[0-9]?[0-9]</param> </data> </define> which will catch '192.618.0.254' as erroneous but not '192.168.0.264' . There is also a number of cases which are structure related but hard to express cleanly in a schemas for example the fact that we may have an emulator description in the device list but that it's should only be allowed in an hvm kind of configuration. Still despite the limitations I found 2 weirdness: - we allow both <os> and <bootloader> blocks to be present, but I think they are redundant, I remember that Xen will ignore the bootloader informations if the os description is there, shouldn't we ban having both in a domain description ? e.g. tests/sexpr2xmldata/sexpr2xml-curmem.xml in the tree I still allowed this in the schemas but this may be wrong. - I though an interface of type ethernet needed a source description, but the output tests/sexpr2xmldata/sexpr2xml-net-routed.xml seems to miss both the source and target of the interface though the device is present in tests/sexpr2xmldata/sexpr2xml-net-routed.sexpr as (dev 'eth3') this probably indicates our conversion from sexpr to xml is lossy there. currently tests/sexpr2xmldata/sexpr2xml-net-routed.xml is the only example from our regression tests which doesn't pass the schemas testing. In general the schemas is both stricter than libvirt itself (as libvirt will only pick the parts of the XML it recognizes and need) and still allows some invalid constructs, I guess it's nearly impossible to make it a one to one match but I hope this can still be useful both for client tools, regression testings, and as another source of documentation. I still need to update the libvirt documentation, the XML page had some omissions and document the availability of the schemas and find its place when doing a 'make install', Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Wed, Jan 10, 2007 at 05:39:45AM -0500, Daniel Veillard wrote:
As hinted previously in the QEmu thread, I developped a Relax-NG schemas to check the XML instances used to define Domains in libvirt. It's in CVS in the docs directory and also available online at http://libvirt.org/libvirt.rng
For those not familiar with Relax-NG there is a nice tutorial and docs at http://relaxng.org/
Still despite the limitations I found 2 weirdness:
- we allow both <os> and <bootloader> blocks to be present, but I think they are redundant, I remember that Xen will ignore the bootloader informations if the os description is there, shouldn't we ban having both in a domain description ? e.g. tests/sexpr2xmldata/sexpr2xml-curmem.xml in the tree I still allowed this in the schemas but this may be wrong.
There is one further complication with the <os> block - currently you have two sets of definitions - one showing the Xen paravirt style config of an explicit kernel, initrd & cmdline; the other showing HVM style of a boot device & a loader. Well QEMU fully-virt guests can actually work with either a boot device, or an explicit kernel & initrd. So I think we need to combine the two for QEMU / KVM guests at least.
- I though an interface of type ethernet needed a source description, but the output tests/sexpr2xmldata/sexpr2xml-net-routed.xml seems to miss both the source and target of the interface though the device is present in tests/sexpr2xmldata/sexpr2xml-net-routed.sexpr as (dev 'eth3') this probably indicates our conversion from sexpr to xml is lossy there.
Yeah, I might well have made a mistake in there. I'll check up on it. The rest of it all looks very good & accurate wrt what we intend to allow in the XML file. Regards, Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
participants (2)
-
Daniel P. Berrange
-
Daniel Veillard