[libvirt] PATCH: 11/14: Change XM driver in-memory objects

Daniel P. Berrange berrange at redhat.com
Tue Jul 8 16:40:17 UTC 2008


This is a refactoring of the XM driver. Previously we would store
the virConfPtr objects as our master 'in memory' representation
of inactive domains. This switch it over to using virDomainDefPtr
objects instead. The code for reading/writing the config files is
unchanged at this time.

Again the XML config file has changed because of re-ordering of
elements by the generic XML formatter

 src/xm_internal.c                                      | 1038 ++++-------------
 src/xm_internal.h                                      |   13 
 tests/Makefile.am                                      |    2 
 tests/xmconfigdata/test-escape-paths.cfg               |    2 
 tests/xmconfigdata/test-escape-paths.xml               |   24 
 tests/xmconfigdata/test-fullvirt-localtime.cfg         |    2 
 tests/xmconfigdata/test-fullvirt-localtime.xml         |   24 
 tests/xmconfigdata/test-fullvirt-new-cdrom.cfg         |    2 
 tests/xmconfigdata/test-fullvirt-new-cdrom.xml         |   24 
 tests/xmconfigdata/test-fullvirt-old-cdrom.cfg         |    2 
 tests/xmconfigdata/test-fullvirt-old-cdrom.xml         |   24 
 tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg      |    2 
 tests/xmconfigdata/test-fullvirt-parallel-tcp.xml      |   26 
 tests/xmconfigdata/test-fullvirt-serial-file.cfg       |    2 
 tests/xmconfigdata/test-fullvirt-serial-file.xml       |   26 
 tests/xmconfigdata/test-fullvirt-serial-null.cfg       |    2 
 tests/xmconfigdata/test-fullvirt-serial-null.xml       |   26 
 tests/xmconfigdata/test-fullvirt-serial-pipe.cfg       |    2 
 tests/xmconfigdata/test-fullvirt-serial-pipe.xml       |   26 
 tests/xmconfigdata/test-fullvirt-serial-pty.cfg        |    2 
 tests/xmconfigdata/test-fullvirt-serial-pty.xml        |   26 
 tests/xmconfigdata/test-fullvirt-serial-stdio.cfg      |    2 
 tests/xmconfigdata/test-fullvirt-serial-stdio.xml      |   26 
 tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg |    2 
 tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml |   26 
 tests/xmconfigdata/test-fullvirt-serial-tcp.cfg        |    2 
 tests/xmconfigdata/test-fullvirt-serial-tcp.xml        |   26 
 tests/xmconfigdata/test-fullvirt-serial-udp.cfg        |    2 
 tests/xmconfigdata/test-fullvirt-serial-udp.xml        |   30 
 tests/xmconfigdata/test-fullvirt-serial-unix.cfg       |    2 
 tests/xmconfigdata/test-fullvirt-serial-unix.xml       |   26 
 tests/xmconfigdata/test-fullvirt-sound.cfg             |    2 
 tests/xmconfigdata/test-fullvirt-sound.xml             |   24 
 tests/xmconfigdata/test-fullvirt-usbmouse.cfg          |    2 
 tests/xmconfigdata/test-fullvirt-usbmouse.xml          |   24 
 tests/xmconfigdata/test-fullvirt-usbtablet-no-bus.xml  |    2 
 tests/xmconfigdata/test-fullvirt-usbtablet.cfg         |    2 
 tests/xmconfigdata/test-fullvirt-usbtablet.xml         |   24 
 tests/xmconfigdata/test-fullvirt-utc.cfg               |    2 
 tests/xmconfigdata/test-fullvirt-utc.xml               |   24 
 tests/xmconfigdata/test-paravirt-net-e1000.cfg         |    2 
 tests/xmconfigdata/test-paravirt-net-e1000.xml         |   19 
 tests/xmconfigdata/test-paravirt-new-pvfb.cfg          |    2 
 tests/xmconfigdata/test-paravirt-new-pvfb.xml          |   19 
 tests/xmconfigdata/test-paravirt-old-pvfb.cfg          |    2 
 tests/xmconfigdata/test-paravirt-old-pvfb.xml          |   19 
 tests/xmconfigtest.c                                   |   29 
 47 files changed, 581 insertions(+), 1058 deletions(-)


Daniel

diff -r a6688e03b4fc src/xm_internal.c
--- a/src/xm_internal.c	Mon Jul 07 07:11:30 2008 -0400
+++ b/src/xm_internal.c	Mon Jul 07 10:12:49 2008 -0400
@@ -47,7 +47,6 @@
 #include "xen_unified.h"
 #include "xm_internal.h"
 #include "xend_internal.h"
-#include "conf.h"
 #include "hash.h"
 #include "internal.h"
 #include "xml.h"
