[libvirt] Generic processing of xml data

There are some changes made to the conf code to handle some new tags like <title> or to add some "metadata" to a domain description in the last days. I'm wondering if there is a more generic (read better) way to handle those extra data in xml config elements. I think it would be far more reasonable to use xml namespaces to enable libvirt to differentiate between config options which it has to process and data which are unknown to libvirt and thus are only stored without any further processing. This distinction could then by easily used for expansions like the <title>-tag, to store the x- and y-position of a guest in a graphical visualization of virtual networks, to add some names of administrators which are responsible for the guests, to add some hints to interfaces concerning quality of service, etc... I don't know how complex such in implementation would be but I think it would be worth the effort. Hendrik Schwartke

On 02/01/2012 07:01 AM, Hendrik Schwartke wrote:
There are some changes made to the conf code to handle some new tags like <title> or to add some "metadata" to a domain description in the last days. I'm wondering if there is a more generic (read better) way to handle those extra data in xml config elements. I think it would be far more reasonable to use xml namespaces to enable libvirt to differentiate between config options which it has to process and data which are unknown to libvirt and thus are only stored without any further processing.
That's precisely what we have already started implementing. We added the <metadata> element that takes one sub-element per namespace for use by however the application sees fit: https://www.redhat.com/archives/libvir-list/2012-January/msg00943.html and have a pending API to allow runtime manipulation of that metadata: https://www.redhat.com/archives/libvir-list/2012-February/msg00032.html
This distinction could then by easily used for expansions like the <title>-tag, to store the x- and y-position of a guest in a graphical visualization of virtual networks, to add some names of administrators which are responsible for the guests, to add some hints to interfaces concerning quality of service, etc...
I don't know how complex such in implementation would be but I think it would be worth the effort.
Right now, the only missing part is wiring up the proposed API from Peter's series to actually modify the XML from Zeeshan's patch, if you'd like to help with that. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Ok, seems that i missed something here. I tried to add some additional data to a domain description on monday but haven't a closer look at it. I missed that I have to use the <metadata>-tag. So adding <domain type='kvm' id='25' xmlns:t="urn:foo" t:x="55">...</domain> doesn't work, or does it? However, this patch will make my life much easier. Great Work! On 01.02.2012 16:41, Eric Blake wrote:
There are some changes made to the conf code to handle some new tags like<title> or to add some "metadata" to a domain description in the last days. I'm wondering if there is a more generic (read better) way to handle those extra data in xml config elements. I think it would be far more reasonable to use xml namespaces to enable libvirt to differentiate between config options which it has to process and data which are unknown to libvirt and thus are only stored without any further processing. That's precisely what we have already started implementing. We added
On 02/01/2012 07:01 AM, Hendrik Schwartke wrote: the<metadata> element that takes one sub-element per namespace for use by however the application sees fit: https://www.redhat.com/archives/libvir-list/2012-January/msg00943.html and have a pending API to allow runtime manipulation of that metadata: https://www.redhat.com/archives/libvir-list/2012-February/msg00032.html
This distinction could then by easily used for expansions like the <title>-tag, to store the x- and y-position of a guest in a graphical visualization of virtual networks, to add some names of administrators which are responsible for the guests, to add some hints to interfaces concerning quality of service, etc...
I don't know how complex such in implementation would be but I think it would be worth the effort. Right now, the only missing part is wiring up the proposed API from Peter's series to actually modify the XML from Zeeshan's patch, if you'd like to help with that.

[please don't top-post on technical lists] On 02/01/2012 09:22 AM, Hendrik Schwartke wrote:
Ok, seems that i missed something here. I tried to add some additional data to a domain description on monday but haven't a closer look at it. I missed that I have to use the <metadata>-tag. So adding <domain type='kvm' id='25' xmlns:t="urn:foo" t:x="55">...</domain> doesn't work, or does it?
Libvirt won't preserve any unknown namespace content _except_ under the <metadata> element. So you want to do: <domain type='kvm'> <metadata> <t:coords xmlns:t="urn:foo" t:x="55"/> </metadata> ... </domain> or something similar when providing the entire domain XML, or for hot-editing an already-running domain, you would use: virDomainSetMetadata(domain, VIR_DOMAIN_METADATA_ELEMENT, "<t:coords xmlns:t=\"urn:foo\" t:x=\"55\"/>", "t", "urn:foo", VIR_DOMAIN_AFFECT_LIVE); to set things, and: virDomainGetMetadata(domain, VIR_DOMAIN_METADATA_ELEMENT, "urn:foo", VIR_DOMAIN_AFFECT_LIVE); to get back your string "<t:coords xmlns:t=\"urn:foo\" t:x=\"55\"/>".
However, this patch will make my life much easier.
Glad to hear it. Now's the time to give feedback on how easy the new stuff is to understand and use, before we freeze the API in stone in 0.9.10 and miss out on any chances for minor improvements. Please do test the RC1 when it is announced. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Hendrik Schwartke