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

Re: [libvirt] Allow custom metadata in domain configuration XML

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


<define name="anyElement">
        <ref name="anyElement"/>

<define name='metadata'>
  <element name='metadata'>
        <ref name='anyElement'/>

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


> @@ -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.

Looking forward to v2.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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