]> xenbits.xensource.com Git - libvirt.git/commitdiff
523639 Allows a <description> tag for domains
authorDaniel Veillard <veillard@redhat.com>
Wed, 30 Sep 2009 14:07:24 +0000 (16:07 +0200)
committerDaniel Veillard <veillard@redhat.com>
Wed, 30 Sep 2009 14:10:16 +0000 (16:10 +0200)
* docs/schemas/domain.rng: allow one <description> tag in the top level
  of the <domain> to store user information as text
* src/conf/domain_conf.c src/conf/domain_conf.h: extend the structure
  to store this text, grab it at parse time and save it back when
  present after <uuid>

docs/schemas/domain.rng
src/conf/domain_conf.c
src/conf/domain_conf.h

index 70e98a708dab53a846e88675b97f8f26ecd68099..b1987e11fa730d3a72b10f62648ad02efd03c9e3 100644 (file)
@@ -6,6 +6,16 @@
   </start>
 
   <include href='storageencryption.rng'/>
+
+  <!--
+    description element, maybe placed anywhere under the root
+    -->
+  <define name="description">
+    <element name="description">
+      <text/>
+    </element>
+  </define>
+
   <!--
       We handle only document defining a domain
     -->
@@ -14,6 +24,9 @@
       <ref name="hvs"/>
       <ref name="ids"/>
       <interleave>
+        <optional>
+          <ref name="description"/>
+        </optional>
         <ref name="os"/>
         <ref name="clock"/>
         <ref name="resources"/>
index 5e37d96a54e8f19c88d2853534055468558bc470..868e8652253ffa595e14492455cada924aec0e24 100644 (file)
@@ -506,6 +506,7 @@ void virDomainDefFree(virDomainDefPtr def)
     VIR_FREE(def->name);
     VIR_FREE(def->cpumask);
     VIR_FREE(def->emulator);
+    VIR_FREE(def->description);
 
     virSecurityLabelDefFree(def);
 
@@ -2534,6 +2535,9 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
         VIR_FREE(tmp);
     }
 
+    /* Extract documentation if present */
+    def->description = virXPathString(conn, "string(./description[1])", ctxt);
+
     /* Extract domain memory */
     if (virXPathULong(conn, "string(./memory[1])", ctxt, &def->maxmem) < 0) {
         virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
@@ -4197,6 +4201,10 @@ char *virDomainDefFormat(virConnectPtr conn,
     virUUIDFormat(uuid, uuidstr);
     virBufferVSprintf(&buf, "  <uuid>%s</uuid>\n", uuidstr);
 
+    if (def->description)
+        virBufferEscapeString(&buf, "  <description>%s</description>\n",
+                              def->description);
+
     virBufferVSprintf(&buf, "  <memory>%lu</memory>\n", def->maxmem);
     virBufferVSprintf(&buf, "  <currentMemory>%lu</currentMemory>\n",
                       def->memory);
index 7c918a7b03a6d47a593f51148484e5cbd6700938..4b3646ee8c122248bd5daec8f181a7b7c8e2272a 100644 (file)
@@ -533,6 +533,7 @@ struct _virDomainDef {
     int id;
     unsigned char uuid[VIR_UUID_BUFLEN];
     char *name;
+    char *description;
 
     unsigned long memory;
     unsigned long maxmem;