[libvirt] [PATCH] Allows for a <description> tag for domains
Daniel Veillard
veillard at redhat.com
Thu Oct 1 13:45:58 UTC 2009
On Wed, Sep 30, 2009 at 04:09:38PM +0100, Daniel P. Berrange wrote:
> On Wed, Sep 30, 2009 at 04:37:46PM +0200, Daniel Veillard wrote:
> > Hum, I'm not sure I follow, you would like to create a metadata
> > container at the top level and put <description> in it ? The problem
> > is that I don't see what else we could move there.
>
> Yes, like
>
> <domain>
> <name>guest</name>
> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
> <metadata>
> <description>blah</description>
> </metadata>
> ....
>
> I didn't mean we should move any other elements - this is just to serve
> as a container for future expansion
>
> Other example bits of information we could define metadata elements for
> might be the operating system name, the person who created it, the
> date on which it was created, the name of the appliance it was based
> on, etc, etc.
Okay, that makes sense and it's better to have the placeholder now
than mess with different formats later. The trivial patch enclosed does
this,
thanks,
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
-------------- next part --------------
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index b1987e1..c972059 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -8,11 +8,19 @@
<include href='storageencryption.rng'/>
<!--
- description element, maybe placed anywhere under the root
+ metadata element, maybe placed anywhere under the root
+ after name and uuid
+ Currently hold only a single description element but may
+ be extended in the future for more user related informations
+ not influencing the domain runtime definition
-->
- <define name="description">
- <element name="description">
- <text/>
+ <define name="metadata">
+ <element name="metadata">
+ <optional>
+ <element name="description">
+ <text/>
+ </element>
+ </optional>
</element>
</define>
@@ -25,7 +33,7 @@
<ref name="ids"/>
<interleave>
<optional>
- <ref name="description"/>
+ <ref name="metadata"/>
</optional>
<ref name="os"/>
<ref name="clock"/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 87e05c2..e12f6f8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2537,7 +2537,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
}
/* Extract documentation if present */
- def->description = virXPathString(conn, "string(./description[1])", ctxt);
+ def->description = virXPathString(conn,
+ "string(./metadata/description[1])", ctxt);
/* Extract domain memory */
if (virXPathULong(conn, "string(./memory[1])", ctxt, &def->maxmem) < 0) {
@@ -4202,9 +4203,12 @@ char *virDomainDefFormat(virConnectPtr conn,
virUUIDFormat(uuid, uuidstr);
virBufferVSprintf(&buf, " <uuid>%s</uuid>\n", uuidstr);
- if (def->description)
- virBufferEscapeString(&buf, " <description>%s</description>\n",
+ if (def->description) {
+ virBufferAddLit(&buf, " <metadata>\n");
+ virBufferEscapeString(&buf, " <description>%s</description>\n",
def->description);
+ virBufferAddLit(&buf, " </metadata>\n");
+ }
virBufferVSprintf(&buf, " <memory>%lu</memory>\n", def->maxmem);
virBufferVSprintf(&buf, " <currentMemory>%lu</currentMemory>\n",
More information about the libvir-list
mailing list