On Mon, May 16, 2011 at 02:59:28PM -0600, Eric Blake wrote:
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.
Yeah that can't fly, even for an XML/Markup editor preserving this
kind of non-strucural information is nearly impossible, since we even
discard the tree in libvirt after parsing we really can't hope to do
anything like this.
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/