On 05/16/2011 01:12 AM, Daniel Veillard wrote:
On Fri, May 13, 2011 at 02:42:29PM +0100, Daniel P. Berrange wrote:
> There are two common problems with virsh edit & friends
>
> - Invalid XML syntax, causes error report & lost changes
> - User add unsupported/unknown XML attributes/elements which
> are silently discarded by libvirt
>
> This patch only fixes the first problem. It would be nice to
> fix the second two, by running the XML through the RNG schema
> validator.
>
> Rather than do this in virsh though, I'd add some flags to
> the virXXXXDefine/Create APIs, eg
>
> VIR_DOMAIN_XML_VALIDATE
>
> virsh can set this flag by default, and if the XML fails
> validation, it could prompt the user, asking if they want
> to proceed anyway (in which case recall the same API but
> without the validate flag set), or re-edit the XML
Hum, yes I agree with the option of validating on define of APIs
the only problem is that we tend to have holes in the RNG, but
since that would be optional I think that's okay, this would
hopefully help finding the mismatches between the RNG and the C parsing
code.
There's also the idea of doing a round trip parse -> dumpxml -> compare;
but that also has problems where dumpxml sometimes rearranges elements
or populates backwards-compatibility additions that were not present in
the original.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org