[libvirt] Generic processing of xml data

Eric Blake eblake at redhat.com
Wed Feb 1 17:13:54 UTC 2012


[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 at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120201/77d39675/attachment-0001.sig>


More information about the libvir-list mailing list