Re: Allow custom metadata in domain configuration XML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 20, 2012 at 02:55:27PM -0700, Eric Blake wrote:
> On 01/20/2012 01:15 PM, Zeeshan Ali (Khattak) wrote:
> > From 6895c107970ea6daf3d0e7f8be9a1a4e97b2278b Mon Sep 17 00:00:00 2001
> > From: "Zeeshan Ali (Khattak)" <zeeshanak@xxxxxxxxx>
> > Date: Fri, 20 Jan 2012 21:50:35 +0200
> > Subject: [PATCH] Allow custom metadata in domain configuration XML
> > 
> > Applications can now insert custom nodes and hierarchies into domain
> > cofiguration XML. Although currently not enforced, application are
> > required to use their own namespaces on every custom node they insert.
> 
> Looks like an interesting idea, as it gives applications more structure
> than what they would get by overloading the free-form <description>.
> 
> > ---
> >  docs/formatdomain.html.in |   18 ++++++++++++++++++
> >  src/conf/domain_conf.c    |   21 +++++++++++++++++++++
> >  src/conf/domain_conf.h    |    3 +++
> 
> Hmm, you didn't update docs/schemas/domaincommon.rng.  But how do you
> write a schema that accepts a <metadata> element with arbitrary
> contents?  </me searches the web...>
> 
> http://www.oasis-open.org/committees/relax-ng/tutorial.html#IDAFLZR
> 
> <define name="anyElement">
>   <element>
>     <anyName/>
>     <zeroOrMore>
>       <choice>
>         <attribute>
>           <anyName/>
>         </attribute>
>         <text/>
>         <ref name="anyElement"/>
>       </choice>
>     </zeroOrMore>
>   </element>
> </define>
> 
> <define name='metadata'>
>   <element name='metadata'>
>     <choice>
>       <text/>
>       <zeroOrMore>
>         <ref name='anyElement'/>
>       </zeroOrMore>
>     </choice>
>   </element>
> </define>
> 
> > +    <dl>
> > +      <dt><code>metadata</code></dt>
> > +      <dd><code>metadata</code> node could be used by applications to
> > +      store custom metadata in the form of XML nodes/trees. Applications
> > +      must use custom namespaces on any XML nodes they insert here.
> > +      <span class="since">Since 0.9.9</span></dd>
> 
> 0.9.10.
> 
> > @@ -11833,6 +11841,19 @@ virDomainDefFormatInternal(virDomainDefPtr def,
> >              goto cleanup;
> >      }
> >  
> > +    /* Custom metadata comes at the end */
> > +    if (def->metadata) {
> > +        xmlBufferPtr xmlbuf;
> > +
> > +        xmlbuf = xmlBufferCreate();
> > +        if (xmlNodeDump(xmlbuf, def->metadata->doc, def->metadata, 2, 0) < 0) {
> 
> Is this the right level of indentation if buf itself already has
> indentation (such as when <domain> is nested inside <domainsnapshot>?
> You may need to use virBufferGetIndent() and use that to alter the
> fourth argument to xmlNodeDump accordingly.
> 
> Unless anyone else objects to this XML addition, I think it is probably
> okay; but I have a couple caveats:
> 
> 1. you need to add tests that prove we can parse/regenerate user XML
> (that is, qemuxml2xmltest.c needs a new test case, and I'd also like to
> see one of the snapshot xml tests covering this to ensure indentation
> was taken care of)
> 
> 2. we probably need an API to allow the user to change this XML on the
> fly for a running domain.  Which means you ought to investigate whether
> you can merge your arbitrary XML alongside Peter's patch series [1] to
> add <title> and alter <description>.  I think that adding a new flag
> VIR_DOMAIN_DESCRIPTION_METADATA for use in virDomainSetDescription would
> do the trick, rather than adding yet another API.
> [1]https://www.redhat.com/archives/libvir-list/2012-January/msg00709.html

I'm not really convinced we need an API for setting the title/description
either. Are we going to create APIs for setting every little attribute
of the XML ? IMHO that's the job for libvirt-gconfig.


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 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]