@@ -63,7 +62,7 @@ typedef struct xenXMConfCache {
 typedef struct xenXMConfCache {
     time_t refreshedAt;
     char filename[PATH_MAX];
-    virConfPtr conf;
+    virDomainDefPtr def;
 } xenXMConfCache;
 
 static char configDir[PATH_MAX];
@@ -75,10 +74,6 @@ static time_t lastRefresh = 0;
 static time_t lastRefresh = 0;
 
 char * xenXMAutoAssignMac(void);
-static int xenXMAttachDisk(virDomainPtr domain, xmlXPathContextPtr ctxt, int hvm,
-                            xmlNodePtr node, xenXMConfCachePtr entry);
-static int xenXMAttachInterface(virDomainPtr domain, xmlXPathContextPtr ctxt, int hvm,
-                                xmlNodePtr node, xenXMConfCachePtr entry);
 static int xenXMDomainAttachDevice(virDomainPtr domain, const char *xml);
 static int xenXMDomainDetachDevice(virDomainPtr domain, const char *xml);
 
@@ -233,59 +228,10 @@ static int xenXMConfigGetUUID(virConfPtr
 }
 
 
-/* Ensure that a config object has a valid UUID in it,
-   if it doesn't then (re-)generate one */
-static int xenXMConfigEnsureIdentity(virConfPtr conf, const char *filename) {
-    unsigned char uuid[VIR_UUID_BUFLEN];
-    const char *name;
-
-    /* Had better have a name...*/
-    if (xenXMConfigGetString(conf, "name", &name) < 0) {
-        virConfValuePtr value;
-        if (VIR_ALLOC(value) < 0)
-            return (-1);
-
-        /* Set name based on filename */
-        value->type = VIR_CONF_STRING;
-        value->str = strdup(filename);
-        if (!value->str) {
-            VIR_FREE(value);
-            return (-1);
-        }
-        if (virConfSetValue(conf, "name", value) < 0)
-            return (-1);
-    }
-
-    /* If there is no uuid...*/
-    if (xenXMConfigGetUUID(conf, "uuid", uuid) < 0) {
-        virConfValuePtr value;
-        char uuidstr[VIR_UUID_STRING_BUFLEN];
-
-        if (VIR_ALLOC(value) < 0)
-            return (-1);
-
-        /* ... then generate one */
-        virUUIDGenerate(uuid);
-        virUUIDFormat(uuid, uuidstr);
-
-        value->type = VIR_CONF_STRING;
-        value->str = strdup(uuidstr);
-        if (!value->str) {
-            VIR_FREE(value);
-            return (-1);
-        }
-
-        /* And stuff the UUID back into the config file */
-        if (virConfSetValue(conf, "uuid", value) < 0)
-            return (-1);
-    }
-    return (0);
-}
-
 /* Release memory associated with a cached config object */
 static void xenXMConfigFree(void *payload, const char *key ATTRIBUTE_UNUSED) {
     xenXMConfCachePtr entry = (xenXMConfCachePtr)payload;
-    virConfFree(entry->conf);
+    virDomainDefFree(entry->def);
     VIR_FREE(entry);
 }
 
@@ -295,20 +241,47 @@ static int xenXMConfigReaper(const void 
     time_t now = *(const time_t *)data;
     xenXMConfCachePtr entry = (xenXMConfCachePtr)payload;
 
+    /* We're going to purge this config file, so check if it
+       is currently mapped as owner of a named domain. */
     if (entry->refreshedAt != now) {
-        const char *olddomname;
-        /* We're going to pure this config file, so check if it
-           is currently mapped as owner of a named domain. */
-        if (xenXMConfigGetString(entry->conf, "name", &olddomname) != -1) {
-            char *nameowner = (char *)virHashLookup(nameConfigMap, olddomname);
-            if (nameowner && STREQ(nameowner, key)) {
-                virHashRemoveEntry(nameConfigMap, olddomname, NULL);
-            }
+        const char *olddomname = entry->def->name;
+        char *nameowner = (char *)virHashLookup(nameConfigMap, olddomname);
+        if (nameowner && STREQ(nameowner, key)) {
+            virHashRemoveEntry(nameConfigMap, olddomname, NULL);
         }
         return (1);
     }
     return (0);
 }
+
+
+static virDomainDefPtr
+xenXMConfigReadFile(virConnectPtr conn, const char *filename) {
+    virConfPtr conf;
+    virDomainDefPtr def;
+
+    if (!(conf = virConfReadFile(filename)))
+        return NULL;
+
+    def = xenXMDomainConfigParse(conn, conf);
+    virConfFree(conf);
+
+    return def;
+}
+
+static int
+xenXMConfigSaveFile(virConnectPtr conn, const char *filename, virDomainDefPtr def) {
+    virConfPtr conf;
+    int ret;
+
+    if (!(conf = xenXMDomainConfigFormat(conn, def)))
+        return -1;
+
+    ret = virConfWriteFile(filename, conf);
+    virConfFree(conf);
+    return ret;
+}
+
 
 /* This method is called by various methods to scan /etc/xen
    (or whatever directory was set by  LIBVIRT_XM_CONFIG_DIR
@@ -343,7 +316,6 @@ static int xenXMConfigCacheRefresh (virC
         struct stat st;
         int newborn = 0;
         char path[PATH_MAX];
-        const char *domname = NULL;
 
         /*
          * Skip a bunch of crufty files that clearly aren't config files
@@ -387,7 +359,7 @@ static int xenXMConfigCacheRefresh (virC
         /* If we already have a matching entry and it is not
            modified, then carry on to next one*/
         if ((entry = virHashLookup(configCache, path))) {
-            const char *olddomname = NULL;
+            char *nameowner;
 
             if (entry->refreshedAt >= st.st_mtime) {
                 entry->refreshedAt = now;
@@ -396,16 +368,14 @@ static int xenXMConfigCacheRefresh (virC
 
             /* If we currently own the name, then release it and
                re-acquire it later - just in case it was renamed */
-            if (xenXMConfigGetString(entry->conf, "name", &olddomname) != -1) {
-                char *nameowner = (char *)virHashLookup(nameConfigMap, olddomname);
-                if (nameowner && STREQ(nameowner, path)) {
-                    virHashRemoveEntry(nameConfigMap, olddomname, NULL);
-                }
+            nameowner = (char *)virHashLookup(nameConfigMap, entry->def->name);
+            if (nameowner && STREQ(nameowner, path)) {
+                virHashRemoveEntry(nameConfigMap, entry->def->name, NULL);
             }
 
             /* Clear existing config entry which needs refresh */
-            virConfFree(entry->conf);
-            entry->conf = NULL;
+            virDomainDefFree(entry->def);
+            entry->def = NULL;
         } else { /* Completely new entry */
             newborn = 1;
             if (VIR_ALLOC(entry) < 0) {
@@ -416,31 +386,18 @@ static int xenXMConfigCacheRefresh (virC
         }
         entry->refreshedAt = now;
 
-        if (!(entry->conf = virConfReadFile(entry->filename)) ||
-            xenXMConfigEnsureIdentity(entry->conf, ent->d_name) < 0) {
-            if (!newborn) {
+        if (!(entry->def = xenXMConfigReadFile(conn, entry->filename))) {
+            if (!newborn)
                 virHashRemoveEntry(configCache, path, NULL);
-            }
             VIR_FREE(entry);
             continue;
-        }
-
-        /* Lookup what domain name the conf contains */
-        if (xenXMConfigGetString(entry->conf, "name", &domname) < 0) {
-            if (!newborn) {
-                virHashRemoveEntry(configCache, path, NULL);
-            }
-            VIR_FREE(entry);
-            xenXMError (conn, VIR_ERR_INTERNAL_ERROR,
-                        _("xenXMConfigCacheRefresh: name"));
-            goto cleanup;
         }
 
         /* If its a completely new entry, it must be stuck into
            the cache (refresh'd entries are already registered) */
         if (newborn) {
             if (virHashAddEntry(configCache, entry->filename, entry) < 0) {
-                virConfFree(entry->conf);
+                virDomainDefFree(entry->def);
                 VIR_FREE(entry);
                 xenXMError (conn, VIR_ERR_INTERNAL_ERROR,
                             _("xenXMConfigCacheRefresh: virHashAddEntry"));
@@ -451,10 +408,10 @@ static int xenXMConfigCacheRefresh (virC
         /* See if we need to map this config file in as the primary owner
          * of the domain in question
          */
-        if (!virHashLookup(nameConfigMap, domname)) {
-            if (virHashAddEntry(nameConfigMap, domname, entry->filename) < 0) {
+        if (!virHashLookup(nameConfigMap, entry->def->name)) {
+            if (virHashAddEntry(nameConfigMap, entry->def->name, entry->filename) < 0) {
                 virHashRemoveEntry(configCache, ent->d_name, NULL);
-                virConfFree(entry->conf);
+                virDomainDefFree(entry->def);
                 VIR_FREE(entry);
             }
         }
@@ -529,8 +486,6 @@ int xenXMDomainGetInfo(virDomainPtr doma
 int xenXMDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) {
     const char *filename;
     xenXMConfCachePtr entry;
-    long vcpus;
-    long mem;
     if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
         xenXMError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
                    __FUNCTION__);
@@ -547,22 +502,9 @@ int xenXMDomainGetInfo(virDomainPtr doma
         return (-1);
 
     memset(info, 0, sizeof(virDomainInfo));
-    if (xenXMConfigGetInt(entry->conf, "memory", &mem) < 0 ||
-        mem < 0)
-        info->memory = MIN_XEN_GUEST_SIZE * 1024 * 2;
-    else
-        info->memory = (unsigned long)mem * 1024;
-    if (xenXMConfigGetInt(entry->conf, "maxmem", &mem) < 0 ||
-        mem < 0)
-        info->maxMem = info->memory;
-    else
-        info->maxMem = (unsigned long)mem * 1024;
-
-    if (xenXMConfigGetInt(entry->conf, "vcpus", &vcpus) < 0 ||
-        vcpus < 0)
-        info->nrVirtCpu = 1;
-    else
-        info->nrVirtCpu = (unsigned short)vcpus;
+    info->maxMem = entry->def->maxmem;
+    info->memory = entry->def->memory;
+    info->nrVirtCpu = entry->def->vcpus;
     info->state = VIR_DOMAIN_SHUTOFF;
     info->cpuTime = 0;
 
@@ -575,7 +517,8 @@ int xenXMDomainGetInfo(virDomainPtr doma
  * Turn a config record into a lump of XML describing the
  * domain, suitable for later feeding for virDomainCreateLinux
  */
-char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
+virDomainDefPtr
+xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     const char *name;
     unsigned char uuid[VIR_UUID_BUFLEN];
@@ -592,6 +535,8 @@ char *xenXMDomainFormatXML(virConnectPtr
     const char *vncpasswd = NULL;
     const char *keymap = NULL;
     xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
+    virDomainDefPtr def = NULL;
+    char *xml;
 
     if (xenXMConfigGetString(conf, "name", &name) < 0)
         return (NULL);
@@ -1080,7 +1025,15 @@ char *xenXMDomainFormatXML(virConnectPtr
         goto error;
     }
 
-    return virBufferContentAndReset(&buf);
+    xml = virBufferContentAndReset(&buf);
+
+    if (!(def = virDomainDefParseString(conn, priv->caps, xml))) {
+        VIR_FREE(xml);
+        return NULL;
+    }
+
+    VIR_FREE(xml);
+    return def;
 
   error:
     str = virBufferContentAndReset(&buf);
@@ -1093,7 +1046,7 @@ char *xenXMDomainFormatXML(virConnectPtr
  * Turn a config record into a lump of XML describing the
  * domain, suitable for later feeding for virDomainCreateLinux
  */
-char *xenXMDomainDumpXML(virDomainPtr domain, int flags ATTRIBUTE_UNUSED) {
+char *xenXMDomainDumpXML(virDomainPtr domain, int flags) {
     const char *filename;
     xenXMConfCachePtr entry;
 
@@ -1111,7 +1064,7 @@ char *xenXMDomainDumpXML(virDomainPtr do
     if (!(entry = virHashLookup(configCache, filename)))
         return (NULL);
 
-    return xenXMDomainFormatXML(domain->conn, entry->conf);
+    return virDomainDefFormat(domain->conn, entry->def, flags);
 }
 
 
@@ -1121,7 +1074,6 @@ int xenXMDomainSetMemory(virDomainPtr do
 int xenXMDomainSetMemory(virDomainPtr domain, unsigned long memory) {
     const char *filename;
     xenXMConfCachePtr entry;
-    virConfValuePtr value;
 
     if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
         xenXMError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
@@ -1139,19 +1091,14 @@ int xenXMDomainSetMemory(virDomainPtr do
     if (!(entry = virHashLookup(configCache, filename)))
         return (-1);
 
-    if (VIR_ALLOC(value) < 0)
-        return (-1);
-
-    value->type = VIR_CONF_LONG;
-    value->l = (memory/1024);
-
-    if (virConfSetValue(entry->conf, "memory", value) < 0)
-        return (-1);
+    entry->def->memory = memory;
+    if (entry->def->memory > entry->def->maxmem)
+        entry->def->memory = entry->def->maxmem;
 
     /* If this fails, should we try to undo our changes to the
      * in-memory representation of the config file. I say not!
      */
-    if (virConfWriteFile(entry->filename, entry->conf) < 0)
+    if (xenXMConfigSaveFile(domain->conn, entry->filename, entry->def) < 0)
         return (-1);
 
     return (0);
@@ -1163,7 +1110,6 @@ int xenXMDomainSetMaxMemory(virDomainPtr
 int xenXMDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) {
     const char *filename;
     xenXMConfCachePtr entry;
-    virConfValuePtr value;
 
     if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
         xenXMError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
@@ -1181,19 +1127,14 @@ int xenXMDomainSetMaxMemory(virDomainPtr
     if (!(entry = virHashLookup(configCache, filename)))
         return (-1);
 
-    if (VIR_ALLOC(value) < 0)
-        return (-1);
-
-    value->type = VIR_CONF_LONG;
-    value->l = (memory/1024);
-
-    if (virConfSetValue(entry->conf, "maxmem", value) < 0)
-        return (-1);
+    entry->def->maxmem = memory;
+    if (entry->def->memory > entry->def->maxmem)
+        entry->def->memory = entry->def->maxmem;
 
     /* If this fails, should we try to undo our changes to the
      * in-memory representation of the config file. I say not!
      */
-    if (virConfWriteFile(entry->filename, entry->conf) < 0)
+    if (xenXMConfigSaveFile(domain->conn, entry->filename, entry->def) < 0)
         return (-1);
 
     return (0);
@@ -1205,7 +1146,6 @@ unsigned long xenXMDomainGetMaxMemory(vi
 unsigned long xenXMDomainGetMaxMemory(virDomainPtr domain) {
     const char *filename;
     xenXMConfCachePtr entry;
-    long val;
 
     if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
         xenXMError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
@@ -1221,13 +1161,7 @@ unsigned long xenXMDomainGetMaxMemory(vi
     if (!(entry = virHashLookup(configCache, filename)))
         return (-1);
 
-    if (xenXMConfigGetInt(entry->conf, "maxmem", &val) < 0 ||
-        val < 0)
-        if (xenXMConfigGetInt(entry->conf, "memory", &val) < 0 ||
-            val < 0)
-            val = MIN_XEN_GUEST_SIZE * 2;
-
-    return (val * 1024);
+    return entry->def->maxmem;
 }
 
 /*
@@ -1236,7 +1170,6 @@ int xenXMDomainSetVcpus(virDomainPtr dom
 int xenXMDomainSetVcpus(virDomainPtr domain, unsigned int vcpus) {
     const char *filename;
     xenXMConfCachePtr entry;
-    virConfValuePtr value;
 
     if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
         xenXMError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
@@ -1254,19 +1187,12 @@ int xenXMDomainSetVcpus(virDomainPtr dom
     if (!(entry = virHashLookup(configCache, filename)))
         return (-1);
 
-    if (VIR_ALLOC(value) < 0)
-        return (-1);
-
-    value->type = VIR_CONF_LONG;
-    value->l = vcpus;
-
-    if (virConfSetValue(entry->conf, "vcpus", value) < 0)
-        return (-1);
+    entry->def->vcpus = vcpus;
 
     /* If this fails, should we try to undo our changes to the
      * in-memory representation of the config file. I say not!
      */
-    if (virConfWriteFile(entry->filename, entry->conf) < 0)
+    if (xenXMConfigSaveFile(domain->conn, entry->filename, entry->def) < 0)
         return (-1);
 
     return (0);
@@ -1291,9 +1217,10 @@ int xenXMDomainPinVcpu(virDomainPtr doma
     xenXMConfCachePtr entry;
     virBuffer mapbuf = VIR_BUFFER_INITIALIZER;
     char *mapstr = NULL;
-    char *ranges = NULL;
     int i, j, n, comma = 0;
     int ret = -1;
+    char *cpuset = NULL;
+    int maxcpu = 4096;
 
     if (domain == NULL || domain->conn == NULL || domain->name == NULL
         || cpumap == NULL || maplen < 1 || maplen > (int)sizeof(cpumap_t)) {
@@ -1342,24 +1269,28 @@ int xenXMDomainPinVcpu(virDomainPtr doma
 
     mapstr = virBufferContentAndReset(&mapbuf);
 
-    /* convert the mapstr to a range based string */
-    ranges = virConvertCpuSet(domain->conn, mapstr, 0);
-
-    if (ranges != NULL) {
-        if (xenXMConfigSetString(entry->conf, "cpus", ranges) < 0)
-            goto cleanup;
-    } else
-        if (xenXMConfigSetString(entry->conf, "cpus", mapstr) < 0)
-            goto cleanup;
-
-    if (virConfWriteFile(entry->filename, entry->conf) < 0)
+    if (VIR_ALLOC_N(cpuset, maxcpu) < 0) {
+        xenXMError(domain->conn, VIR_ERR_NO_MEMORY, _("allocate buffer"));
+        goto cleanup;
+    }
+    if (virDomainCpuSetParse(domain->conn,
+                             (const char **)&mapstr, 0,
+                             cpuset, maxcpu) < 0)
+        goto cleanup;
+
+    VIR_FREE(entry->def->cpumask);
+    entry->def->cpumask = cpuset;
+    entry->def->cpumasklen = maxcpu;
+    cpuset = NULL;
+
+    if (xenXMConfigSaveFile(domain->conn, entry->filename, entry->def) < 0)
         goto cleanup;
 
     ret = 0;
 
  cleanup:
     VIR_FREE(mapstr);
-    VIR_FREE(ranges);
+    VIR_FREE(cpuset);
     return (ret);
 }
 
@@ -1370,7 +1301,7 @@ virDomainPtr xenXMDomainLookupByName(vir
     const char *filename;
     xenXMConfCachePtr entry;
     virDomainPtr ret;
-    unsigned char uuid[VIR_UUID_BUFLEN];
+
     if (!VIR_IS_CONNECT(conn)) {
         xenXMError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
         return (NULL);
@@ -1390,12 +1321,7 @@ virDomainPtr xenXMDomainLookupByName(vir
         return (NULL);
     }
 
-
-    if (xenXMConfigGetUUID(entry->conf, "uuid", uuid) < 0) {
-        return (NULL);
-    }
-
-    if (!(ret = virGetDomain(conn, domname, uuid))) {
+    if (!(ret = virGetDomain(conn, domname, entry->def->uuid))) {
         return (NULL);
     }
 
@@ -1411,15 +1337,10 @@ virDomainPtr xenXMDomainLookupByName(vir
  * Hash table iterator to search for a domain based on UUID
  */
 static int xenXMDomainSearchForUUID(const void *payload, const char *name ATTRIBUTE_UNUSED, const void *data) {
-    unsigned char uuid[VIR_UUID_BUFLEN];
     const unsigned char *wantuuid = (const unsigned char *)data;
     const xenXMConfCachePtr entry = (const xenXMConfCachePtr)payload;
 
-    if (xenXMConfigGetUUID(entry->conf, "uuid", uuid) < 0) {
-        return (0);
-    }
-
-    if (!memcmp(uuid, wantuuid, VIR_UUID_BUFLEN))
+    if (!memcmp(entry->def->uuid, wantuuid, VIR_UUID_BUFLEN))
         return (1);
 
     return (0);
@@ -1432,7 +1353,6 @@ virDomainPtr xenXMDomainLookupByUUID(vir
                                      const unsigned char *uuid) {
     xenXMConfCachePtr entry;
     virDomainPtr ret;
-    const char *domname;
 
     if (!VIR_IS_CONNECT(conn)) {
         xenXMError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
@@ -1450,11 +1370,7 @@ virDomainPtr xenXMDomainLookupByUUID(vir
         return (NULL);
     }
 
-    if (xenXMConfigGetString(entry->conf, "name", &domname) < 0) {
-        return (NULL);
-    }
-
-    if (!(ret = virGetDomain(conn, domname, uuid))) {
+    if (!(ret = virGetDomain(conn, entry->def->name, uuid))) {
         return (NULL);
     }
 
@@ -1470,35 +1386,28 @@ virDomainPtr xenXMDomainLookupByUUID(vir
  * Start a domain from an existing defined config file
  */
 int xenXMDomainCreate(virDomainPtr domain) {
-    char *xml;
     char *sexpr;
     int ret;
-    unsigned char uuid[VIR_UUID_BUFLEN];
     xenUnifiedPrivatePtr priv;
-    virDomainDefPtr def;
+    const char *filename;
+    xenXMConfCachePtr entry;
+
+    priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
 
     if (domain->id != -1)
         return (-1);
 
-    if (!(xml = xenXMDomainDumpXML(domain, 0)))
-        return (-1);
-
-    priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
-
-    if (!(def = virDomainDefParseString(domain->conn, priv->caps, xml))) {
-        xenXMError(domain->conn, VIR_ERR_XML_ERROR,
-                   _("failed to parse domain description"));
-        return (-1);
-    }
-    VIR_FREE(xml);
-
-    if (!(sexpr = xenDaemonFormatSxpr(domain->conn, def, priv->xendConfigVersion))) {
-        virDomainDefFree(def);
+    if (!(filename = virHashLookup(nameConfigMap, domain->name)))
+        return (-1);
+
+    if (!(entry = virHashLookup(configCache, filename)))
+        return (-1);
+
+    if (!(sexpr = xenDaemonFormatSxpr(domain->conn, entry->def, priv->xendConfigVersion))) {
         xenXMError(domain->conn, VIR_ERR_XML_ERROR,
                    _("failed to build sexpr"));
         return (-1);
     }
-    virDomainDefFree(def);
 
     ret = xenDaemonDomainCreateLinux(domain->conn, sexpr);
     VIR_FREE(sexpr);
@@ -1506,7 +1415,8 @@ int xenXMDomainCreate(virDomainPtr domai
         return (-1);
     }
 
-    if ((ret = xenDaemonDomainLookupByName_ids(domain->conn, domain->name, uuid)) < 0) {
+    if ((ret = xenDaemonDomainLookupByName_ids(domain->conn, domain->name,
+                                               entry->def->uuid)) < 0) {
         return (-1);
     }
     domain->id = ret;
@@ -1930,7 +1840,8 @@ static char *xenXMParseXMLVif(virConnect
 }
 
 
-virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
+virConfPtr xenXMDomainConfigFormat(virConnectPtr conn,
+                                   virDomainDefPtr def) {
     xmlDocPtr doc = NULL;
     xmlNodePtr node;
     xmlXPathObjectPtr obj = NULL;
@@ -1940,10 +1851,17 @@ virConfPtr xenXMParseXMLToConfig(virConn
     int hvm = 0, i;
     xenUnifiedPrivatePtr priv;
     char *cpus;
+    char *xml;
+
+    priv = (xenUnifiedPrivatePtr) conn->privateData;
+
+    if (!(xml = virDomainDefFormat(conn, def, VIR_DOMAIN_XML_SECURE)))
+        return NULL;
 
     doc = xmlReadDoc((const xmlChar *) xml, "domain.xml", NULL,
                      XML_PARSE_NOENT | XML_PARSE_NONET |
                      XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
+    VIR_FREE(xml);
     if (doc == NULL) {
         xenXMError(conn, VIR_ERR_XML_ERROR,
                    _("cannot read XML domain definition"));
@@ -2024,8 +1942,6 @@ virConfPtr xenXMParseXMLToConfig(virConn
         hvm = 1;
     xmlXPathFreeObject(obj);
     obj = NULL;
-
-    priv = (xenUnifiedPrivatePtr) conn->privateData;
 
     if (hvm) {
         const char *boot = "c";
@@ -2390,10 +2306,9 @@ virDomainPtr xenXMDomainDefineXML(virCon
     virDomainPtr olddomain;
     char filename[PATH_MAX];
     const char * oldfilename;
-    unsigned char uuid[VIR_UUID_BUFLEN];
-    virConfPtr conf = NULL;
+    virDomainDefPtr def = NULL;
     xenXMConfCachePtr entry = NULL;
-    virConfValuePtr value;
+    xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
 
     if (!VIR_IS_CONNECT(conn)) {
         xenXMError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
@@ -2409,21 +2324,13 @@ virDomainPtr xenXMDomainDefineXML(virCon
     if (xenXMConfigCacheRefresh (conn) < 0)
         return (NULL);
 
-    if (!(conf = xenXMParseXMLToConfig(conn, xml)))
-        goto error;
-
-    if (!(value = virConfGetValue(conf, "name")) ||
-        value->type != VIR_CONF_STRING ||
-        value->str == NULL) {
-        xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
-                   _("name config parameter is missing"));
-        goto error;
-    }
-
-    if (virHashLookup(nameConfigMap, value->str)) {
+    if (!(def = virDomainDefParseString(conn, priv->caps, xml)))
+        return (NULL);
+
+    if (virHashLookup(nameConfigMap, def->name)) {
         /* domain exists, we will overwrite it */
 
-        if (!(oldfilename = (char *)virHashLookup(nameConfigMap, value->str))) {
+        if (!(oldfilename = (char *)virHashLookup(nameConfigMap, def->name))) {
             xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
                        _("can't retrieve config filename for domain to overwrite"));
             goto error;
@@ -2435,17 +2342,12 @@ virDomainPtr xenXMDomainDefineXML(virCon
             goto error;
         }
 
-        if (xenXMConfigGetUUID(entry->conf, "uuid", uuid) < 0) {
-            xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
-                       _("uuid config parameter is missing"));
-            goto error;
-        }
-
-        if (!(olddomain = virGetDomain(conn, value->str, uuid)))
+        /* XXX wtf.com is this line for - it appears to be amemory leak */
+        if (!(olddomain = virGetDomain(conn, def->name, entry->def->uuid)))
             goto error;
 
         /* Remove the name -> filename mapping */
-        if (virHashRemoveEntry(nameConfigMap, value->str, NULL) < 0) {
+        if (virHashRemoveEntry(nameConfigMap, def->name, NULL) < 0) {
             xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
                        _("failed to remove old domain from config map"));
             goto error;
@@ -2461,7 +2363,7 @@ virDomainPtr xenXMDomainDefineXML(virCon
         entry = NULL;
     }
 
-    if ((strlen(configDir) + 1 + strlen(value->str) + 1) > PATH_MAX) {
+    if ((strlen(configDir) + 1 + strlen(def->name) + 1) > PATH_MAX) {
         xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
                    _("config file name is too long"));
         goto error;
@@ -2469,13 +2371,10 @@ virDomainPtr xenXMDomainDefineXML(virCon
 
     strcpy(filename, configDir);
     strcat(filename, "/");
-    strcat(filename, value->str);
-
-    if (virConfWriteFile(filename, conf) < 0) {
-        xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
-                   _("unable to write config file"));
+    strcat(filename, def->name);
+
+    if (xenXMConfigSaveFile(conn, filename, def) < 0)
         goto error;
-    }
 
     if (VIR_ALLOC(entry) < 0) {
         xenXMError(conn, VIR_ERR_NO_MEMORY, _("config"));
@@ -2489,13 +2388,7 @@ virDomainPtr xenXMDomainDefineXML(virCon
     }
 
     memmove(entry->filename, filename, PATH_MAX);
-    entry->conf = conf;
-
-    if (xenXMConfigGetUUID(conf, "uuid", uuid) < 0) {
-        xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
-                   _("uuid config parameter is missing"));
-        goto error;
-    }
+    entry->def = def;
 
     if (virHashAddEntry(configCache, filename, entry) < 0) {
         xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
@@ -2503,25 +2396,23 @@ virDomainPtr xenXMDomainDefineXML(virCon
         goto error;
     }
 
-    if (virHashAddEntry(nameConfigMap, value->str, entry->filename) < 0) {
+    if (virHashAddEntry(nameConfigMap, def->name, entry->filename) < 0) {
         virHashRemoveEntry(configCache, filename, NULL);
         xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
                    _("unable to store config file handle"));
         goto error;
     }
 
-    entry = NULL;
-
-    if (!(ret = virGetDomain(conn, value->str, uuid)))
-        goto error;
+    if (!(ret = virGetDomain(conn, def->name, def->uuid)))
+        return NULL;
+
     ret->id = -1;
 
     return (ret);
 
  error:
     VIR_FREE(entry);
-    if (conf)
-        virConfFree(conf);
+    virDomainDefFree(def);
     return (NULL);
 }
 
@@ -2628,6 +2519,15 @@ int xenXMNumOfDefinedDomains(virConnectP
 
     return virHashSize(nameConfigMap);
 }
+
+static int xenXMDiskCompare(virDomainDiskDefPtr a,
+                            virDomainDiskDefPtr b) {
+    if (a->bus == b->bus)
+        return virDiskNameToIndex(a->dst) - virDiskNameToIndex(b->dst);
+    else
+        return a->bus - b->bus;
+}
+
 
 /**
  * xenXMDomainAttachDevice:
@@ -2643,75 +2543,65 @@ xenXMDomainAttachDevice(virDomainPtr dom
 xenXMDomainAttachDevice(virDomainPtr domain, const char *xml) {
     const char *filename = NULL;
     xenXMConfCachePtr entry = NULL;
-    xmlDocPtr doc = NULL;
-    xmlNodePtr node = NULL;
-    xmlXPathContextPtr ctxt = NULL;
-    xmlXPathObjectPtr obj = NULL;
-    char *domxml = NULL;
-    int ret = -1, hvm = 0;
+    int ret = -1;
+    virDomainDeviceDefPtr dev = NULL;
 
     if ((!domain) || (!domain->conn) || (!domain->name) || (!xml)) {
         xenXMError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
                    __FUNCTION__);
-        goto cleanup;
+        return -1;
     }
     if (domain->conn->flags & VIR_CONNECT_RO)
-        goto cleanup;
+        return -1;
     if (domain->id != -1)
-        goto cleanup;
+        return -1;
+
     if (!(filename = virHashLookup(nameConfigMap, domain->name)))
-        goto cleanup;
+        return -1;
     if (!(entry = virHashLookup(configCache, filename)))
-        goto cleanup;
-    if (!(entry->conf))
-        goto cleanup;
-
-    if (!(domxml = xenXMDomainDumpXML(domain, 0)))
-        goto cleanup;
-
-    doc = xmlReadDoc((const xmlChar *) domxml, "domain.xml", NULL,
-                     XML_PARSE_NOENT | XML_PARSE_NONET |
-                     XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
-    if (!doc) {
-        xenXMError(domain->conn, VIR_ERR_XML_ERROR,
-                   _("cannot read XML domain definition"));
-        goto cleanup;
-    }
-    if (!(ctxt = xmlXPathNewContext(doc))) {
-        xenXMError(domain->conn, VIR_ERR_INTERNAL_ERROR,
-                   _("cannot create XPath context"));
-        goto cleanup;
-    }
-    obj = xmlXPathEval(BAD_CAST "string(/domain/os/type)", ctxt);
-    if ((obj != NULL) && (obj->type == XPATH_STRING) &&
-        (obj->stringval) && (STREQ((char *)obj->stringval, "hvm")))
-        hvm = 1;
-
-    xmlXPathFreeContext(ctxt);
-    ctxt = NULL;
-    if (doc)
-        xmlFreeDoc(doc);
-    doc = xmlReadDoc((const xmlChar *) xml, "device.xml", NULL,
-                     XML_PARSE_NOENT | XML_PARSE_NONET |
-                     XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
-    if (!doc) {
-        xenXMError(domain->conn, VIR_ERR_XML_ERROR,
-                   _("cannot read XML domain definition"));
-        goto cleanup;
-    }
-    if (!(ctxt = xmlXPathNewContext(doc))) {
-        xenXMError(domain->conn, VIR_ERR_INTERNAL_ERROR,
-                   _("cannot create XPath context"));
-        goto cleanup;
-    }
-
-    if ((node = virXPathNode("/disk", ctxt))) {
-        if (xenXMAttachDisk(domain, ctxt, hvm, node, entry))
-            goto cleanup;
-    } else if ((node = virXPathNode("/interface", ctxt))) {
-        if (xenXMAttachInterface(domain, ctxt, hvm, node, entry))
-            goto cleanup;
-    } else {
+        return -1;
+
+    if (!(dev = virDomainDeviceDefParse(domain->conn,
+                                        entry->def,
+                                        xml)))
+        return -1;
+
+    switch (dev->type) {
+    case VIR_DOMAIN_DEVICE_DISK:
+    {
+        /* Maintain list in sorted order according to target device name */
+        if (entry->def->disks == NULL) {
+            dev->data.disk->next = entry->def->disks;
+            entry->def->disks = dev->data.disk;
+        } else {
+            virDomainDiskDefPtr ptr = entry->def->disks;
+            while (ptr) {
+                if (!ptr->next || xenXMDiskCompare(dev->data.disk, ptr->next) < 0) {
+                    dev->data.disk->next = ptr->next;
+                    ptr->next = dev->data.disk;
+                    break;
+                }
+                ptr = ptr->next;
+            }
+        }
+        dev->data.disk = NULL;
+    }
+    break;
+
+    case VIR_DOMAIN_DEVICE_NET:
+    {
+        virDomainNetDefPtr net = entry->def->nets;
+        while (net && net->next)
+            net = net->next;
+        if (net)
+            net->next = dev->data.net;
+        else
+            entry->def->nets = dev->data.net;
+        dev->data.net = NULL;
+        break;
+    }
+
+    default:
         xenXMError(domain->conn, VIR_ERR_XML_ERROR,
                    _("unknown device"));
         goto cleanup;
@@ -2720,318 +2610,17 @@ xenXMDomainAttachDevice(virDomainPtr dom
     /* If this fails, should we try to undo our changes to the
      * in-memory representation of the config file. I say not!
      */
-    if (virConfWriteFile(entry->filename, entry->conf) < 0)
+    if (xenXMConfigSaveFile(domain->conn, entry->filename, entry->def) < 0)
         goto cleanup;
 
     ret = 0;
 
  cleanup:
-    VIR_FREE(domxml);
-    xmlXPathFreeObject(obj);
-    xmlXPathFreeContext(ctxt);
-    if (doc)
-        xmlFreeDoc(doc);
+    virDomainDeviceDefFree(dev);
 
     return ret;
 }
 
-static int
-xenXMAttachDisk(virDomainPtr domain, xmlXPathContextPtr ctxt, int hvm,
-                xmlNodePtr node, xenXMConfCachePtr entry) {
-    virConfValuePtr list_item = NULL, list_val = NULL, prev = NULL;
-    xenUnifiedPrivatePtr priv = NULL;
-    xmlChar *type = NULL, *source = NULL, *target = NULL;
-    int ret = -1;
-    char *dev;
-
-    priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
-    xenXMParseXMLDisk(node, hvm, ((xenUnifiedPrivatePtr) domain->conn->privateData)->xendConfigVersion, &dev);
-    if (!dev)
-        goto cleanup;
-
-    if (!(type = xmlGetProp(node, BAD_CAST "type"))) {
-        xenXMError(domain->conn, VIR_ERR_XML_ERROR, XM_XML_ERROR);
-        goto cleanup;
-    }
-    if (!(node = virXPathNode("/disk/source", ctxt))) {
-        xenXMError(domain->conn, VIR_ERR_XML_ERROR, XM_XML_ERROR);
-        goto cleanup;
-    }
-    if (STREQ((const char *) type, "block"))
-        source = xmlGetProp(node, BAD_CAST "dev");
-    else if (STREQ((const char *) type, "file"))
-        source = xmlGetProp(node, BAD_CAST "file");
-    else {
-        xenXMError(domain->conn, VIR_ERR_XML_ERROR, XM_XML_ERROR);
-        goto cleanup;
-    }
-    if (!(node = virXPathNode("/disk/target", ctxt))) {
-        xenXMError(domain->conn, VIR_ERR_XML_ERROR, XM_XML_ERROR);
-        goto cleanup;
-    }
-    target = xmlGetProp(node, BAD_CAST "dev");
-
-    list_item = virConfGetValue(entry->conf, "disk");
-    if (list_item && list_item->type == VIR_CONF_LIST) {
-        prev = list_item;
-        list_val = list_item->list;
-        while (list_val) {
-            if ((list_val->type != VIR_CONF_STRING) || (!list_val->str))
-                goto skip;
-            char domdev[NAME_MAX];
-            char *head;
-            char *offset;
-            char *tmp;
-
-            head = list_val->str;
-
-            /* Extract the source */
-            if (!(offset = strchr(head, ',')) || offset[0] == '\0')
-                goto skip;
-            if ((offset - head) >= (PATH_MAX-1))
-                goto skip;
-            head = offset + 1;
-
-            /* Extract the dest */
-            if (!(offset = strchr(head, ',')) || offset[0] == '\0')
-                goto skip;
-            if ((offset - head) >= (PATH_MAX-1))
-                goto skip;
-            strncpy(domdev, head, (offset - head));
-            domdev[(offset-head)] = '\0';
-            head = offset + 1;
-
-            /* Remove legacy ioemu: junk */
-            if (STRPREFIX(domdev, "ioemu:")) {
-                memmove(domdev, domdev+6, strlen(domdev)-5);
-            }
-
-            /* Check for a :cdrom/:disk postfix */
-            if ((tmp = strchr(domdev, ':')))
-                tmp[0] = '\0';
-
-            if (STREQ(domdev, (const char *) target))
-                break;
-         skip:
-            prev = list_val;
-            list_val = list_val->next;
-        }
-    } else if (!list_item) {
-        if (VIR_ALLOC(list_item) < 0)
-            goto cleanup;
-        list_item->type = VIR_CONF_LIST;
-        if(virConfSetValue(entry->conf, "disk", list_item)) {
-            VIR_FREE(list_item);
-            goto cleanup;
-        }
-        list_val = NULL;
-        prev = list_item;
-    } else
-        goto cleanup;
-
-    if (!list_val) {
-        /* insert */
-        if (VIR_ALLOC(list_val) < 0)
-            goto cleanup;
-        list_val->type = VIR_CONF_STRING;
-        list_val->next = NULL;
-        list_val->str = dev;
-        if (prev->type == VIR_CONF_LIST)
-            prev->list = list_val;
-        else
-            prev->next = list_val;
-    } else {
-        /* configure */
-        VIR_FREE(list_val->str);
-        list_val->str = dev;
-    }
-
-    ret = 0;
-    goto cleanup;
-
- cleanup:
-    VIR_FREE(type);
-    VIR_FREE(source);
-    VIR_FREE(target);
-
-    return (ret);
-}
-
-static int
-xenXMAttachInterface(virDomainPtr domain, xmlXPathContextPtr ctxt, int hvm,
-                    xmlNodePtr node, xenXMConfCachePtr entry) {
-    virConfValuePtr list_item = NULL, list_val = NULL, prev = NULL;
-    xmlChar *type = NULL, *source = NULL, *mac = NULL;
-    int ret = -1, autoassign = 0;
-    char *dev;
-
-    xmlNodePtr node_cur = NULL, node_tmp = NULL;
-    xmlAttrPtr attr_node = NULL;
-    xmlNodePtr text_node = NULL;
-
-    if(!(type = xmlGetProp(node, BAD_CAST "type"))) {
-        xenXMError(domain->conn, VIR_ERR_XML_ERROR, XM_XML_ERROR);
-        goto cleanup;
-    }
-
-    if (!(node = virXPathNode("/interface/source", ctxt))) {
-        xenXMError(domain->conn, VIR_ERR_XML_ERROR, XM_XML_ERROR);
-        goto cleanup;
-    }
-    source = xmlGetProp(node, BAD_CAST type);
-
-    if ((node = virXPathNode("/interface/mac", ctxt)))
-        mac = xmlGetProp(node, BAD_CAST "address");
-    if (!node || !mac) {
-        if (!(mac = (xmlChar *)xenXMAutoAssignMac()))
-            goto cleanup;
-        autoassign = 1;
-    }
-
-    list_item = virConfGetValue(entry->conf, "vif");
-    if (list_item && list_item->type == VIR_CONF_LIST) {
-        prev = list_item;
-        list_val = list_item->list;
-        while (list_val) {
-            if ((list_val->type != VIR_CONF_STRING) || (!list_val->str))
-                goto skip;
-            char dommac[18];
-            char *key;
-
-            dommac[0] = '\0';
-
-            key = list_val->str;
-            while (key) {
-                char *data;
-                char *nextkey = strchr(key, ',');
-
-                if (!(data = strchr(key, '=')) || (data[0] == '\0'))
-                    goto skip;
-                data++;
-
-                if (STRPREFIX(key, "mac=")) {
-                    int len = nextkey ? (nextkey - data) : 17;
-                    if (len > 17)
-                        len = 17;
-                    strncpy(dommac, data, len);
-                    dommac[len] = '\0';
-                }
-
-                while (nextkey && (nextkey[0] == ',' ||
-                                   nextkey[0] == ' ' ||
-                                   nextkey[0] == '\t'))
-                    nextkey++;
-                key = nextkey;
-            }
-
-            if (virMacAddrCompare (dommac, (const char *) mac) == 0) {
-                if (autoassign) {
-                    VIR_FREE(mac);
-                    mac = NULL;
-                    if (!(mac = (xmlChar *)xenXMAutoAssignMac()))
-                        goto cleanup;
-                    /* initialize the list */
-                    list_item = virConfGetValue(entry->conf, "vif");
-                    prev = list_item;
-                    list_val = list_item->list;
-                    continue;
-                } else
-                    break;
-            }
-        skip:
-            prev = list_val;
-            list_val = list_val->next;
-        }
-    } else if (!list_item) {
-        if (VIR_ALLOC(list_item) < 0)
-            goto cleanup;
-        list_item->type = VIR_CONF_LIST;
-        if(virConfSetValue(entry->conf, "vif", list_item)) {
-            VIR_FREE(list_item);
-            goto cleanup;
-        }
-        list_val = NULL;
-        prev = list_item;
-    } else
-        goto cleanup;
-
-    if ((node = virXPathNode("/interface", ctxt))) {
-        if (autoassign) {
-            node_cur = node->children;
-
-            while (node_cur->next)
-                node_cur = node_cur->next;
-
-            if (VIR_ALLOC(node_tmp) < 0)
-                goto node_cleanup;
-            node_tmp->type = XML_ELEMENT_NODE;
-            if (VIR_ALLOC_N(node_tmp->name, 4) < 0)
-                goto node_cleanup;
-            strcpy((char *)node_tmp->name, "mac");
-            node_tmp->children = NULL;
-
-            if (VIR_ALLOC(attr_node) < 0)
-                goto node_cleanup;
-            attr_node->type = XML_ATTRIBUTE_NODE;
-            attr_node->ns = NULL;
-            if (VIR_ALLOC_N(attr_node->name, 8) < 0)
-                goto node_cleanup;
-            strcpy((char *) attr_node->name, "address");
-            node_tmp->properties = attr_node;
-
-            if (VIR_ALLOC(text_node) < 0)
-                goto node_cleanup;
-            text_node->type = XML_TEXT_NODE;
-            text_node->_private = NULL;
-            if (VIR_ALLOC_N(text_node->name, 5) < 0)
-                goto node_cleanup;
-            strcpy((char *) text_node->name, "text");
-            text_node->children = NULL;
-            text_node->parent = (xmlNodePtr)attr_node;
-            text_node->content = mac;
-            mac = NULL;
-            attr_node->children = text_node;
-            attr_node->last = text_node;
-            attr_node->parent = node_tmp;
-
-            node_cur->next = node_tmp;
-        }
-        if (!(dev = xenXMParseXMLVif(domain->conn, node, hvm)))
-            goto cleanup;
-    } else
-        goto cleanup;
-
-    if (!list_val) {
-        /* insert */
-        if (VIR_ALLOC(list_val) < 0)
-            goto cleanup;
-        list_val->type = VIR_CONF_STRING;
-        list_val->next = NULL;
-        list_val->str = dev;
-        if (prev->type == VIR_CONF_LIST)
-            prev->list = list_val;
-        else
-            prev->next = list_val;
-    } else {
-        /* configure */
-        VIR_FREE(list_val->str);
-        list_val->str = dev;
-    }
-
-    ret = 0;
-    goto cleanup;
-
- node_cleanup:
-    xmlFree(node_tmp);
-    xmlFree(attr_node);
-    xmlFree(text_node);
- cleanup:
-    VIR_FREE(type);
-    VIR_FREE(source);
-    VIR_FREE(mac);
-
-    return (ret);
-}
 
 /**
  * xenXMAutoAssignMac:
@@ -3067,180 +2656,87 @@ static int
 static int
 xenXMDomainDetachDevice(virDomainPtr domain, const char *xml) {
     const char *filename = NULL;
-    char device[8], *domdevice = NULL;
     xenXMConfCachePtr entry = NULL;
-    virConfValuePtr prev = NULL, list_ptr = NULL, list_val = NULL;
-    xmlDocPtr doc = NULL;
-    xmlNodePtr node = NULL;
-    xmlXPathContextPtr ctxt = NULL;
-    xmlChar *key = NULL;
+    virDomainDeviceDefPtr dev = NULL;
     int ret = -1;
 
     if ((!domain) || (!domain->conn) || (!domain->name) || (!xml)) {
         xenXMError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
                    __FUNCTION__);
+        return -1;
+    }
+    if (domain->conn->flags & VIR_CONNECT_RO)
+        return -1;
+    if (domain->id != -1)
+        return -1;
+    if (!(filename = virHashLookup(nameConfigMap, domain->name)))
+        return -1;
+    if (!(entry = virHashLookup(configCache, filename)))
+        return -1;
+
+    if (!(dev = virDomainDeviceDefParse(domain->conn,
+                                        entry->def,
+                                        xml)))
+        return -1;
+
+    switch (dev->type) {
+    case VIR_DOMAIN_DEVICE_DISK:
+    {
+        virDomainDiskDefPtr disk = entry->def->disks;
+        virDomainDiskDefPtr prev = NULL;
+        while (disk) {
+            if (disk->dst &&
+                dev->data.disk->dst &&
+                STREQ(disk->dst, dev->data.disk->dst)) {
+                if (prev) {
+                    prev->next = disk->next;
+                } else {
+                    entry->def->disks = disk->next;
+                }
+                virDomainDiskDefFree(disk);
+                break;
+            }
+            prev = disk;
+            disk = disk->next;
+        }
+        break;
+    }
+
+    case VIR_DOMAIN_DEVICE_NET:
+    {
+        virDomainNetDefPtr net = entry->def->nets;
+        virDomainNetDefPtr prev = NULL;
+        while (net) {
+            if (!memcmp(net->mac, dev->data.net->mac, VIR_DOMAIN_NET_MAC_SIZE)) {
+                if (prev) {
+                    prev->next = net->next;
+                } else {
+                    entry->def->nets = net->next;
+                }
+                virDomainNetDefFree(net);
+                break;
+            }
+            prev = net;
+            net = net->next;
+        }
+        break;
+    }
+    default:
+        xenXMError(domain->conn, VIR_ERR_XML_ERROR,
+                   _("unknown device"));
         goto cleanup;
-    }
-    if (domain->conn->flags & VIR_CONNECT_RO)
-        goto cleanup;
-    if (domain->id != -1)
-        goto cleanup;
-    if (!(filename = virHashLookup(nameConfigMap, domain->name)))
-        goto cleanup;
-
-    doc = xmlReadDoc((const xmlChar *) xml, "device.xml", NULL,
-                     XML_PARSE_NOENT | XML_PARSE_NONET |
-                     XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
-    if (!doc) {
-        xenXMError(domain->conn, VIR_ERR_XML_ERROR,
-                   _("cannot read XML domain definition"));
-        goto cleanup;
-    }
-    if (!(ctxt = xmlXPathNewContext(doc))) {
-        xenXMError(domain->conn, VIR_ERR_INTERNAL_ERROR,
-                   _("cannot create XPath context"));
-        goto cleanup;
-    }
-
-    if ((node = virXPathNode("/disk", ctxt))) {
-        strcpy(device, "disk");
-        if (!(node = virXPathNode("/disk/target", ctxt)))
-            goto cleanup;
-        key = xmlGetProp(node, BAD_CAST "dev");
-    } else if ((node = virXPathNode("/interface", ctxt))) {
-        strcpy(device, "vif");
-        if (!(node = virXPathNode("/interface/mac", ctxt)))
-            goto cleanup;
-        key = xmlGetProp(node, BAD_CAST "address");
-    } else
-        goto cleanup;
-    if (!key || (strlen((char *)key) == 0))
-        goto cleanup;
-
-    if (!(entry = virHashLookup(configCache, filename)))
-        goto cleanup;
-    if (!entry->conf)
-        goto cleanup;
-
-    list_ptr = virConfGetValue(entry->conf, device);
-    if (!list_ptr)
-        goto cleanup;
-    else if (list_ptr && list_ptr->type == VIR_CONF_LIST) {
-        list_val = list_ptr->list;
-        while (list_val) {
-            if (STREQ(device, "disk")) {
-                char domdev[NAME_MAX];
-                char *head;
-                char *offset;
-                char *tmp;
-
-                if ((list_val->type != VIR_CONF_STRING) || (!list_val->str))
-                    goto skip;
-                head = list_val->str;
-
-                /* Extract the source */
-                if (!(offset = strchr(head, ',')) || offset[0] == '\0')
-                    goto skip;
-                if ((offset - head) >= (PATH_MAX-1))
-                    goto skip;
-                head = offset + 1;
-
-                /* Extract the dest */
-                if (!(offset = strchr(head, ',')) || offset[0] == '\0')
-                    goto skip;
-                if ((offset - head) >= (PATH_MAX-1))
-                    goto skip;
-                strncpy(domdev, head, (offset - head));
-                domdev[(offset-head)] = '\0';
-                head = offset + 1;
-
-                /* Remove legacy ioemu: junk */
-                if (STRPREFIX(domdev, "ioemu:")) {
-                    memmove(domdev, domdev+6, strlen(domdev)-5);
-                }
-
-                /* Check for a :cdrom/:disk postfix */
-                if ((tmp = strchr(domdev, ':')))
-                    tmp[0] = '\0';
-
-                if (STREQ(domdev, (const char *) key))
-                    break;
-            } else {
-                char dommac[18];
-                char *mac;
-
-                dommac[0] = '\0';
-
-                if ((list_val->type != VIR_CONF_STRING) || (!list_val->str))
-                    goto skip;
-
-                mac = list_val->str;
-                while (mac) {
-                    char *data;
-                    char *nextmac = strchr(mac, ',');
-
-                    if (!(data = strchr(mac, '=')) || (data[0] == '\0'))
-                        goto skip;
-                    data++;
-
-                    if (STRPREFIX(mac, "mac=")) {
-                        int len = nextmac ? (nextmac - data) : 17;
-                        if (len > 17)
-                            len = 17;
-                        strncpy(dommac, data, len);
-                        dommac[len] = '\0';
-                    }
-
-                    while (nextmac && (nextmac[0] == ',' ||
-                                       nextmac[0] == ' ' ||
-                                       nextmac[0] == '\t'))
-                        nextmac++;
-                    mac = nextmac;
-                }
-
-                if (virMacAddrCompare (dommac, (const char *) key) == 0)
-                    break;
-            }
-        skip:
-            prev = list_val;
-            list_val = list_val->next;
-        }
-    }
-
-    if (!list_val)
-        goto cleanup;
-    else {
-        if (!prev) {
-            virConfValuePtr value;
-            if (VIR_ALLOC(value) < 0)
-                goto cleanup;
-            value->type = VIR_CONF_LIST;
-            value->list = list_val->next;
-            list_val->next = NULL;
-            if (virConfSetValue(entry->conf, device, value)) {
-                VIR_FREE(value);
-                goto cleanup;
-            }
-        } else
-            prev->next = list_val->next;
     }
 
     /* If this fails, should we try to undo our changes to the
      * in-memory representation of the config file. I say not!
      */
-    if (virConfWriteFile(entry->filename, entry->conf) < 0)
+    if (xenXMConfigSaveFile(domain->conn, entry->filename, entry->def) < 0)
         goto cleanup;
 
     ret = 0;
 
  cleanup:
-    xmlXPathFreeContext(ctxt);
-    if (doc)
-        xmlFreeDoc(doc);
-    VIR_FREE(domdevice);
-    VIR_FREE(key);
-    VIR_FREE(list_val);
-
+    virDomainDeviceDefFree(dev);
     return (ret);
 }
 
diff -r a6688e03b4fc src/xm_internal.h
--- a/src/xm_internal.h	Mon Jul 07 07:11:30 2008 -0400
+++ b/src/xm_internal.h	Mon Jul 07 10:11:29 2008 -0400
@@ -28,10 +28,7 @@
 #include "libvirt/libvirt.h"
 #include "conf.h"
 #include "internal.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "domain_conf.h"
 
 extern struct xenUnifiedDriver xenXMDriver;
 int xenXMInit (void);
@@ -58,11 +55,9 @@ virDomainPtr xenXMDomainDefineXML(virCon
 virDomainPtr xenXMDomainDefineXML(virConnectPtr con, const char *xml);
 int xenXMDomainUndefine(virDomainPtr domain);
 
-virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml);
-char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf);
+virConfPtr xenXMDomainConfigFormat(virConnectPtr conn, virDomainDefPtr def);
+virDomainDefPtr xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf);
+
 int xenXMDomainBlockPeek (virDomainPtr dom, const char *path, unsigned long long offset, size_t size, void *buffer);
 
-#ifdef __cplusplus
-}
 #endif
-#endif
diff -r a6688e03b4fc tests/Makefile.am
--- a/tests/Makefile.am	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/Makefile.am	Mon Jul 07 07:11:30 2008 -0400
@@ -100,7 +100,7 @@ sexpr2xmltest_LDADD = $(LDADDS)
 sexpr2xmltest_LDADD = $(LDADDS)
 
 xmconfigtest_SOURCES = \
-	xmconfigtest.c \
+	xmconfigtest.c testutilsxen.c testutilsxen.h \
 	testutils.c testutils.h
 xmconfigtest_LDADD = $(LDADDS)
 
diff -r a6688e03b4fc tests/xmconfigdata/test-escape-paths.cfg
--- a/tests/xmconfigdata/test-escape-paths.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-escape-paths.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,7 +20,7 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso&test,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "none"
 soundhw = "sb16,es1370"
diff -r a6688e03b4fc tests/xmconfigdata/test-escape-paths.xml
--- a/tests/xmconfigdata/test-escape-paths.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-escape-paths.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2&test</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader&test</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm&test</emulator>
     <disk type='block' device='disk'>
@@ -32,11 +32,11 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
     <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
     <sound model='sb16'/>
     <sound model='es1370'/>
   </devices>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-localtime.cfg
--- a/tests/xmconfigdata/test-fullvirt-localtime.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-localtime.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,6 +20,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "none"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-localtime.xml
--- a/tests/xmconfigdata/test-fullvirt-localtime.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-localtime.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='localtime'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='localtime'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,10 +32,10 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
     <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-new-cdrom.cfg
--- a/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,6 +20,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "none"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-new-cdrom.xml
--- a/tests/xmconfigdata/test-fullvirt-new-cdrom.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-new-cdrom.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,10 +32,10 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
     <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-old-cdrom.cfg
--- a/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -21,6 +21,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,ioemu:hda,w" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr0,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr0,type=ioemu" ]
 parallel = "none"
 serial = "none"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-old-cdrom.xml
--- a/tests/xmconfigdata/test-fullvirt-old-cdrom.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-old-cdrom.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,10 +32,10 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr0'/>
     </interface>
     <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg
--- a/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,6 +20,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "tcp:127.0.0.1:7777"
 serial = "none"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-parallel-tcp.xml
--- a/tests/xmconfigdata/test-fullvirt-parallel-tcp.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-parallel-tcp.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,15 +32,15 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
-    <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
     <parallel type='tcp'>
       <source mode='connect' host='127.0.0.1' service='7777'/>
       <protocol type='raw'/>
       <target port='0'/>
     </parallel>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-file.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-file.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-file.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,6 +20,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "file:/tmp/serial.log"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-file.xml
--- a/tests/xmconfigdata/test-fullvirt-serial-file.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-file.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,11 +32,9 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
-    <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
     <serial type='file'>
       <source path='/tmp/serial.log'/>
       <target port='0'/>
@@ -45,5 +43,7 @@
       <source path='/tmp/serial.log'/>
       <target port='0'/>
     </console>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-null.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-null.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-null.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,6 +20,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "null"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-null.xml
--- a/tests/xmconfigdata/test-fullvirt-serial-null.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-null.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,16 +32,16 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
-    <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
     <serial type='null'>
       <target port='0'/>
     </serial>
     <console type='null'>
       <target port='0'/>
     </console>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-pipe.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,6 +20,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "pipe:/tmp/serial.pipe"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-pipe.xml
--- a/tests/xmconfigdata/test-fullvirt-serial-pipe.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-pipe.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,11 +32,9 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
-    <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
     <serial type='pipe'>
       <source path='/tmp/serial.pipe'/>
       <target port='0'/>
@@ -45,5 +43,7 @@
       <source path='/tmp/serial.pipe'/>
       <target port='0'/>
     </console>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-pty.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-pty.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-pty.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,6 +20,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "pty"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-pty.xml
--- a/tests/xmconfigdata/test-fullvirt-serial-pty.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-pty.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,16 +32,16 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
-    <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
     <serial type='pty'>
       <target port='0'/>
     </serial>
     <console type='pty'>
       <target port='0'/>
     </console>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-stdio.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,6 +20,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "stdio"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-stdio.xml
--- a/tests/xmconfigdata/test-fullvirt-serial-stdio.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-stdio.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,16 +32,16 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
-    <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
     <serial type='stdio'>
       <target port='0'/>
     </serial>
     <console type='stdio'>
       <target port='0'/>
     </console>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,6 +20,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "telnet:127.0.0.1:9999,listen"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml
--- a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,11 +32,9 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
-    <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
     <serial type='tcp'>
       <source mode='bind' host='127.0.0.1' service='9999'/>
       <protocol type='telnet'/>
@@ -47,5 +45,7 @@
       <protocol type='telnet'/>
       <target port='0'/>
     </console>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-tcp.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,6 +20,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "tcp:127.0.0.1:7777"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-tcp.xml
--- a/tests/xmconfigdata/test-fullvirt-serial-tcp.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-tcp.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,11 +32,9 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
-    <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
     <serial type='tcp'>
       <source mode='connect' host='127.0.0.1' service='7777'/>
       <protocol type='raw'/>
@@ -47,5 +45,7 @@
       <protocol type='raw'/>
       <target port='0'/>
     </console>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-udp.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-udp.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-udp.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,6 +20,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "udp:127.0.0.1:9999 at 0.0.0.0:99998"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-udp.xml
--- a/tests/xmconfigdata/test-fullvirt-serial-udp.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-udp.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,20 +32,20 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
-    <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
     <serial type='udp'>
+      <source mode='bind' host='0.0.0.0' service='99998'/>
       <source mode='connect' host='127.0.0.1' service='9999'/>
-      <source mode='bind' host='0.0.0.0' service='99998'/>
       <target port='0'/>
     </serial>
     <console type='udp'>
+      <source mode='bind' host='0.0.0.0' service='99998'/>
       <source mode='connect' host='127.0.0.1' service='9999'/>
-      <source mode='bind' host='0.0.0.0' service='99998'/>
       <target port='0'/>
     </console>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-unix.cfg
--- a/tests/xmconfigdata/test-fullvirt-serial-unix.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-unix.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,6 +20,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "unix:/tmp/serial.sock,listen"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-serial-unix.xml
--- a/tests/xmconfigdata/test-fullvirt-serial-unix.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-serial-unix.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,11 +32,9 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
-    <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
     <serial type='unix'>
       <source mode='bind' path='/tmp/serial.sock'/>
       <target port='0'/>
@@ -45,5 +43,7 @@
       <source mode='bind' path='/tmp/serial.sock'/>
       <target port='0'/>
     </console>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-sound.cfg
--- a/tests/xmconfigdata/test-fullvirt-sound.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-sound.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,7 +20,7 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "none"
 soundhw = "sb16,es1370"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-sound.xml
--- a/tests/xmconfigdata/test-fullvirt-sound.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-sound.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,11 +32,11 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
     <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
     <sound model='sb16'/>
     <sound model='es1370'/>
   </devices>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-usbmouse.cfg
--- a/tests/xmconfigdata/test-fullvirt-usbmouse.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-usbmouse.cfg	Mon Jul 07 10:11:29 2008 -0400
@@ -21,6 +21,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "none"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-usbmouse.xml
--- a/tests/xmconfigdata/test-fullvirt-usbmouse.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-usbmouse.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,11 +32,11 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
     <input type='mouse' bus='usb'/>
     <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-usbtablet-no-bus.xml
--- a/tests/xmconfigdata/test-fullvirt-usbtablet-no-bus.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-usbtablet-no-bus.xml	Mon Jul 07 07:11:30 2008 -0400
@@ -32,7 +32,7 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
     <input type='tablet'/>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-usbtablet.cfg
--- a/tests/xmconfigdata/test-fullvirt-usbtablet.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-usbtablet.cfg	Mon Jul 07 10:11:29 2008 -0400
@@ -21,6 +21,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "none"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-usbtablet.xml
--- a/tests/xmconfigdata/test-fullvirt-usbtablet.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-usbtablet.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,11 +32,11 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
     <input type='tablet' bus='usb'/>
     <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-utc.cfg
--- a/tests/xmconfigdata/test-fullvirt-utc.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-utc.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -20,6 +20,6 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,type=ioemu" ]
 parallel = "none"
 serial = "none"
diff -r a6688e03b4fc tests/xmconfigdata/test-fullvirt-utc.xml
--- a/tests/xmconfigdata/test-fullvirt-utc.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-fullvirt-utc.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,23 +1,23 @@
 <domain type='xen'>
   <name>XenGuest2</name>
   <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <os>
-    <type>hvm</type>
+    <type arch='i686' machine='xenfv'>hvm</type>
     <loader>/usr/lib/xen/boot/hvmloader</loader>
     <boot dev='cdrom'/>
   </os>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
-  <features>
-    <pae/>
-    <acpi/>
-    <apic/>
-  </features>
-  <clock offset='utc'/>
   <devices>
     <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
@@ -32,10 +32,10 @@
       <readonly/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:92:9C'/>
+      <mac address='00:16:3e:66:92:9c'/>
       <source bridge='xenbr1'/>
     </interface>
     <input type='mouse' bus='ps2'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-paravirt-net-e1000.cfg
--- a/tests/xmconfigdata/test-paravirt-net-e1000.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-paravirt-net-e1000.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -9,4 +9,4 @@ on_crash = "restart"
 on_crash = "restart"
 vfb = [ "type=vnc,vncunused=1,vnclisten=127.0.0.1,vncpasswd=123poi" ]
 disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ]
-vif = [ "mac=00:16:3E:66:94:9C,model=e1000,ip=192.168.0.9" ]
+vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,model=e1000" ]
diff -r a6688e03b4fc tests/xmconfigdata/test-paravirt-net-e1000.xml
--- a/tests/xmconfigdata/test-paravirt-net-e1000.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-paravirt-net-e1000.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,28 +1,33 @@
 <domain type='xen'>
   <name>XenGuest1</name>
   <uuid>c7a5fdb0-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <bootloader>/usr/bin/pygrub</bootloader>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <os>
+    <type arch='i686' machine='xenpv'>linux</type>
+  </os>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
   <devices>
+    <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
       <driver name='phy'/>
       <source dev='/dev/HostVG/XenGuest1'/>
       <target dev='xvda' bus='xen'/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:94:9C'/>
-      <ip address='192.168.0.9'/>
+      <mac address='00:16:3e:66:94:9c'/>
+      <source bridge='br0'/>
       <model type='e1000'/>
     </interface>
-    <input type='mouse' bus='xen'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
     <console type='pty'>
       <target port='0'/>
     </console>
+    <input type='mouse' bus='xen'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-paravirt-new-pvfb.cfg
--- a/tests/xmconfigdata/test-paravirt-new-pvfb.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-paravirt-new-pvfb.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -9,4 +9,4 @@ on_crash = "restart"
 on_crash = "restart"
 vfb = [ "type=vnc,vncunused=1,vnclisten=127.0.0.1,vncpasswd=123poi" ]
 disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ]
-vif = [ "mac=00:16:3E:66:94:9C,ip=192.168.0.9" ]
+vif = [ "mac=00:16:3e:66:94:9c,bridge=br0" ]
diff -r a6688e03b4fc tests/xmconfigdata/test-paravirt-new-pvfb.xml
--- a/tests/xmconfigdata/test-paravirt-new-pvfb.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-paravirt-new-pvfb.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,27 +1,32 @@
 <domain type='xen'>
   <name>XenGuest1</name>
   <uuid>c7a5fdb0-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <bootloader>/usr/bin/pygrub</bootloader>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <os>
+    <type arch='i686' machine='xenpv'>linux</type>
+  </os>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
   <devices>
+    <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
       <driver name='phy'/>
       <source dev='/dev/HostVG/XenGuest1'/>
       <target dev='xvda' bus='xen'/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:94:9C'/>
-      <ip address='192.168.0.9'/>
+      <mac address='00:16:3e:66:94:9c'/>
+      <source bridge='br0'/>
     </interface>
-    <input type='mouse' bus='xen'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
     <console type='pty'>
       <target port='0'/>
     </console>
+    <input type='mouse' bus='xen'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigdata/test-paravirt-old-pvfb.cfg
--- a/tests/xmconfigdata/test-paravirt-old-pvfb.cfg	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-paravirt-old-pvfb.cfg	Mon Jul 07 07:11:30 2008 -0400
@@ -13,4 +13,4 @@ vnclisten = "127.0.0.1"
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ]
-vif = [ "mac=00:16:3E:66:94:9C,ip=192.168.0.9" ]
+vif = [ "mac=00:16:3e:66:94:9c,bridge=br0" ]
diff -r a6688e03b4fc tests/xmconfigdata/test-paravirt-old-pvfb.xml
--- a/tests/xmconfigdata/test-paravirt-old-pvfb.xml	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigdata/test-paravirt-old-pvfb.xml	Mon Jul 07 10:11:30 2008 -0400
@@ -1,27 +1,32 @@
 <domain type='xen'>
   <name>XenGuest1</name>
   <uuid>c7a5fdb0-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory>592896</memory>
+  <currentMemory>403456</currentMemory>
+  <vcpu>1</vcpu>
   <bootloader>/usr/bin/pygrub</bootloader>
-  <currentMemory>403456</currentMemory>
-  <memory>592896</memory>
-  <vcpu>1</vcpu>
+  <os>
+    <type arch='i686' machine='xenpv'>linux</type>
+  </os>
+  <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
   <devices>
+    <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
     <disk type='block' device='disk'>
       <driver name='phy'/>
       <source dev='/dev/HostVG/XenGuest1'/>
       <target dev='xvda' bus='xen'/>
     </disk>
     <interface type='bridge'>
-      <mac address='00:16:3E:66:94:9C'/>
-      <ip address='192.168.0.9'/>
+      <mac address='00:16:3e:66:94:9c'/>
+      <source bridge='br0'/>
     </interface>
-    <input type='mouse' bus='xen'/>
-    <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
     <console type='pty'>
       <target port='0'/>
     </console>
+    <input type='mouse' bus='xen'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'/>
   </devices>
 </domain>
diff -r a6688e03b4fc tests/xmconfigtest.c
--- a/tests/xmconfigtest.c	Mon Jul 07 07:11:30 2008 -0400
+++ b/tests/xmconfigtest.c	Mon Jul 07 07:35:08 2008 -0400
@@ -33,10 +33,12 @@
 #include "xen_unified.h"
 #include "xm_internal.h"
 #include "testutils.h"
-#include "conf.h"
+#include "testutilsxen.h"
+#include "memory.h"
 
 static char *progname;
 static char *abs_srcdir;
+static virCapsPtr caps;
 
 #define MAX_FILE 4096
 
@@ -54,6 +56,7 @@ static int testCompareParseXML(const cha
     int wrote = MAX_FILE;
     void *old_priv = NULL;
     struct _xenUnifiedPrivate priv;
+    virDomainDefPtr def = NULL;
 
     conn = virConnectOpenReadOnly("test:///default");
     if (!conn) goto fail;
@@ -67,9 +70,13 @@ static int testCompareParseXML(const cha
 
     /* Many puppies died to bring you this code. */
     priv.xendConfigVersion = xendConfigVersion;
+    priv.caps = caps;
     conn->privateData = &priv;
 
-    if (!(conf = xenXMParseXMLToConfig(conn, xmlPtr)))
+    if (!(def = virDomainDefParseString(NULL, caps, xmlPtr)))
+        goto fail;
+
+    if (!(conf = xenXMDomainConfigFormat(conn, def)))
         goto fail;
 
     if (virConfWriteMem(gotxmcfgPtr, &wrote, conf) < 0)
@@ -86,7 +93,7 @@ static int testCompareParseXML(const cha
  fail:
     if (conf)
         virConfFree(conf);
-
+    virDomainDefFree(def);
     if (conn) {
         conn->privateData = old_priv;
         virConnectClose(conn);
@@ -107,6 +114,7 @@ static int testCompareFormatXML(const ch
     virConnectPtr conn;
     void *old_priv;
     struct _xenUnifiedPrivate priv;
+    virDomainDefPtr def = NULL;
 
     conn = virConnectOpenReadOnly("test:///default");
     if (!conn) goto fail;
@@ -120,12 +128,16 @@ static int testCompareFormatXML(const ch
 
     /* Many puppies died to bring you this code. */
     priv.xendConfigVersion = xendConfigVersion;
+    priv.caps = caps;
     conn->privateData = &priv;
 
     if (!(conf = virConfReadMem(xmcfgPtr, strlen(xmcfgPtr))))
         goto fail;
 
-    if (!(gotxml = xenXMDomainFormatXML(conn, conf)))
+    if (!(def = xenXMDomainConfigParse(conn, conf)))
+        goto fail;
+
+    if (!(gotxml = virDomainDefFormat(conn, def, VIR_DOMAIN_XML_SECURE)))
         goto fail;
 
     if (STRNEQ(xmlData, gotxml)) {
@@ -138,8 +150,8 @@ static int testCompareFormatXML(const ch
  fail:
     if (conf)
         virConfFree(conf);
-    free(gotxml);
-
+    VIR_FREE(gotxml);
+    virDomainDefFree(def);
     if (conn) {
         conn->privateData = old_priv;
         virConnectClose(conn);
@@ -187,6 +199,8 @@ mymain(int argc, char **argv)
     if (!abs_srcdir)
         abs_srcdir = getcwd(cwd, sizeof(cwd));
 
+    if (!(caps = testXenCapsInit()))
+        return(EXIT_FAILURE);
 
 #define DO_TEST(name, version)                                          \
     do {                                                                \
@@ -224,6 +238,9 @@ mymain(int argc, char **argv)
     DO_TEST("fullvirt-sound", 2);
 
     DO_TEST("escape-paths", 2);
+
+    virCapabilitiesFree(caps);
+
     return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
 }
 

-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list