]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
* src/xml.c src/xend_internal.c TODO: added uuid to the XML
authorDaniel Veillard <veillard@redhat.com>
Thu, 27 Apr 2006 14:14:23 +0000 (14:14 +0000)
committerDaniel Veillard <veillard@redhat.com>
Thu, 27 Apr 2006 14:14:23 +0000 (14:14 +0000)
  serialization
Daniel

ChangeLog
TODO
src/xend_internal.c
src/xml.c

index 6353f98ee3b872105998413383efa8642340ae6b..8a11a6b7bc40e4d0125c52598a68934d82c0c7a7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Apr 27 14:17:04 EDT 2006 Daniel Veillard <veillard@redhat.com>
+
+       * src/xml.c src/xend_internal.c TODO: added uuid to the XML
+         serialization
+
 Wed Apr 26 08:32:38 CEST 2006 Daniel Veillard <veillard@redhat.com>
 
        * src/xml.c: applied patch from Jeremy Katz to not require a 
diff --git a/TODO b/TODO
index 0055bd36f91db4ee8efee87ab0bc472534078419..48a59724ac977933e437d9c23dbddc1034ec4aa3 100644 (file)
--- a/TODO
+++ b/TODO
@@ -7,7 +7,6 @@ TODO:
 - DTD/RNG/XSD schemas for the XML Domain descriptions
 - in python bindings raise an exception if a lookup or connection fails
   to return a non-None object
-- Add uuid to XML format
 - add error handling hooks at the python level
 - object unicity for domains at the Python level
 - UUID lookup in hash.c
@@ -50,3 +49,4 @@ Done:
 - API for the Node: extracting informations
 - docs for the principle in the error handling code
 - thread protection, reentrancy, refcounting, etc ...
+- Add uuid to XML format
index 3655246516ffa1eecc4aef56d523a2192af35baa..64cd72edda9004d20fa07ccdc44713937e60268b 100644 (file)
@@ -1347,6 +1347,21 @@ xend_parse_sexp_desc(struct sexpr *root)
         goto error;
     }
     virBufferVSprintf(&buf, "  <name>%s</name>\n", tmp);
+    tmp = sexpr_node(root, "domain/uuid");
+    if (tmp != NULL) {
+        char compact[33];
+       int i, j;
+       for (i = 0, j = 0;(i < 32) && (tmp[j] != 0);j++) {
+           if (((tmp[j] >= '0') && (tmp[j] <= '9')) ||
+               ((tmp[j] >= 'a') && (tmp[j] <= 'f')))
+               compact[i++] = tmp[j];
+           else if ((tmp[j] >= 'A') && (tmp[j] <= 'F'))
+               compact[i++] = tmp[j] + 'a' - 'A';
+       }
+       compact[i] = 0;
+       if (i > 0)
+           virBufferVSprintf(&buf, "  <uuid>%s</uuid>\n", compact);
+    }
     tmp = sexpr_node(root, "domain/bootloader");
     if (tmp != NULL)
        virBufferVSprintf(&buf, "  <bootloader>%s</bootloader>\n", tmp);
index 58646b3d85fa276cde1d9af56a7a58e8763faed8..ba417aa7d0a4c5fb8260e7b682236fb08e5e73f0 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -462,6 +462,7 @@ char *
 virDomainGetXMLDesc(virDomainPtr domain, int flags)
 {
     char *ret = NULL;
+    unsigned char uuid[16];
     virBuffer buf;
     virDomainInfo info;
 
@@ -483,6 +484,14 @@ virDomainGetXMLDesc(virDomainPtr domain, int flags)
                       virDomainGetID(domain));
     virBufferVSprintf(&buf, "  <name>%s</name>\n",
                       virDomainGetName(domain));
+    if (virDomainGetUUID(domain, &uuid[0]) == 0) {
+    virBufferVSprintf(&buf,
+"  <uuid>%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x</uuid>\n",
+                      uuid[0], uuid[1], uuid[2], uuid[3],
+                      uuid[4], uuid[5], uuid[6], uuid[7],
+                      uuid[8], uuid[9], uuid[10], uuid[11],
+                      uuid[12], uuid[13], uuid[14], uuid[15]);
+    }
     virDomainGetXMLBoot(domain, &buf);
     virBufferVSprintf(&buf, "  <memory>%lu</memory>\n", info.maxMem);
     virBufferVSprintf(&buf, "  <vcpu>%d</vcpu>\n", (int) info.nrVirtCpu);