On Wed, Sep 18, 2013 at 09:41:40AM -0600, Eric Blake wrote:
On 09/18/2013 09:38 AM, Eric Blake wrote:
> On 09/18/2013 09:32 AM, Cole Robinson wrote:
>>
>> Seems overkill IMO. Do we really need to add an API to facilitate the crappy
>> interface that is virsh detach-device? Will any other application ever want to
>> use this API?
>
> Yes, I can envision other use cases. In fact, virt-manager is one of them:
>
> Oftentimes, we add features to XML, but you don't have an easy way to
> probe if the feature is supported. Rather than complicate the (already
> large) capabilities xml to call out yet more features, it is rather
> simple to write up XML that tries to use the feature, then run it
> through the normalizing API, then look at the result. If the feature is
> still present in the output, then libvirt understands the feature (and
> you can safely use it); if the feature got stripped as unrecognized,
> then you can issue a much nicer error message to the user stating that
> the libvirtd on the other end of the connection can't honor the user's
> request.
In fact, I'd love to have 'virsh edit' and friends take advantage of
normalization. Right now, if you run 'virsh edit' and type in something
that libvirt doesn't recognize, it gets silently discarded; but if we
add normalization into the mix and do a strcmp of the xml before the
user's edits and after the normalization of the edits, we can more
easily warn the user that not all their edits can be honored, and give
them a chance to try again.
That's a job for RNG schema validation IMHO. Round-tripping XML and
doing a strcmp is really poor-mans schema validation.
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|