Availability of the Relax-NG schemas for libvirt XML instances

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  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@xxxxxxxxxx  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]