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(a)gnome.org>
> 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>
Yes, that looks fine.
> + <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:
FYI this XML design is something I suggested to the Boxes team, instead
of hijacking the user's <description> field, so obviously it gets
my vote.
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 :|