Hi, Apologies for not using git-send-mail but for some reason its not working for me at the moment with gmail's SMTP. -- Regards, Zeeshan Ali (Khattak) FSF member#5124
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. --- docs/formatdomain.html.in | 18 ++++++++++++++++++ src/conf/domain_conf.c | 21 +++++++++++++++++++++ src/conf/domain_conf.h | 3 +++ 3 files changed, 42 insertions(+), 0 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index de9b480..b8a7e71 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3548,6 +3548,24 @@ qemu-kvm -net nic,model=? /dev/null sub-element <code>label</code> are supported. </p> + <h3><a name="customMetadata">Custom metadata</a></h3> + +<pre> + ... + <metadata> + <app1:foo xmlns:app1="http://app1.org/app1/">..</app1:foo> + <app2:bar xmlns:app2="http://app1.org/app2/">..</app2:bar> + </metadata> + ...</pre> + + <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> + </dl> + <h2><a name="examples">Example configs</a></h2> <p> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f97014e..a3fc7ee 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1500,6 +1500,9 @@ void virDomainDefFree(virDomainDefPtr def) if (def->namespaceData && def->ns.free) (def->ns.free)(def->namespaceData); + if (def->metadata) + xmlFreeNode(def->metadata); + VIR_FREE(def); } @@ -8072,6 +8075,11 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, def->os.smbios_mode = VIR_DOMAIN_SMBIOS_NONE; /* not present */ } + /* Extract custom metadata */ + if ((node = virXPathNode("./metadata[1]", ctxt)) != NULL) { + def->metadata = xmlCopyNode (node, 1); + } + /* we have to make a copy of all of the callback pointers here since * we won't have the virCaps structure available during free */ @@ -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) { + xmlBufferFree(xmlbuf); + goto cleanup; + } + virBufferAdd(buf, (char *) xmlBufferContent(xmlbuf), xmlBufferLength(xmlbuf)); + xmlBufferFree(xmlbuf); + } + virBufferAddLit(buf, "</domain>\n"); if (virBufferError(buf)) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b121f9c..601a58b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1524,6 +1524,9 @@ struct _virDomainDef { void *namespaceData; virDomainXMLNamespace ns; + + /* Application-specific custom metadata */ + xmlNodePtr metadata; }; enum virDomainTaintFlags { -- 1.7.7.5
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list