
On Fri, Dec 11, 2009 at 08:09:33AM +0100, Daniel Veillard wrote:
On Thu, Dec 10, 2009 at 06:07:13PM +0000, Daniel P. Berrange wrote:
There should be an option to validate the XML input, either by providing a VIR_DOMAIN_XML_VALIDATE flag with the APIs which accept XML as input, or by having virsh edit doing validation after the editor exits.
I think I suggested a couple of time to have the input XML data be validated at the API level, but we don't want to do this systematically, this would create IMHO more problems it can solve. Using a flag and/or activating it when libvirt conf is in debug mode would both make sense.
This would also allow virsh to re-launch the editor upon error and let you correct the mistake instead of forcing you to start again from scratch.
The schemas validation won't be perfect in any way, for example trying to limit the list of allowed ethernet adapter based on the hypervisor type is nearly impossible even with Relax-NG since we differentiate based on an attribute in the top level element (this would force to basically write parallel schemas and become completely unmaintainable). Relax-NG validation also will provide out of context error messages, while the conf parser can give way better diagnostics.
I think it is a mistake that our current schemas try to validate the content of attributes such as ethernet adapter name. Increasingly we in a situation where the allowed values are dynamically determined on the fly. The schema would be more useful if it simply validated that it was a string a-Z,0-9, and didn't try to check explicit enumeration of values there. ie just validate basic syntax, and not semantics. The original poster's problem of 'pc' vs 'pc-0.11' is a good example of validating the individual values is bad - 'pc-0.11' is dynamically pulled from the QEMU binary so there's no hope of the schema ever being aware of that. Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|