]> xenbits.xensource.com Git - libvirt.git/commitdiff
Added full support for serial and parallel devices to Xen drivers
authorDaniel P. Berrange <berrange@redhat.com>
Sat, 26 Apr 2008 14:22:02 +0000 (14:22 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Sat, 26 Apr 2008 14:22:02 +0000 (14:22 +0000)
101 files changed:
ChangeLog
src/internal.h
src/xend_internal.c
src/xend_internal.h
src/xm_internal.c
src/xml.c
src/xml.h
tests/sexpr2xmldata/sexpr2xml-curmem.xml
tests/sexpr2xmldata/sexpr2xml-disk-block-shareable.xml
tests/sexpr2xmldata/sexpr2xml-disk-block.xml
tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.xml
tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.xml
tests/sexpr2xmldata/sexpr2xml-disk-file.xml
tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml
tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.sexpr [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-file.sexpr [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-null.sexpr [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.sexpr [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.sexpr [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.sexpr [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.sexpr [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.sexpr [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.sexpr [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.sexpr [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-net-bridged.xml
tests/sexpr2xmldata/sexpr2xml-net-routed.xml
tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml
tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml
tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml
tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml
tests/sexpr2xmldata/sexpr2xml-pv.xml
tests/sexpr2xmltest.c
tests/xmconfigdata/test-fullvirt-localtime.cfg
tests/xmconfigdata/test-fullvirt-new-cdrom.cfg
tests/xmconfigdata/test-fullvirt-old-cdrom.cfg
tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg [new file with mode: 0755]
tests/xmconfigdata/test-fullvirt-parallel-tcp.xml [new file with mode: 0644]
tests/xmconfigdata/test-fullvirt-serial-file.cfg [new file with mode: 0755]
tests/xmconfigdata/test-fullvirt-serial-file.xml [new file with mode: 0644]
tests/xmconfigdata/test-fullvirt-serial-null.cfg [new file with mode: 0755]
tests/xmconfigdata/test-fullvirt-serial-null.xml [new file with mode: 0644]
tests/xmconfigdata/test-fullvirt-serial-pipe.cfg [new file with mode: 0755]
tests/xmconfigdata/test-fullvirt-serial-pipe.xml [new file with mode: 0644]
tests/xmconfigdata/test-fullvirt-serial-pty.cfg [new file with mode: 0755]
tests/xmconfigdata/test-fullvirt-serial-pty.xml [new file with mode: 0644]
tests/xmconfigdata/test-fullvirt-serial-stdio.cfg [new file with mode: 0755]
tests/xmconfigdata/test-fullvirt-serial-stdio.xml [new file with mode: 0644]
tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg [new file with mode: 0755]
tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml [new file with mode: 0644]
tests/xmconfigdata/test-fullvirt-serial-tcp.cfg [new file with mode: 0755]
tests/xmconfigdata/test-fullvirt-serial-tcp.xml [new file with mode: 0644]
tests/xmconfigdata/test-fullvirt-serial-udp.cfg [new file with mode: 0755]
tests/xmconfigdata/test-fullvirt-serial-udp.xml [new file with mode: 0644]
tests/xmconfigdata/test-fullvirt-serial-unix.cfg [new file with mode: 0755]
tests/xmconfigdata/test-fullvirt-serial-unix.xml [new file with mode: 0644]
tests/xmconfigdata/test-fullvirt-usbmouse.cfg
tests/xmconfigdata/test-fullvirt-usbtablet.cfg
tests/xmconfigdata/test-fullvirt-utc.cfg
tests/xmconfigdata/test-paravirt-new-pvfb.xml
tests/xmconfigdata/test-paravirt-old-pvfb.xml
tests/xmconfigtest.c
tests/xml2sexprdata/xml2sexpr-fv-kernel.sexpr
tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr
tests/xml2sexprdata/xml2sexpr-fv-parallel-tcp.sexpr [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-parallel-tcp.xml [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-file.sexpr [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-file.xml [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-null.sexpr [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-null.xml [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-pipe.sexpr [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-pipe.xml [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-pty.sexpr [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-pty.xml [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-stdio.sexpr [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-stdio.xml [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-tcp-telnet.sexpr [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-tcp-telnet.xml [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-tcp.sexpr [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-tcp.xml [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-udp.sexpr [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-udp.xml [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-unix.sexpr [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-serial-unix.xml [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-fv-usbmouse.sexpr
tests/xml2sexprdata/xml2sexpr-fv-usbtablet.sexpr
tests/xml2sexprdata/xml2sexpr-fv-utc.sexpr
tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr
tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr
tests/xml2sexprdata/xml2sexpr-fv.sexpr
tests/xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr
tests/xml2sexprtest.c

index 7247f9a6afba5e309720f28c79dfd5faac365e11..0bf674c3d168da286a49ef48153bd9ac86a89afb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Sat Apr 26 10:21:28 EST 2008 Daniel P. Berrange <berrange@redhat.com>
+
+       * src/xm_internal.c, src/xml.c, src/xml.h, src/xend_internal.c,
+       src/xend_internal.h: Added support for serial and parallel
+       devices
+       * tests/sexpr2xmltest.c, tests/xml2sexprtest.c, tests/xmconfigtest.c:
+       added tests for serial and parallel devices
+       * tests/sexpr2xmldata/*, tests/xml2sexprdata/*, tests/xmconfigdata/*:
+       updated for new test cases
+
 Fri Apr 25 16:45:28 EST 2008 Daniel P. Berrange <berrange@redhat.com>
 
        * src/internal.c: Convenience macros for fixed arrays
index 67d31b3639d15bd72f1a01fcb8c15627ea0a2cea..02cd3584a1e62472d114ba8747adbe54a79bc3a6 100644 (file)
@@ -65,7 +65,7 @@ extern "C" {
 #define STRCASEEQLEN(a,b,n) (strncasecmp((a),(b),(n)) == 0)
 #define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
 #define STRCASENEQLEN(a,b,n) (strncasecmp((a),(b),(n)) != 0)
-
+#define STRPREFIX(a,b) (strncmp((a),(b),strlen((b))) == 0)
 
 #define NUL_TERMINATE(buf) do { (buf)[sizeof(buf)-1] = '\0'; } while (0)
 #define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
index 6ba4571db6f0443fd4a887f50b17c90ac485caca..7eb4877e10ec81cabcd5f1b16053736c88bd01dc 100644 (file)
@@ -1376,6 +1376,244 @@ xend_parse_sexp_desc_os(virConnectPtr xend, struct sexpr *node, virBufferPtr buf
     return(0);
 }
 
+
+int
+xend_parse_sexp_desc_char(virConnectPtr conn,
+                          virBufferPtr buf,
+                          const char *devtype,
+                          int portNum,
+                          const char *value,
+                          const char *tty)
+{
+    const char *type;
+    int telnet = 0;
+    char *bindPort = NULL;
+    char *bindHost = NULL;
+    char *connectPort = NULL;
+    char *connectHost = NULL;
+    char *path = NULL;
+    int ret = -1;
+
+    if (value[0] == '/') {
+        type = "dev";
+    } else if (STRPREFIX(value, "null")) {
+        type = "null";
+        value = NULL;
+    } else if (STRPREFIX(value, "vc")) {
+        type = "vc";
+        value = NULL;
+    } else if (STRPREFIX(value, "pty")) {
+        type = "pty";
+        value = NULL;
+    } else if (STRPREFIX(value, "stdio")) {
+        type = "stdio";
+        value = NULL;
+    } else if (STRPREFIX(value, "file:")) {
+        type = "file";
+        value += sizeof("file:")-1;
+    } else if (STRPREFIX(value, "pipe:")) {
+        type = "pipe";
+        value += sizeof("pipe:")-1;
+    } else if (STRPREFIX(value, "tcp:")) {
+        type = "tcp";
+        value += sizeof("tcp:")-1;
+    } else if (STRPREFIX(value, "telnet:")) {
+        type = "tcp";
+        value += sizeof("telnet:")-1;
+        telnet = 1;
+    } else if (STRPREFIX(value, "udp:")) {
+        type = "udp";
+        value += sizeof("udp:")-1;
+    } else if (STRPREFIX(value, "unix:")) {
+        type = "unix";
+        value += sizeof("unix:")-1;
+    } else {
+        virXendError(conn, VIR_ERR_INTERNAL_ERROR,
+                     _("Unknown char device type"));
+        return -1;
+    }
+
+    /* Compat with legacy  <console tty='/dev/pts/5'/> syntax */
+    if (STREQ(devtype, "console") &&
+        STREQ(type, "pty") &&
+        tty != NULL) {
+        if (virBufferVSprintf(buf, "    <%s type='%s' tty='%s'>\n",
+                              devtype, type, tty) < 0)
+            goto no_memory;
+    } else {
+        if (virBufferVSprintf(buf, "    <%s type='%s'>\n",
+                              devtype, type) < 0)
+            goto no_memory;
+    }
+
+    if (STREQ(type, "null") ||
+        STREQ(type, "vc") ||
+        STREQ(type, "stdio")) {
+        /* no source needed */
+    } else if (STREQ(type, "pty")) {
+        if (tty &&
+            virBufferVSprintf(buf, "      <source path='%s'/>\n",
+                              tty) < 0)
+            goto no_memory;
+    } else if (STREQ(type, "file") ||
+               STREQ(type, "pipe")) {
+        if (virBufferVSprintf(buf, "      <source path='%s'/>\n",
+                              value) < 0)
+            goto no_memory;
+    } else if (STREQ(type, "tcp")) {
+        const char *offset = strchr(value, ':');
+        const char *offset2;
+        const char *mode, *protocol;
+
+        if (offset == NULL) {
+            virXendError(conn, VIR_ERR_INTERNAL_ERROR,
+                         _("malformed char device string"));
+            goto error;
+        }
+
+        if (offset != value &&
+            (bindHost = strndup(value, offset - value)) == NULL)
+            goto no_memory;
+
+        offset2 = strchr(offset, ',');
+        if (offset2 == NULL)
+            bindPort = strdup(offset+1);
+        else
+            bindPort = strndup(offset+1, offset2-(offset+1));
+        if (bindPort == NULL)
+            goto no_memory;
+
+        if (offset2 && strstr(offset2, ",listen"))
+            mode = "bind";
+        else
+            mode = "connect";
+        protocol = telnet ? "telnet":"raw";
+
+        if (bindHost) {
+            if (virBufferVSprintf(buf,
+                                  "      <source mode='%s' host='%s' service='%s'/>\n",
+                                  mode, bindHost, bindPort) < 0)
+                goto no_memory;
+        } else {
+            if (virBufferVSprintf(buf,
+                                  "      <source mode='%s' service='%s'/>\n",
+                                  mode, bindPort) < 0)
+                goto no_memory;
+        }
+        if (virBufferVSprintf(buf,
+                              "      <protocol type='%s'/>\n",
+                              protocol) < 0)
+            goto no_memory;
+    } else if (STREQ(type, "udp")) {
+        const char *offset = strchr(value, ':');
+        const char *offset2, *offset3;
+
+        if (offset == NULL) {
+            virXendError(conn, VIR_ERR_INTERNAL_ERROR,
+                         _("malformed char device string"));
+            goto error;
+        }
+
+        if (offset != value &&
+            (connectHost = strndup(value, offset - value)) == NULL)
+            goto no_memory;
+
+        offset2 = strchr(offset, '@');
+        if (offset2 != NULL) {
+            if ((connectPort = strndup(offset + 1, offset2-(offset+1))) == NULL)
+                goto no_memory;
+
+            offset3 = strchr(offset2, ':');
+            if (offset3 == NULL) {
+                virXendError(conn, VIR_ERR_INTERNAL_ERROR,
+                             _("malformed char device string"));
+                goto error;
+            }
+
+            if (offset3 > (offset2 + 1) &&
+                (bindHost = strndup(offset2 + 1, offset3 - (offset2+1))) == NULL)
+                goto no_memory;
+
+            if ((bindPort = strdup(offset3 + 1)) == NULL)
+                goto no_memory;
+        } else {
+            if ((connectPort = strdup(offset + 1)) == NULL)
+                goto no_memory;
+        }
+
+        if (connectPort) {
+            if (connectHost) {
+                if (virBufferVSprintf(buf,
+                                      "      <source mode='connect' host='%s' service='%s'/>\n",
+                                      connectHost, connectPort) < 0)
+                    goto no_memory;
+            } else {
+                if (virBufferVSprintf(buf,
+                                      "      <source mode='connect' service='%s'/>\n",
+                                      connectPort) < 0)
+                    goto no_memory;
+            }
+        }
+        if (bindPort) {
+            if (bindHost) {
+                if (virBufferVSprintf(buf,
+                                      "      <source mode='bind' host='%s' service='%s'/>\n",
+                                      bindHost, bindPort) < 0)
+                    goto no_memory;
+            } else {
+                if (virBufferVSprintf(buf,
+                                      "      <source mode='bind' service='%s'/>\n",
+                                      bindPort) < 0)
+                    goto no_memory;
+            }
+        }
+
+    } else if (STREQ(type, "unix")) {
+        const char *offset = strchr(value, ',');
+        int dolisten = 0;
+        if (offset)
+            path = strndup(value, (offset - value));
+        else
+            path = strdup(value);
+        if (path == NULL)
+            goto no_memory;
+
+        if (offset != NULL &&
+            strstr(offset, ",listen") != NULL)
+            dolisten = 1;
+
+        if (virBufferVSprintf(buf, "      <source mode='%s' path='%s'/>\n",
+                              dolisten ? "bind" : "connect", path) < 0)
+            goto no_memory;
+    }
+
+    if (virBufferVSprintf(buf, "      <target port='%d'/>\n",
+                          portNum) < 0)
+        goto no_memory;
+
+    if (virBufferVSprintf(buf, "    </%s>\n",
+                          devtype) < 0)
+        goto no_memory;
+
+    ret = 0;
+
+    if (ret == -1) {
+no_memory:
+        virXendError(conn, VIR_ERR_NO_MEMORY,
+                     _("no memory for char device config"));
+    }
+
+error:
+
+    free(path);
+    free(bindHost);
+    free(bindPort);
+    free(connectHost);
+    free(connectPort);
+
+    return ret;
+}
+
 /**
  * xend_parse_sexp_desc:
  * @conn: the connection associated with the XML
@@ -1828,10 +2066,33 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
     }
 
     tty = xenStoreDomainGetConsolePath(conn, domid);
-    if (tty) {
-        virBufferVSprintf(&buf, "    <console tty='%s'/>\n", tty);
-        free(tty);
+    if (hvm) {
+        tmp = sexpr_node(root, "domain/image/hvm/serial");
+        if (tmp && STRNEQ(tmp, "none")) {
+            if (xend_parse_sexp_desc_char(conn, &buf, "serial", 0, tmp, tty) < 0)
+                goto error;
+            /* Add back-compat <console/> tag for primary console */
+            if (xend_parse_sexp_desc_char(conn, &buf, "console", 0, tmp, tty) < 0)
+                goto error;
+        }
+        tmp = sexpr_node(root, "domain/image/hvm/parallel");
+        if (tmp && STRNEQ(tmp, "none")) {
+            /* XXX does XenD stuff parallel port tty info into xenstore somewhere ? */
+            if (xend_parse_sexp_desc_char(conn, &buf, "parallel", 0, tmp, NULL) < 0)
+                goto error;
+        }
+    } else {
+        /* Paravirt always has a console */
+        if (tty) {
+            virBufferVSprintf(&buf, "    <console type='pty' tty='%s'>\n", tty);
+            virBufferVSprintf(&buf, "      <source path='%s'/>\n", tty);
+        } else {
+            virBufferAddLit(&buf, "    <console type='pty'>\n");
+        }
+        virBufferAddLit(&buf, "      <target port='0'/>\n");
+        virBufferAddLit(&buf, "    </console>\n");
     }
+    free(tty);
 
     virBufferAddLit(&buf, "  </devices>\n");
     virBufferAddLit(&buf, "</domain>\n");
index e157e88b5e20329f663963fe37070b198f195bca..d56d73d60dc2e39bcc4f393ae3afff2de38ef31e 100644 (file)
 
 #include "libvirt/libvirt.h"
 #include "capabilities.h"
+#include "buf.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-
 /**
  * \brief Setup the connection to a xend instance via TCP
  * \param host The host name to connect to
@@ -180,6 +180,13 @@ char *xenDaemonDomainDumpXMLByName(virConnectPtr xend,
  */
     int xend_log(virConnectPtr xend, char *buffer, size_t n_buffer);
 
+    int xend_parse_sexp_desc_char(virConnectPtr conn,
+                                  virBufferPtr buf,
+                                  const char *devtype,
+                                  int portNum,
+                                  const char *value,
+                                  const char *tty);
+
   char *xend_parse_domain_sexp(virConnectPtr conn,  char *root, int xendConfigVersion);
 
 /* refactored ones */
index 3d845dcd57c9ca9343e9a1fb43db0bbf40d69da9..811a62bdee55d39d393c7fcdc1bfa6b04ffcd17f 100644 (file)
@@ -1025,11 +1025,22 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
     }
 
     if (hvm) {
-        if (xenXMConfigGetString(conf, "serial", &str) == 0 && !strcmp(str, "pty")) {
-            virBufferAddLit(buf, "    <console/>\n");
+        if (xenXMConfigGetString(conf, "parallel", &str) == 0) {
+            if (STRNEQ(str, "none"))
+                xend_parse_sexp_desc_char(conn, buf, "parallel", 0, str, NULL);
         }
-    } else { /* Paravirt implicitly always has a console */
-        virBufferAddLit(buf, "    <console/>\n");
+        if (xenXMConfigGetString(conf, "serial", &str) == 0) {
+            if (STRNEQ(str, "none")) {
+                xend_parse_sexp_desc_char(conn, buf, "serial", 0, str, NULL);
+                /* Add back-compat console tag for primary console */
+                xend_parse_sexp_desc_char(conn, buf, "console", 0, str, NULL);
+            }
+        }
+    } else {
+        /* Paravirt implicitly always has a single console */
+        virBufferAddLit(buf, "    <console type='pty'>\n");
+        virBufferAddLit(buf, "      <target port='0'/>\n");
+        virBufferAddLit(buf, "    </console>\n");
     }
 
     virBufferAddLit(buf, "  </devices>\n");
@@ -2267,14 +2278,38 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
     obj = NULL;
 
     if (hvm) {
-        obj = xmlXPathEval(BAD_CAST "count(/domain/devices/console) > 0", ctxt);
-        if ((obj != NULL) && (obj->type == XPATH_BOOLEAN) &&
-            (obj->boolval)) {
-            if (xenXMConfigSetString(conf, "serial", "pty") < 0)
+        xmlNodePtr cur;
+        cur = virXPathNode("/domain/devices/parallel[1]", ctxt);
+        if (cur != NULL) {
+            char scratch[PATH_MAX];
+
+            if (virDomainParseXMLOSDescHVMChar(conn, scratch, sizeof(scratch), cur) < 0) {
+                goto error;
+            }
+
+            if (xenXMConfigSetString(conf, "parallel", scratch) < 0)
+                goto error;
+        } else {
+            if (xenXMConfigSetString(conf, "parallel", "none") < 0)
                 goto error;
         }
-        xmlXPathFreeObject(obj);
-        obj = NULL;
+
+        cur = virXPathNode("/domain/devices/serial[1]", ctxt);
+        if (cur != NULL) {
+            char scratch[PATH_MAX];
+            if (virDomainParseXMLOSDescHVMChar(conn, scratch, sizeof(scratch), cur) < 0)
+                goto error;
+            if (xenXMConfigSetString(conf, "serial", scratch) < 0)
+                goto error;
+        } else {
+            if (virXPathBoolean("count(/domain/devices/console) > 0", ctxt)) {
+                if (xenXMConfigSetString(conf, "serial", "pty") < 0)
+                    goto error;
+            } else {
+                if (xenXMConfigSetString(conf, "serial", "none") < 0)
+                    goto error;
+            }
+        }
     }
 
     xmlFreeDoc(doc);
index 8e95103b196edce7880a9dbd7a9b3656237be0b0..ceea9872193457677c314c1a57c9277f4c06918c 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -673,6 +673,178 @@ virDomainParseXMLGraphicsDescVFB(virConnectPtr conn ATTRIBUTE_UNUSED,
 }
 
 
+int
+virDomainParseXMLOSDescHVMChar(virConnectPtr conn,
+                               char *buf,
+                               size_t buflen,
+                               xmlNodePtr node)
+{
+    xmlChar *type = NULL;
+    xmlChar *path = NULL;
+    xmlChar *bindHost = NULL;
+    xmlChar *bindService = NULL;
+    xmlChar *connectHost = NULL;
+    xmlChar *connectService = NULL;
+    xmlChar *mode = NULL;
+    xmlChar *protocol = NULL;
+    xmlNodePtr cur;
+
+    type = xmlGetProp(node, BAD_CAST "type");
+
+    if (type != NULL) {
+        cur = node->children;
+        while (cur != NULL) {
+            if (cur->type == XML_ELEMENT_NODE) {
+                if (xmlStrEqual(cur->name, BAD_CAST "source")) {
+                    if (mode == NULL)
+                        mode = xmlGetProp(cur, BAD_CAST "mode");
+
+                    if (STREQ((const char *)type, "dev") ||
+                        STREQ((const char *)type, "file") ||
+                        STREQ((const char *)type, "pipe") ||
+                        STREQ((const char *)type, "unix")) {
+                        if (path == NULL)
+                            path = xmlGetProp(cur, BAD_CAST "path");
+
+                    } else if (STREQ((const char *)type, "udp") ||
+                               STREQ((const char *)type, "tcp")) {
+                        if (mode == NULL ||
+                            STREQ((const char *)mode, "connect")) {
+
+                            if (connectHost == NULL)
+                                connectHost = xmlGetProp(cur, BAD_CAST "host");
+                            if (connectService == NULL)
+                                connectService = xmlGetProp(cur, BAD_CAST "service");
+                        } else {
+                            if (bindHost == NULL)
+                                bindHost = xmlGetProp(cur, BAD_CAST "host");
+                            if (bindService == NULL)
+                                bindService = xmlGetProp(cur, BAD_CAST "service");
+                        }
+
+                        if (STREQ((const char*)type, "udp")) {
+                            xmlFree(mode);
+                            mode = NULL;
+                        }
+                    }
+                } else if (xmlStrEqual(cur->name, BAD_CAST "protocol")) {
+                    if (protocol == NULL)
+                        protocol = xmlGetProp(cur, BAD_CAST "type");
+                }
+            }
+            cur = cur->next;
+        }
+    }
+
+    if (type == NULL ||
+        STREQ((const char *)type, "pty")) {
+        strncpy(buf, "pty", buflen);
+    } else if (STREQ((const char *)type, "null") ||
+               STREQ((const char *)type, "stdio") ||
+               STREQ((const char *)type, "vc")) {
+        snprintf(buf, buflen, "%s", type);
+    } else if (STREQ((const char *)type, "file") ||
+               STREQ((const char *)type, "dev") ||
+               STREQ((const char *)type, "pipe")) {
+        if (path == NULL) {
+            virXMLError(conn, VIR_ERR_XML_ERROR,
+                        _("Missing source path attribute for char device"), 0);
+            goto cleanup;
+        }
+
+        if (STREQ((const char *)type, "dev"))
+            strncpy(buf, (const char *)path, buflen);
+        else
+            snprintf(buf, buflen, "%s:%s", type, path);
+    } else if (STREQ((const char *)type, "tcp")) {
+        int telnet = 0;
+        if (protocol != NULL &&
+            STREQ((const char *)protocol, "telnet"))
+            telnet = 1;
+
+        if (mode == NULL ||
+            STREQ((const char *)mode, "connect")) {
+            if (connectHost == NULL) {
+                virXMLError(conn, VIR_ERR_INTERNAL_ERROR,
+                            _("Missing source host attribute for char device"), 0);
+                goto cleanup;
+            }
+            if (connectService == NULL) {
+                virXMLError(conn, VIR_ERR_INTERNAL_ERROR,
+                            _("Missing source service attribute for char device"), 0);
+                goto cleanup;
+            }
+
+            snprintf(buf, buflen, "%s:%s:%s",
+                     (telnet ? "telnet" : "tcp"),
+                     connectHost, connectService);
+        } else {
+            if (bindHost == NULL) {
+                virXMLError(conn, VIR_ERR_INTERNAL_ERROR,
+                            _("Missing source host attribute for char device"), 0);
+                goto cleanup;
+            }
+            if (bindService == NULL) {
+                virXMLError(conn, VIR_ERR_INTERNAL_ERROR,
+                            _("Missing source service attribute for char device"), 0);
+                goto cleanup;
+            }
+
+            snprintf(buf, buflen, "%s:%s:%s,listen",
+                     (telnet ? "telnet" : "tcp"),
+                     bindHost, bindService);
+        }
+    } else if (STREQ((const char *)type, "udp")) {
+        if (connectService == NULL) {
+            virXMLError(conn, VIR_ERR_XML_ERROR,
+                        _("Missing source service attribute for char device"), 0);
+            goto cleanup;
+        }
+
+        snprintf(buf, buflen, "udp:%s:%s@%s:%s",
+                 connectHost ? (const char *)connectHost : "",
+                 connectService,
+                 bindHost ? (const char *)bindHost : "",
+                 bindService ? (const char *)bindService : "");
+    } else if (STREQ((const char *)type, "unix")) {
+        if (path == NULL) {
+            virXMLError(conn, VIR_ERR_XML_ERROR,
+                        _("Missing source path attribute for char device"), 0);
+            goto cleanup;
+        }
+
+        if (mode == NULL ||
+            STREQ((const char *)mode, "connect")) {
+            snprintf(buf, buflen, "%s:%s", type, path);
+        } else {
+            snprintf(buf, buflen, "%s:%s,listen", type, path);
+        }
+    }
+    buf[buflen-1] = '\0';
+
+    xmlFree(mode);
+    xmlFree(protocol);
+    xmlFree(type);
+    xmlFree(bindHost);
+    xmlFree(bindService);
+    xmlFree(connectHost);
+    xmlFree(connectService);
+    xmlFree(path);
+
+    return 0;
+
+cleanup:
+    xmlFree(mode);
+    xmlFree(protocol);
+    xmlFree(type);
+    xmlFree(bindHost);
+    xmlFree(bindService);
+    xmlFree(connectHost);
+    xmlFree(connectService);
+    xmlFree(path);
+    return -1;
+}
+
 /**
  * virDomainParseXMLOSDescHVM:
  * @conn: pointer to the hypervisor connection
@@ -877,24 +1049,53 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
         nodes = NULL;
     }
 
-
-    res = virXPathBoolean("count(domain/devices/console) > 0", ctxt);
-    if (res < 0) {
-        virXMLError(conn, VIR_ERR_XML_ERROR, NULL, 0);
-        goto error;
+    cur = virXPathNode("/domain/devices/parallel[1]", ctxt);
+    if (cur != NULL) {
+        char scratch[PATH_MAX];
+        if (virDomainParseXMLOSDescHVMChar(conn, scratch, sizeof(scratch), cur) < 0)
+            goto error;
+        if (virBufferVSprintf(buf, "(parallel %s)", scratch) < 0)
+            goto no_memory;
+    } else {
+        if (virBufferAddLit(buf, "(parallel none)") < 0)
+            goto no_memory;
     }
-    if (res) {
-        virBufferAddLit(buf, "(serial pty)");
+
+    cur = virXPathNode("/domain/devices/serial[1]", ctxt);
+    if (cur != NULL) {
+        char scratch[PATH_MAX];
+        if (virDomainParseXMLOSDescHVMChar(conn, scratch, sizeof(scratch), cur) < 0)
+            goto error;
+        if (virBufferVSprintf(buf, "(serial %s)", scratch) < 0)
+            goto no_memory;
+    } else {
+        res = virXPathBoolean("count(domain/devices/console) > 0", ctxt);
+        if (res < 0) {
+            virXMLError(conn, VIR_ERR_XML_ERROR, NULL, 0);
+            goto error;
+        }
+        if (res) {
+            if (virBufferAddLit(buf, "(serial pty)") < 0)
+                goto no_memory;
+        } else {
+            if (virBufferAddLit(buf, "(serial none)") < 0)
+                goto no_memory;
+        }
     }
 
     str = virXPathString("string(/domain/clock/@offset)", ctxt);
     if (str != NULL && !strcmp(str, "localtime")) {
-        virBufferAddLit(buf, "(localtime 1)");
+        if (virBufferAddLit(buf, "(localtime 1)") < 0)
+            goto no_memory;
     }
     free(str);
 
     return (0);
 
+no_memory:
+    virXMLError(conn, VIR_ERR_XML_ERROR,
+                _("cannot allocate memory for buffer"), 0);
+
   error:
     free(nodes);
     return (-1);
index 2d30b6576f71e4cb1026c3f7002408201e3f73a5..d91a1b0e7ba4044acb2b3130d5717cf145f7a48a 100644 (file)
--- a/src/xml.h
+++ b/src/xml.h
@@ -44,6 +44,10 @@ char *          virSaveCpuSet        (virConnectPtr conn,
 char *         virConvertCpuSet(virConnectPtr conn,
                                  const char *str,
                                  int maxcpu);
+int             virDomainParseXMLOSDescHVMChar(virConnectPtr conn,
+                                               char *buf,
+                                               size_t buflen,
+                                               xmlNodePtr node);
 char *         virDomainParseXMLDesc(virConnectPtr conn,
                                  const char *xmldesc,
                                  char **name,
index 15853cd82738de93891bd2a3a19a2dd57213b021..a609f97e833fd42fe7433676d9f21e0543ae7935 100644 (file)
@@ -28,5 +28,8 @@
     </disk>
     <input type='mouse' bus='xen'/>
     <graphics type='vnc' port='5905'/>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index 9c2f19dcc926cb531e6608a0d82f734e83b5066c..35735399f1e5dd9f96c8e00f0aad4180101bb306 100644 (file)
@@ -21,5 +21,8 @@
       <mac address='00:16:3e:23:9e:eb'/>
       <script path='vif-bridge'/>
     </interface>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index a6d54661a11ef4e98833b4d933810a2bb53c74fe..0bcf58390204b7c30fe60adeb471b89e06b028ea 100644 (file)
@@ -18,5 +18,8 @@
       <source dev='/dev/MainVG/GuestVG'/>
       <target dev='xvda'/>
     </disk>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index af2ae7b2547061a591a0d17d4e0ff605ba417d63..a0e139587bf37f0e8133fb6ee4a8204fc9388fe3 100644 (file)
@@ -18,5 +18,8 @@
       <source file='/root/some.img'/>
       <target dev='xvda'/>
     </disk>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index 1cb4a3978e338ffc09b3d9c3d84bb2f9d1460f68..f16f1cc8d62e9a1118e0c1e8187d6ab9e70f9455 100644 (file)
@@ -18,5 +18,8 @@
       <source file='/root/some.img'/>
       <target dev='xvda'/>
     </disk>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index 8c3603647e1aa9f8a9725ae704cfe06d484b2281..e0841aa8b85c596a6cce7910ee33a4709582ccd6 100644 (file)
@@ -18,5 +18,8 @@
       <source file='/root/some.img'/>
       <target dev='xvda'/>
     </disk>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index 7faeeff82327d607f64cd6f08a8363a25e4b8dbe..96ce59d16129ec164a9a32f0e0d0a05f3fe671ec 100644 (file)
       <source file='/root/some.img'/>
       <target dev='xvda'/>
     </disk>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.sexpr
new file mode 100644 (file)
index 0000000..104f979
--- /dev/null
@@ -0,0 +1 @@
+(domain (domid 1)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel tcp:localhost:9999)(serial none)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml b/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml
new file mode 100644 (file)
index 0000000..7bab9c6
--- /dev/null
@@ -0,0 +1,45 @@
+<domain type='xen' id='1'>
+  <name>fvtest</name>
+  <uuid>b5d70dd2-75cd-aca5-1776-9660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <clock offset='utc'/>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <disk type='file' device='disk'>
+      <driver name='file'/>
+      <source file='/root/foo.img'/>
+      <target dev='hda'/>
+    </disk>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <target dev='vif1.0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='5901'/>
+    <parallel type='tcp'>
+      <source mode='connect' host='localhost' service='9999'/>
+      <protocol type='raw'/>
+      <target port='0'/>
+    </parallel>
+  </devices>
+</domain>
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.sexpr
new file mode 100644 (file)
index 0000000..28c4346
--- /dev/null
@@ -0,0 +1 @@
+(domain (domid 1)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial file:/tmp/serial.log)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml
new file mode 100644 (file)
index 0000000..2a55b2a
--- /dev/null
@@ -0,0 +1,48 @@
+<domain type='xen' id='1'>
+  <name>fvtest</name>
+  <uuid>b5d70dd2-75cd-aca5-1776-9660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <clock offset='utc'/>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <disk type='file' device='disk'>
+      <driver name='file'/>
+      <source file='/root/foo.img'/>
+      <target dev='hda'/>
+    </disk>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <target dev='vif1.0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='5901'/>
+    <serial type='file'>
+      <source path='/tmp/serial.log'/>
+      <target port='0'/>
+    </serial>
+    <console type='file'>
+      <source path='/tmp/serial.log'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.sexpr
new file mode 100644 (file)
index 0000000..a87c493
--- /dev/null
@@ -0,0 +1 @@
+(domain (domid 1)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial null)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml
new file mode 100644 (file)
index 0000000..76fa8bf
--- /dev/null
@@ -0,0 +1,46 @@
+<domain type='xen' id='1'>
+  <name>fvtest</name>
+  <uuid>b5d70dd2-75cd-aca5-1776-9660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <clock offset='utc'/>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <disk type='file' device='disk'>
+      <driver name='file'/>
+      <source file='/root/foo.img'/>
+      <target dev='hda'/>
+    </disk>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <target dev='vif1.0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='5901'/>
+    <serial type='null'>
+      <target port='0'/>
+    </serial>
+    <console type='null'>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.sexpr
new file mode 100644 (file)
index 0000000..11a7952
--- /dev/null
@@ -0,0 +1 @@
+(domain (domid 1)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial pipe:/tmp/serial.pipe)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml
new file mode 100644 (file)
index 0000000..e2dbd14
--- /dev/null
@@ -0,0 +1,48 @@
+<domain type='xen' id='1'>
+  <name>fvtest</name>
+  <uuid>b5d70dd2-75cd-aca5-1776-9660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <clock offset='utc'/>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <disk type='file' device='disk'>
+      <driver name='file'/>
+      <source file='/root/foo.img'/>
+      <target dev='hda'/>
+    </disk>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <target dev='vif1.0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='5901'/>
+    <serial type='pipe'>
+      <source path='/tmp/serial.pipe'/>
+      <target port='0'/>
+    </serial>
+    <console type='pipe'>
+      <source path='/tmp/serial.pipe'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.sexpr
new file mode 100644 (file)
index 0000000..0ef0576
--- /dev/null
@@ -0,0 +1 @@
+(domain (domid 1)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial pty)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml
new file mode 100644 (file)
index 0000000..34b9488
--- /dev/null
@@ -0,0 +1,46 @@
+<domain type='xen' id='1'>
+  <name>fvtest</name>
+  <uuid>b5d70dd2-75cd-aca5-1776-9660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <clock offset='utc'/>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <disk type='file' device='disk'>
+      <driver name='file'/>
+      <source file='/root/foo.img'/>
+      <target dev='hda'/>
+    </disk>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <target dev='vif1.0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='5901'/>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.sexpr
new file mode 100644 (file)
index 0000000..58e223c
--- /dev/null
@@ -0,0 +1 @@
+(domain (domid 1)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial stdio)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml
new file mode 100644 (file)
index 0000000..1ed205e
--- /dev/null
@@ -0,0 +1,46 @@
+<domain type='xen' id='1'>
+  <name>fvtest</name>
+  <uuid>b5d70dd2-75cd-aca5-1776-9660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <clock offset='utc'/>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <disk type='file' device='disk'>
+      <driver name='file'/>
+      <source file='/root/foo.img'/>
+      <target dev='hda'/>
+    </disk>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <target dev='vif1.0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='5901'/>
+    <serial type='stdio'>
+      <target port='0'/>
+    </serial>
+    <console type='stdio'>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.sexpr
new file mode 100644 (file)
index 0000000..605f3c8
--- /dev/null
@@ -0,0 +1 @@
+(domain (domid 1)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial telnet:localhost:9999,listen)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml
new file mode 100644 (file)
index 0000000..764ec82
--- /dev/null
@@ -0,0 +1,50 @@
+<domain type='xen' id='1'>
+  <name>fvtest</name>
+  <uuid>b5d70dd2-75cd-aca5-1776-9660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <clock offset='utc'/>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <disk type='file' device='disk'>
+      <driver name='file'/>
+      <source file='/root/foo.img'/>
+      <target dev='hda'/>
+    </disk>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <target dev='vif1.0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='5901'/>
+    <serial type='tcp'>
+      <source mode='bind' host='localhost' service='9999'/>
+      <protocol type='telnet'/>
+      <target port='0'/>
+    </serial>
+    <console type='tcp'>
+      <source mode='bind' host='localhost' service='9999'/>
+      <protocol type='telnet'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.sexpr
new file mode 100644 (file)
index 0000000..aa20310
--- /dev/null
@@ -0,0 +1 @@
+(domain (domid 1)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial tcp:localhost:9999,listen)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml
new file mode 100644 (file)
index 0000000..940092f
--- /dev/null
@@ -0,0 +1,50 @@
+<domain type='xen' id='1'>
+  <name>fvtest</name>
+  <uuid>b5d70dd2-75cd-aca5-1776-9660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <clock offset='utc'/>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <disk type='file' device='disk'>
+      <driver name='file'/>
+      <source file='/root/foo.img'/>
+      <target dev='hda'/>
+    </disk>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <target dev='vif1.0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='5901'/>
+    <serial type='tcp'>
+      <source mode='bind' host='localhost' service='9999'/>
+      <protocol type='raw'/>
+      <target port='0'/>
+    </serial>
+    <console type='tcp'>
+      <source mode='bind' host='localhost' service='9999'/>
+      <protocol type='raw'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.sexpr
new file mode 100644 (file)
index 0000000..f07dc4e
--- /dev/null
@@ -0,0 +1 @@
+(domain (domid 1)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial udp:localhost:9998@localhost:9999)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml
new file mode 100644 (file)
index 0000000..672892a
--- /dev/null
@@ -0,0 +1,50 @@
+<domain type='xen' id='1'>
+  <name>fvtest</name>
+  <uuid>b5d70dd2-75cd-aca5-1776-9660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <clock offset='utc'/>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <disk type='file' device='disk'>
+      <driver name='file'/>
+      <source file='/root/foo.img'/>
+      <target dev='hda'/>
+    </disk>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <target dev='vif1.0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='5901'/>
+    <serial type='udp'>
+      <source mode='connect' host='localhost' service='9998'/>
+      <source mode='bind' host='localhost' service='9999'/>
+      <target port='0'/>
+    </serial>
+    <console type='udp'>
+      <source mode='connect' host='localhost' service='9998'/>
+      <source mode='bind' host='localhost' service='9999'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.sexpr
new file mode 100644 (file)
index 0000000..3825ab7
--- /dev/null
@@ -0,0 +1 @@
+(domain (domid 1)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial unix:/tmp/serial.sock,listen)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml
new file mode 100644 (file)
index 0000000..ea6b10f
--- /dev/null
@@ -0,0 +1,48 @@
+<domain type='xen' id='1'>
+  <name>fvtest</name>
+  <uuid>b5d70dd2-75cd-aca5-1776-9660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <clock offset='utc'/>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <disk type='file' device='disk'>
+      <driver name='file'/>
+      <source file='/root/foo.img'/>
+      <target dev='hda'/>
+    </disk>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <target dev='vif1.0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='5901'/>
+    <serial type='unix'>
+      <source mode='bind' path='/tmp/serial.sock'/>
+      <target port='0'/>
+    </serial>
+    <console type='unix'>
+      <source mode='bind' path='/tmp/serial.sock'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
index 26d7badb01168fe8890ccd66602d3aec23201b4b..d4a5db74ea875c4477ad36c14764ad941855372f 100644 (file)
@@ -24,5 +24,8 @@
       <mac address='00:11:22:33:44:55'/>
       <script path='vif-bridge'/>
     </interface>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index 74dad9f535ce80c8657bf306ee8c5f9053e3a9e4..6f5c6b6e3af6289cb6894aec62ee393376d4e47c 100644 (file)
@@ -24,5 +24,8 @@
       <ip address='172.14.5.6'/>
       <script path='vif-routed'/>
     </interface>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index 429474aff26103adfc2326b1afc3592fbdf09fbc..bc4f2eab27e12b1e9eed37c2e3b7f15089142450 100644 (file)
     </disk>
     <input type='mouse' bus='ps2'/>
     <graphics type='vnc' port='5906'/>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index 9ee542dd4729843e698f5c953760ec7ab14d2b8e..7bf3190521c1d739362edbb00f11dc76579b11a4 100644 (file)
@@ -14,5 +14,8 @@
       <source file='/root/some.img'/>
       <target dev='xvda'/>
     </disk>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index a8b61eb5c9cad23da3f0b5c3ce394ab92daa5d7a..cd9da037d669bcf5bea87992f2d677084804d826 100644 (file)
@@ -20,5 +20,8 @@
     </disk>
     <input type='mouse' bus='xen'/>
     <graphics type='vnc' port='-1' listen='0.0.0.0' keymap='ja'/>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index a8b61eb5c9cad23da3f0b5c3ce394ab92daa5d7a..cd9da037d669bcf5bea87992f2d677084804d826 100644 (file)
@@ -20,5 +20,8 @@
     </disk>
     <input type='mouse' bus='xen'/>
     <graphics type='vnc' port='-1' listen='0.0.0.0' keymap='ja'/>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index 8c3603647e1aa9f8a9725ae704cfe06d484b2281..e0841aa8b85c596a6cce7910ee33a4709582ccd6 100644 (file)
@@ -18,5 +18,8 @@
       <source file='/root/some.img'/>
       <target dev='xvda'/>
     </disk>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index 576ea98800556b5c6e301995f8c421a20906ffac..0ec3155329e52dfe1d370c5819c4ec9920114ae8 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
 
 #ifdef WITH_XEN
 
 #include "testutils.h"
 
 static char *progname;
-static char *abs_top_srcdir;
+static char *abs_srcdir;
 
 #define MAX_FILE 4096
 
-static int testCompareFiles(const char *xml_rel, const char *sexpr_rel,
+static int testCompareFiles(const char *xml, const char *sexpr,
                             int xendConfigVersion) {
   char xmlData[MAX_FILE];
   char sexprData[MAX_FILE];
@@ -23,28 +24,23 @@ static int testCompareFiles(const char *xml_rel, const char *sexpr_rel,
   char *xmlPtr = &(xmlData[0]);
   char *sexprPtr = &(sexprData[0]);
   int ret = -1;
-  char xml[PATH_MAX];
-  char sexpr[PATH_MAX];
 
-  snprintf(xml, sizeof xml - 1, "%s/tests/%s", abs_top_srcdir, xml_rel);
-  snprintf(sexpr, sizeof sexpr - 1, "%s/tests/%s", abs_top_srcdir, sexpr_rel);
-
-  if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
-    goto fail;
+  if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0) {
+      printf("Missing %s\n", xml);
+      goto fail;
+  }
 
-  if (virtTestLoadFile(sexpr, &sexprPtr, MAX_FILE) < 0)
-    goto fail;
+  if (virtTestLoadFile(sexpr, &sexprPtr, MAX_FILE) < 0) {
+      printf("Missing %s\n", sexpr);
+      goto fail;
+  }
 
   if (!(gotxml = xend_parse_domain_sexp(NULL, sexprData, xendConfigVersion)))
     goto fail;
 
-  if (strcmp(xmlData, gotxml)) {
-    if (getenv("DEBUG_TESTS")) {
-        printf("In test file %s -> %s:\n", sexpr, xml);
-        printf("Expect %d '%s'\n", (int)strlen(xmlData), xmlData);
-        printf("Actual %d '%s'\n", (int)strlen(gotxml), gotxml);
-    }
-    goto fail;
+  if (STRNEQ(xmlData, gotxml)) {
+      virtTestDifference(stderr, xmlData, gotxml);
+      goto fail;
   }
 
   ret = 0;
@@ -55,139 +51,21 @@ static int testCompareFiles(const char *xml_rel, const char *sexpr_rel,
   return ret;
 }
 
-static int testComparePVversion1(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-pv.xml",
-                          "sexpr2xmldata/sexpr2xml-pv.sexpr",
-                          1);
-}
-
-static int testCompareFVversion1(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-fv.xml",
-                          "sexpr2xmldata/sexpr2xml-fv.sexpr",
-                          1);
-}
-
-static int testComparePVversion2(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-pv.xml",
-                          "sexpr2xmldata/sexpr2xml-pv.sexpr",
-                          2);
-}
-
-static int testComparePVOrigVFB(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml",
-                          "sexpr2xmldata/sexpr2xml-pv-vfb-orig.sexpr",
-                          2);
-}
-
-
-static int testComparePVNewVFB(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-pv-vfb-new.xml",
-                          "sexpr2xmldata/sexpr2xml-pv-vfb-new.sexpr",
-                          3);
-}
-
-
-static int testCompareFVversion2(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-v2.xml",
-                          "sexpr2xmldata/sexpr2xml-fv-v2.sexpr",
-                          2);
-}
-
-static int testComparePVBootloader(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-pv-bootloader.xml",
-                          "sexpr2xmldata/sexpr2xml-pv-bootloader.sexpr",
-                          2);
-}
-
-static int testCompareDiskFile(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-file.xml",
-                          "sexpr2xmldata/sexpr2xml-disk-file.sexpr",
-                          1);
-}
-
-static int testCompareDiskBlock(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-block.xml",
-                          "sexpr2xmldata/sexpr2xml-disk-block.sexpr",
-                          1);
-}
-
-static int testCompareDiskShareable(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-block-shareable.xml",
-                          "sexpr2xmldata/sexpr2xml-disk-block-shareable.sexpr",
-                          1);
-}
-
-static int testCompareDiskDrvBlktapQcow(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.xml",
-                          "sexpr2xmldata/sexpr2xml-disk-drv-blktap-qcow.sexpr",
-                          1);
-}
-
-static int testCompareDiskDrvBlktapRaw(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.xml",
-                          "sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.sexpr",
-                          1);
-}
-
-static int testCompareResizedMemory(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-curmem.xml",
-                          "sexpr2xmldata/sexpr2xml-curmem.sexpr",
-                          1);
-}
-
-
-static int testCompareNetRouted(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-net-routed.xml",
-                          "sexpr2xmldata/sexpr2xml-net-routed.sexpr",
-                          1);
-}
-
-static int testCompareNetBridged(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-net-bridged.xml",
-                          "sexpr2xmldata/sexpr2xml-net-bridged.sexpr",
-                          1);
-}
-
-static int testCompareNoSourceCDRom(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-no-source-cdrom.xml",
-                          "sexpr2xmldata/sexpr2xml-no-source-cdrom.sexpr",
-                          1);
-}
-
-static int testCompareFVInputUSBMouse(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-usbmouse.xml",
-                          "sexpr2xmldata/sexpr2xml-fv-usbmouse.sexpr",
-                          1);
-}
+struct testInfo {
+    const char *input;
+    const char *output;
+    int version;
+};
 
-static int testCompareFVInputUSBTablet(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-usbtablet.xml",
-                          "sexpr2xmldata/sexpr2xml-fv-usbtablet.sexpr",
-                          1);
-}
-
-static int testCompareFVclockUTC(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-utc.xml",
-                          "sexpr2xmldata/sexpr2xml-fv-utc.sexpr",
-                          1);
-}
-
-static int testCompareFVclockLocaltime(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-localtime.xml",
-                          "sexpr2xmldata/sexpr2xml-fv-localtime.sexpr",
-                          1);
-}
-
-static int testCompareFVKernel(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-kernel.xml",
-                          "sexpr2xmldata/sexpr2xml-fv-kernel.sexpr",
-                          1);
-}
-
-static int testCompareFVLegacyVFB(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml",
-                          "sexpr2xmldata/sexpr2xml-fv-legacy-vfb.sexpr",
-                          4);
+static int testCompareHelper(const void *data) {
+    const struct testInfo *info = data;
+    char xml[PATH_MAX];
+    char args[PATH_MAX];
+    snprintf(xml, PATH_MAX, "%s/sexpr2xmldata/sexpr2xml-%s.xml",
+             abs_srcdir, info->input);
+    snprintf(args, PATH_MAX, "%s/sexpr2xmldata/sexpr2xml-%s.sexpr",
+             abs_srcdir, info->output);
+    return testCompareFiles(xml, args, info->version);
 }
 
 
@@ -195,6 +73,7 @@ int
 main(int argc, char **argv)
 {
     int ret = 0;
+    char cwd[PATH_MAX];
 
     progname = argv[0];
 
@@ -203,98 +82,58 @@ main(int argc, char **argv)
         exit(EXIT_FAILURE);
     }
 
-    abs_top_srcdir = getenv("abs_top_srcdir");
-    if (!abs_top_srcdir) {
-        fprintf(stderr, "missing enviroment variable abs_top_srcdir\n");
+    abs_srcdir = getenv("abs_srcdir");
+    if (!abs_srcdir)
+        abs_srcdir = getcwd(cwd, sizeof(cwd));
+
+    if (argc > 1) {
+        fprintf(stderr, "Usage: %s\n", progname);
         exit(EXIT_FAILURE);
     }
 
-    if (virtTestRun("SEXPR-2-XML PV config (version 1)",
-                    1, testComparePVversion1, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML FV config (version 1)",
-                    1, testCompareFVversion1, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML PV config (version 2)",
-                    1, testComparePVversion2, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML PV config (Orig VFB)",
-                    1, testComparePVOrigVFB, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML PV config (New VFB)",
-                    1, testComparePVNewVFB, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML FV config (version 2)",
-                    1, testCompareFVversion2, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML PV config bootloader",
-                    1, testComparePVBootloader, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML Disk File config",
-                    1, testCompareDiskFile, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML Disk Block config",
-                    1, testCompareDiskBlock, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML Disk Block shareable",
-                    1, testCompareDiskShareable, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML Disk Driver blktap qcow config",
-                    1, testCompareDiskDrvBlktapQcow, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML Disk Driver blktap raw config",
-                    1, testCompareDiskDrvBlktapRaw, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML Resized memory config",
-                    1, testCompareResizedMemory, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML net routed",
-                    1, testCompareNetRouted, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML net bridged",
-                    1, testCompareNetBridged, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML no source CDRom",
-                    1, testCompareNoSourceCDRom, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML USB Mouse",
-                    1, testCompareFVInputUSBMouse, NULL) != 0)
-        ret = -1;
-    if (virtTestRun("SEXPR-2-XML USB Tablet",
-                    1, testCompareFVInputUSBTablet, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML clock UTC",
-                    1, testCompareFVclockUTC, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML clock Localtime",
-                    1, testCompareFVclockLocaltime, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML FV kernel",
-                    1, testCompareFVKernel, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("SEXPR-2-XML FV legacy VFB",
-                    1, testCompareFVLegacyVFB, NULL) != 0)
-        ret = -1;
+#define DO_TEST(in, out, version)                                      \
+    do {                                                               \
+        struct testInfo info = { in, out, version };                   \
+        if (virtTestRun("Xen SEXPR-2-XML " in " -> " out,              \
+                        1, testCompareHelper, &info) < 0)              \
+            ret = -1;                                                  \
+    } while (0)
+
+    DO_TEST("pv", "pv", 1);
+    DO_TEST("fv", "fv", 1);
+    DO_TEST("pv", "pv", 2);
+    DO_TEST("fv-v2", "fv-v2", 2);
+    DO_TEST("pv-vfb-orig", "pv-vfb-orig", 2);
+    DO_TEST("pv-vfb-new", "pv-vfb-new", 3);
+    DO_TEST("pv-bootloader", "pv-bootloader", 1);
+
+    DO_TEST("disk-file", "disk-file", 2);
+    DO_TEST("disk-block", "disk-block", 2);
+    DO_TEST("disk-block-shareable", "disk-block-shareable", 2);
+    DO_TEST("disk-drv-blktap-raw", "disk-drv-blktap-raw", 2);
+    DO_TEST("disk-drv-blktap-qcow", "disk-drv-blktap-qcow", 2);
+
+    DO_TEST("curmem", "curmem", 1);
+    DO_TEST("net-routed", "net-routed", 2);
+    DO_TEST("net-bridged", "net-bridged", 2);
+    DO_TEST("no-source-cdrom", "no-source-cdrom", 1);
+
+    DO_TEST("fv-utc", "fv-utc", 1);
+    DO_TEST("fv-localtime", "fv-localtime", 1);
+    DO_TEST("fv-usbmouse", "fv-usbmouse", 1);
+    DO_TEST("fv-usbmouse", "fv-usbmouse", 1);
+    DO_TEST("fv-kernel", "fv-kernel", 1);
+
+    DO_TEST("fv-serial-null", "fv-serial-null", 1);
+    DO_TEST("fv-serial-file", "fv-serial-file", 1);
+    DO_TEST("fv-serial-stdio", "fv-serial-stdio", 1);
+    DO_TEST("fv-serial-pty", "fv-serial-pty", 1);
+    DO_TEST("fv-serial-pipe", "fv-serial-pipe", 1);
+    DO_TEST("fv-serial-tcp", "fv-serial-tcp", 1);
+    DO_TEST("fv-serial-udp", "fv-serial-udp", 1);
+    DO_TEST("fv-serial-tcp-telnet", "fv-serial-tcp-telnet", 1);
+    DO_TEST("fv-serial-unix", "fv-serial-unix", 1);
+    DO_TEST("fv-parallel-tcp", "fv-parallel-tcp", 1);
 
     exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
 }
index 18165a542689390473072547de7be09d13429fc3..f0acaf652f1a376e8e2ec7e2d67c9db3c4cfd37e 100755 (executable)
@@ -21,3 +21,5 @@ 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" ]
+parallel = "none"
+serial = "none"
index 2777535d1898d31c915fa1e6681521bf8da0f57a..01bb7cc52868c0bf425ff5c268e2a1479e1c4efb 100755 (executable)
@@ -21,3 +21,5 @@ 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" ]
+parallel = "none"
+serial = "none"
index 2f2cc361f595bf41c84e2a533e053132bd185abd..c6eee8fa43c9c3abac0296323e6113a8b85edb43 100755 (executable)
@@ -22,3 +22,5 @@ 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" ]
+parallel = "none"
+serial = "none"
diff --git a/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg b/tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg
new file mode 100755 (executable)
index 0000000..a03fdc7
--- /dev/null
@@ -0,0 +1,25 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+builder = "hvm"
+kernel = "/usr/lib/xen/boot/hvmloader"
+boot = "d"
+pae = 1
+acpi = 1
+apic = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-dm"
+sdl = 0
+vnc = 1
+vncunused = 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" ]
+parallel = "tcp:127.0.0.1:7777"
+serial = "none"
diff --git a/tests/xmconfigdata/test-fullvirt-parallel-tcp.xml b/tests/xmconfigdata/test-fullvirt-parallel-tcp.xml
new file mode 100644 (file)
index 0000000..b2eb903
--- /dev/null
@@ -0,0 +1,46 @@
+<domain type='xen'>
+  <name>XenGuest2</name>
+  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='cdrom'/>
+  </os>
+  <currentMemory>403456</currentMemory>
+  <memory>592896</memory>
+  <vcpu>1</vcpu>
+  <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'>
+      <driver name='phy'/>
+      <source dev='/dev/HostVG/XenGuest2'/>
+      <target dev='hda'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <interface type='bridge'>
+      <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>
+  </devices>
+</domain>
diff --git a/tests/xmconfigdata/test-fullvirt-serial-file.cfg b/tests/xmconfigdata/test-fullvirt-serial-file.cfg
new file mode 100755 (executable)
index 0000000..aed2481
--- /dev/null
@@ -0,0 +1,25 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+builder = "hvm"
+kernel = "/usr/lib/xen/boot/hvmloader"
+boot = "d"
+pae = 1
+acpi = 1
+apic = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-dm"
+sdl = 0
+vnc = 1
+vncunused = 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" ]
+parallel = "none"
+serial = "file:/tmp/serial.log"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-file.xml b/tests/xmconfigdata/test-fullvirt-serial-file.xml
new file mode 100644 (file)
index 0000000..dadfe39
--- /dev/null
@@ -0,0 +1,49 @@
+<domain type='xen'>
+  <name>XenGuest2</name>
+  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='cdrom'/>
+  </os>
+  <currentMemory>403456</currentMemory>
+  <memory>592896</memory>
+  <vcpu>1</vcpu>
+  <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'>
+      <driver name='phy'/>
+      <source dev='/dev/HostVG/XenGuest2'/>
+      <target dev='hda'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <interface type='bridge'>
+      <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'/>
+    </serial>
+    <console type='file'>
+      <source path='/tmp/serial.log'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/xmconfigdata/test-fullvirt-serial-null.cfg b/tests/xmconfigdata/test-fullvirt-serial-null.cfg
new file mode 100755 (executable)
index 0000000..eb37471
--- /dev/null
@@ -0,0 +1,25 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+builder = "hvm"
+kernel = "/usr/lib/xen/boot/hvmloader"
+boot = "d"
+pae = 1
+acpi = 1
+apic = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-dm"
+sdl = 0
+vnc = 1
+vncunused = 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" ]
+parallel = "none"
+serial = "null"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-null.xml b/tests/xmconfigdata/test-fullvirt-serial-null.xml
new file mode 100644 (file)
index 0000000..0ce1d56
--- /dev/null
@@ -0,0 +1,47 @@
+<domain type='xen'>
+  <name>XenGuest2</name>
+  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='cdrom'/>
+  </os>
+  <currentMemory>403456</currentMemory>
+  <memory>592896</memory>
+  <vcpu>1</vcpu>
+  <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'>
+      <driver name='phy'/>
+      <source dev='/dev/HostVG/XenGuest2'/>
+      <target dev='hda'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <interface type='bridge'>
+      <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>
+  </devices>
+</domain>
diff --git a/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg b/tests/xmconfigdata/test-fullvirt-serial-pipe.cfg
new file mode 100755 (executable)
index 0000000..2d50fee
--- /dev/null
@@ -0,0 +1,25 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+builder = "hvm"
+kernel = "/usr/lib/xen/boot/hvmloader"
+boot = "d"
+pae = 1
+acpi = 1
+apic = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-dm"
+sdl = 0
+vnc = 1
+vncunused = 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" ]
+parallel = "none"
+serial = "pipe:/tmp/serial.pipe"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-pipe.xml b/tests/xmconfigdata/test-fullvirt-serial-pipe.xml
new file mode 100644 (file)
index 0000000..2019892
--- /dev/null
@@ -0,0 +1,49 @@
+<domain type='xen'>
+  <name>XenGuest2</name>
+  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='cdrom'/>
+  </os>
+  <currentMemory>403456</currentMemory>
+  <memory>592896</memory>
+  <vcpu>1</vcpu>
+  <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'>
+      <driver name='phy'/>
+      <source dev='/dev/HostVG/XenGuest2'/>
+      <target dev='hda'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <interface type='bridge'>
+      <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'/>
+    </serial>
+    <console type='pipe'>
+      <source path='/tmp/serial.pipe'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/xmconfigdata/test-fullvirt-serial-pty.cfg b/tests/xmconfigdata/test-fullvirt-serial-pty.cfg
new file mode 100755 (executable)
index 0000000..509a7f2
--- /dev/null
@@ -0,0 +1,25 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+builder = "hvm"
+kernel = "/usr/lib/xen/boot/hvmloader"
+boot = "d"
+pae = 1
+acpi = 1
+apic = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-dm"
+sdl = 0
+vnc = 1
+vncunused = 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" ]
+parallel = "none"
+serial = "pty"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-pty.xml b/tests/xmconfigdata/test-fullvirt-serial-pty.xml
new file mode 100644 (file)
index 0000000..602a2c1
--- /dev/null
@@ -0,0 +1,47 @@
+<domain type='xen'>
+  <name>XenGuest2</name>
+  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='cdrom'/>
+  </os>
+  <currentMemory>403456</currentMemory>
+  <memory>592896</memory>
+  <vcpu>1</vcpu>
+  <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'>
+      <driver name='phy'/>
+      <source dev='/dev/HostVG/XenGuest2'/>
+      <target dev='hda'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <interface type='bridge'>
+      <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>
+  </devices>
+</domain>
diff --git a/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg b/tests/xmconfigdata/test-fullvirt-serial-stdio.cfg
new file mode 100755 (executable)
index 0000000..3bab00a
--- /dev/null
@@ -0,0 +1,25 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+builder = "hvm"
+kernel = "/usr/lib/xen/boot/hvmloader"
+boot = "d"
+pae = 1
+acpi = 1
+apic = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-dm"
+sdl = 0
+vnc = 1
+vncunused = 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" ]
+parallel = "none"
+serial = "stdio"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-stdio.xml b/tests/xmconfigdata/test-fullvirt-serial-stdio.xml
new file mode 100644 (file)
index 0000000..30ec87a
--- /dev/null
@@ -0,0 +1,47 @@
+<domain type='xen'>
+  <name>XenGuest2</name>
+  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='cdrom'/>
+  </os>
+  <currentMemory>403456</currentMemory>
+  <memory>592896</memory>
+  <vcpu>1</vcpu>
+  <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'>
+      <driver name='phy'/>
+      <source dev='/dev/HostVG/XenGuest2'/>
+      <target dev='hda'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <interface type='bridge'>
+      <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>
+  </devices>
+</domain>
diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.cfg
new file mode 100755 (executable)
index 0000000..ffe7f15
--- /dev/null
@@ -0,0 +1,25 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+builder = "hvm"
+kernel = "/usr/lib/xen/boot/hvmloader"
+boot = "d"
+pae = 1
+acpi = 1
+apic = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-dm"
+sdl = 0
+vnc = 1
+vncunused = 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" ]
+parallel = "none"
+serial = "telnet:127.0.0.1:9999,listen"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml
new file mode 100644 (file)
index 0000000..fb1de88
--- /dev/null
@@ -0,0 +1,51 @@
+<domain type='xen'>
+  <name>XenGuest2</name>
+  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='cdrom'/>
+  </os>
+  <currentMemory>403456</currentMemory>
+  <memory>592896</memory>
+  <vcpu>1</vcpu>
+  <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'>
+      <driver name='phy'/>
+      <source dev='/dev/HostVG/XenGuest2'/>
+      <target dev='hda'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <interface type='bridge'>
+      <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'/>
+      <target port='0'/>
+    </serial>
+    <console type='tcp'>
+      <source mode='bind' host='127.0.0.1' service='9999'/>
+      <protocol type='telnet'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg b/tests/xmconfigdata/test-fullvirt-serial-tcp.cfg
new file mode 100755 (executable)
index 0000000..00a4cfd
--- /dev/null
@@ -0,0 +1,25 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+builder = "hvm"
+kernel = "/usr/lib/xen/boot/hvmloader"
+boot = "d"
+pae = 1
+acpi = 1
+apic = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-dm"
+sdl = 0
+vnc = 1
+vncunused = 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" ]
+parallel = "none"
+serial = "tcp:127.0.0.1:7777"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp.xml b/tests/xmconfigdata/test-fullvirt-serial-tcp.xml
new file mode 100644 (file)
index 0000000..48682cb
--- /dev/null
@@ -0,0 +1,51 @@
+<domain type='xen'>
+  <name>XenGuest2</name>
+  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='cdrom'/>
+  </os>
+  <currentMemory>403456</currentMemory>
+  <memory>592896</memory>
+  <vcpu>1</vcpu>
+  <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'>
+      <driver name='phy'/>
+      <source dev='/dev/HostVG/XenGuest2'/>
+      <target dev='hda'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <interface type='bridge'>
+      <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'/>
+      <target port='0'/>
+    </serial>
+    <console type='tcp'>
+      <source mode='connect' host='127.0.0.1' service='7777'/>
+      <protocol type='raw'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/xmconfigdata/test-fullvirt-serial-udp.cfg b/tests/xmconfigdata/test-fullvirt-serial-udp.cfg
new file mode 100755 (executable)
index 0000000..8110e86
--- /dev/null
@@ -0,0 +1,25 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+builder = "hvm"
+kernel = "/usr/lib/xen/boot/hvmloader"
+boot = "d"
+pae = 1
+acpi = 1
+apic = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-dm"
+sdl = 0
+vnc = 1
+vncunused = 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" ]
+parallel = "none"
+serial = "udp:127.0.0.1:9999@0.0.0.0:99998"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-udp.xml b/tests/xmconfigdata/test-fullvirt-serial-udp.xml
new file mode 100644 (file)
index 0000000..2148d3d
--- /dev/null
@@ -0,0 +1,51 @@
+<domain type='xen'>
+  <name>XenGuest2</name>
+  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='cdrom'/>
+  </os>
+  <currentMemory>403456</currentMemory>
+  <memory>592896</memory>
+  <vcpu>1</vcpu>
+  <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'>
+      <driver name='phy'/>
+      <source dev='/dev/HostVG/XenGuest2'/>
+      <target dev='hda'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <interface type='bridge'>
+      <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='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='connect' host='127.0.0.1' service='9999'/>
+      <source mode='bind' host='0.0.0.0' service='99998'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/xmconfigdata/test-fullvirt-serial-unix.cfg b/tests/xmconfigdata/test-fullvirt-serial-unix.cfg
new file mode 100755 (executable)
index 0000000..17cb628
--- /dev/null
@@ -0,0 +1,25 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+builder = "hvm"
+kernel = "/usr/lib/xen/boot/hvmloader"
+boot = "d"
+pae = 1
+acpi = 1
+apic = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-dm"
+sdl = 0
+vnc = 1
+vncunused = 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" ]
+parallel = "none"
+serial = "unix:/tmp/serial.sock,listen"
diff --git a/tests/xmconfigdata/test-fullvirt-serial-unix.xml b/tests/xmconfigdata/test-fullvirt-serial-unix.xml
new file mode 100644 (file)
index 0000000..b34dfbf
--- /dev/null
@@ -0,0 +1,49 @@
+<domain type='xen'>
+  <name>XenGuest2</name>
+  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='cdrom'/>
+  </os>
+  <currentMemory>403456</currentMemory>
+  <memory>592896</memory>
+  <vcpu>1</vcpu>
+  <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'>
+      <driver name='phy'/>
+      <source dev='/dev/HostVG/XenGuest2'/>
+      <target dev='hda'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='file'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <interface type='bridge'>
+      <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'/>
+    </serial>
+    <console type='unix'>
+      <source mode='bind' path='/tmp/serial.sock'/>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
index b4e5f9b600beca5221f1dbad1e85c84a5b1136ee..96bba6edcbd90ddf259dec6656513861a337fd73 100755 (executable)
@@ -22,3 +22,5 @@ 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" ]
+parallel = "none"
+serial = "none"
index fa10c9aa813ae55ad22ead882e836f7ce669a5f2..ed90a04ffdf9df6afbd6a770b47b1c39206f9242 100755 (executable)
@@ -22,3 +22,5 @@ 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" ]
+parallel = "none"
+serial = "none"
index 2777535d1898d31c915fa1e6681521bf8da0f57a..01bb7cc52868c0bf425ff5c268e2a1479e1c4efb 100755 (executable)
@@ -21,3 +21,5 @@ 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" ]
+parallel = "none"
+serial = "none"
index 72a07f56ae59e9fa06c6e72f5b5fac72dfdec262..c114a4188e024d477d2f4ff388870bf4e853d84f 100644 (file)
@@ -20,6 +20,8 @@
     </interface>
     <input type='mouse' bus='xen'/>
     <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
-    <console/>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index 72a07f56ae59e9fa06c6e72f5b5fac72dfdec262..c114a4188e024d477d2f4ff388870bf4e853d84f 100644 (file)
@@ -20,6 +20,8 @@
     </interface>
     <input type='mouse' bus='xen'/>
     <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
-    <console/>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
   </devices>
 </domain>
index 569bc336e20bfb5d598c85dbc4419e380270e577..71b6830d5dcb9df6fb66b5f44cd86d1a44147c5d 100644 (file)
@@ -128,11 +128,8 @@ static int testCompareFormatXML(const char *xmcfg, const char *xml,
     if (!(gotxml = xenXMDomainFormatXML(conn, conf)))
         goto fail;
 
-    if (strcmp(xmlData, gotxml)) {
-        if (getenv("DEBUG_TESTS")) {
-            printf("Expect %d '%s'\n", (int)strlen(xmlData), xmlData);
-            printf("Actual %d '%s'\n", (int)strlen(gotxml), gotxml);
-        }
+    if (STRNEQ(xmlData, gotxml)) {
+        virtTestDifference(stderr, xmlData, gotxml);
         goto fail;
     }
 
@@ -211,6 +208,17 @@ main(int argc, char **argv)
     DO_TEST("fullvirt-localtime", 2);
     DO_TEST("fullvirt-usbtablet", 2);
     DO_TEST("fullvirt-usbmouse", 2);
+    DO_TEST("fullvirt-serial-file", 2);
+    DO_TEST("fullvirt-serial-null", 2);
+    DO_TEST("fullvirt-serial-pipe", 2);
+    DO_TEST("fullvirt-serial-pty", 2);
+    DO_TEST("fullvirt-serial-stdio", 2);
+    DO_TEST("fullvirt-serial-tcp", 2);
+    DO_TEST("fullvirt-serial-tcp-telnet", 2);
+    DO_TEST("fullvirt-serial-udp", 2);
+    DO_TEST("fullvirt-serial-unix", 2);
+
+    DO_TEST("fullvirt-parallel-tcp", 2);
 
     exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
 }
index b42361f150e514b3c6504b83fc111fdf0a9322a9..bcb1816c76c28af79ea6ab9cd09eae0588c33905 100644 (file)
@@ -1 +1 @@
-(vm (name 'fvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (hvm (kernel '/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk '/var/lib/xen/initrd.img.0u-Vhq')(args ' method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os  ')(loader '/usr/lib/xen/boot/hvmloader')(vcpus 2)(boot c)(usb 1)(serial pty)))(device (vbd (dev 'ioemu:xvda')(uname 'file:/root/some.img')(mode 'w'))))
\ No newline at end of file
+(vm (name 'fvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (hvm (kernel '/var/lib/xen/vmlinuz.2Dn2YT')(ramdisk '/var/lib/xen/initrd.img.0u-Vhq')(args ' method=http://download.fedora.devel.redhat.com/pub/fedora/linux/core/test/5.91/x86_64/os  ')(loader '/usr/lib/xen/boot/hvmloader')(vcpus 2)(boot c)(usb 1)(parallel none)(serial pty)))(device (vbd (dev 'ioemu:xvda')(uname 'file:/root/some.img')(mode 'w'))))
\ No newline at end of file
index a2f170ebe8e3211b79622d6613c1629614e3c23e..01c911c358354bc2bf7e10659b6c80ef4b9c4d2b 100644 (file)
@@ -1 +1 @@
-(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(localtime 1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial none)(localtime 1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-parallel-tcp.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-parallel-tcp.sexpr
new file mode 100644 (file)
index 0000000..6bc6524
--- /dev/null
@@ -0,0 +1 @@
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel tcp:localhost:9999)(serial none)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-parallel-tcp.xml b/tests/xml2sexprdata/xml2sexpr-fv-parallel-tcp.xml
new file mode 100644 (file)
index 0000000..7b1370e
--- /dev/null
@@ -0,0 +1,40 @@
+<domain type='xen'>
+  <name>fvtest</name>
+  <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <disk type='file'>
+      <source file='/root/foo.img'/>
+      <target dev='ioemu:hda'/>
+    </disk>
+    <parallel type='tcp'>
+      <source mode='connect' host='localhost' service='9999' wiremode='raw'/>
+      <target port='0'/>
+    </parallel>
+    <graphics type='vnc' port='5917' keymap='ja'/>
+  </devices>
+</domain>
+
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-file.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-serial-file.sexpr
new file mode 100644 (file)
index 0000000..4a41abf
--- /dev/null
@@ -0,0 +1 @@
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial file:/tmp/serial.log)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-file.xml b/tests/xml2sexprdata/xml2sexpr-fv-serial-file.xml
new file mode 100644 (file)
index 0000000..77874ac
--- /dev/null
@@ -0,0 +1,40 @@
+<domain type='xen'>
+  <name>fvtest</name>
+  <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <disk type='file'>
+      <source file='/root/foo.img'/>
+      <target dev='ioemu:hda'/>
+    </disk>
+    <serial type='file'>
+      <source path='/tmp/serial.log'/>
+      <target port='0'/>
+    </serial>
+    <graphics type='vnc' port='5917' keymap='ja'/>
+  </devices>
+</domain>
+
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-null.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-serial-null.sexpr
new file mode 100644 (file)
index 0000000..36563e1
--- /dev/null
@@ -0,0 +1 @@
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial null)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-null.xml b/tests/xml2sexprdata/xml2sexpr-fv-serial-null.xml
new file mode 100644 (file)
index 0000000..d3ce7e2
--- /dev/null
@@ -0,0 +1,39 @@
+<domain type='xen'>
+  <name>fvtest</name>
+  <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <disk type='file'>
+      <source file='/root/foo.img'/>
+      <target dev='ioemu:hda'/>
+    </disk>
+    <serial type='null'>
+      <target port='0'/>
+    </serial>
+    <graphics type='vnc' port='5917' keymap='ja'/>
+  </devices>
+</domain>
+
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-pipe.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-serial-pipe.sexpr
new file mode 100644 (file)
index 0000000..4ae8b7e
--- /dev/null
@@ -0,0 +1 @@
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial pipe:/tmp/serial.pipe)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-pipe.xml b/tests/xml2sexprdata/xml2sexpr-fv-serial-pipe.xml
new file mode 100644 (file)
index 0000000..6fcac8b
--- /dev/null
@@ -0,0 +1,40 @@
+<domain type='xen'>
+  <name>fvtest</name>
+  <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <disk type='file'>
+      <source file='/root/foo.img'/>
+      <target dev='ioemu:hda'/>
+    </disk>
+    <serial type='pipe'>
+      <source path='/tmp/serial.pipe'/>
+      <target port='0'/>
+    </serial>
+    <graphics type='vnc' port='5917' keymap='ja'/>
+  </devices>
+</domain>
+
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-pty.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-serial-pty.sexpr
new file mode 100644 (file)
index 0000000..da50ac6
--- /dev/null
@@ -0,0 +1 @@
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial pty)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-pty.xml b/tests/xml2sexprdata/xml2sexpr-fv-serial-pty.xml
new file mode 100644 (file)
index 0000000..8f7dbef
--- /dev/null
@@ -0,0 +1,39 @@
+<domain type='xen'>
+  <name>fvtest</name>
+  <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <disk type='file'>
+      <source file='/root/foo.img'/>
+      <target dev='ioemu:hda'/>
+    </disk>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <graphics type='vnc' port='5917' keymap='ja'/>
+  </devices>
+</domain>
+
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-stdio.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-serial-stdio.sexpr
new file mode 100644 (file)
index 0000000..0e6cc44
--- /dev/null
@@ -0,0 +1 @@
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial stdio)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-stdio.xml b/tests/xml2sexprdata/xml2sexpr-fv-serial-stdio.xml
new file mode 100644 (file)
index 0000000..5d6d8dd
--- /dev/null
@@ -0,0 +1,39 @@
+<domain type='xen'>
+  <name>fvtest</name>
+  <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <disk type='file'>
+      <source file='/root/foo.img'/>
+      <target dev='ioemu:hda'/>
+    </disk>
+    <serial type='stdio'>
+      <target port='0'/>
+    </serial>
+    <graphics type='vnc' port='5917' keymap='ja'/>
+  </devices>
+</domain>
+
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-tcp-telnet.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-serial-tcp-telnet.sexpr
new file mode 100644 (file)
index 0000000..4a033f7
--- /dev/null
@@ -0,0 +1 @@
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial telnet:localhost:9999,listen)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-tcp-telnet.xml b/tests/xml2sexprdata/xml2sexpr-fv-serial-tcp-telnet.xml
new file mode 100644 (file)
index 0000000..f08c0d8
--- /dev/null
@@ -0,0 +1,41 @@
+<domain type='xen'>
+  <name>fvtest</name>
+  <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <disk type='file'>
+      <source file='/root/foo.img'/>
+      <target dev='ioemu:hda'/>
+    </disk>
+    <serial type='tcp'>
+      <source mode='bind' host='localhost' service='9999'/>
+      <protocol type='telnet'/>
+      <target port='0'/>
+    </serial>
+    <graphics type='vnc' port='5917' keymap='ja'/>
+  </devices>
+</domain>
+
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-tcp.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-serial-tcp.sexpr
new file mode 100644 (file)
index 0000000..c24ecdd
--- /dev/null
@@ -0,0 +1 @@
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial tcp:localhost:9999,listen)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-tcp.xml b/tests/xml2sexprdata/xml2sexpr-fv-serial-tcp.xml
new file mode 100644 (file)
index 0000000..3d9baae
--- /dev/null
@@ -0,0 +1,40 @@
+<domain type='xen'>
+  <name>fvtest</name>
+  <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <disk type='file'>
+      <source file='/root/foo.img'/>
+      <target dev='ioemu:hda'/>
+    </disk>
+    <serial type='tcp'>
+      <source mode='bind' host='localhost' service='9999' wiremode='raw'/>
+      <target port='0'/>
+    </serial>
+    <graphics type='vnc' port='5917' keymap='ja'/>
+  </devices>
+</domain>
+
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-udp.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-serial-udp.sexpr
new file mode 100644 (file)
index 0000000..399404d
--- /dev/null
@@ -0,0 +1 @@
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial udp:localhost:9998@localhost:9999)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-udp.xml b/tests/xml2sexprdata/xml2sexpr-fv-serial-udp.xml
new file mode 100644 (file)
index 0000000..1ff7457
--- /dev/null
@@ -0,0 +1,41 @@
+<domain type='xen'>
+  <name>fvtest</name>
+  <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <disk type='file'>
+      <source file='/root/foo.img'/>
+      <target dev='ioemu:hda'/>
+    </disk>
+    <serial type='udp'>
+      <source mode='connect' host='localhost' service='9998'/>
+      <source mode='bind' host='localhost' service='9999'/>
+      <target port='0'/>
+    </serial>
+    <graphics type='vnc' port='5917' keymap='ja'/>
+  </devices>
+</domain>
+
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-unix.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-serial-unix.sexpr
new file mode 100644 (file)
index 0000000..cacdbf3
--- /dev/null
@@ -0,0 +1 @@
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial unix:/tmp/serial.sock,listen)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-fv-serial-unix.xml b/tests/xml2sexprdata/xml2sexpr-fv-serial-unix.xml
new file mode 100644 (file)
index 0000000..608c21d
--- /dev/null
@@ -0,0 +1,40 @@
+<domain type='xen'>
+  <name>fvtest</name>
+  <uuid>b5d70dd275cdaca517769660b059d8bc</uuid>
+  <os>
+    <type>hvm</type>
+    <loader>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='hd'/>
+  </os>
+  <memory>409600</memory>
+  <vcpu>1</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <features>
+    <acpi/>
+  </features>
+  <devices>
+    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
+    <interface type='bridge'>
+      <source bridge='xenbr0'/>
+      <mac address='00:16:3e:1b:b1:47'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <disk type='file' device='cdrom'>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+    <disk type='file'>
+      <source file='/root/foo.img'/>
+      <target dev='ioemu:hda'/>
+    </disk>
+    <serial type='unix'>
+      <source mode='bind' path='/tmp/serial.sock'/>
+      <target port='0'/>
+    </serial>
+    <graphics type='vnc' port='5917' keymap='ja'/>
+  </devices>
+</domain>
+
index 8915d406613aed46fcedc33a80eba430e1610e86..59bc2a17ce99f4d6d971eb47af7156010ad554ed 100644 (file)
@@ -1 +1 @@
-(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(usbdevice mouse)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(usbdevice mouse)(parallel none)(serial none)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
index 4299891a4f3518bb7dd43eed9b38670c211f1ade..dde4637476e0c165898efbaa77f5a9e43d310f11 100644 (file)
@@ -1 +1 @@
-(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(usbdevice tablet)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(usbdevice tablet)(parallel none)(serial none)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
index db8b3ff2ae92f12781037827cde9b5f86bfbfed2..2e871b36106b037a84cf254236180676f50fe06d 100644 (file)
@@ -1 +1 @@
-(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial none)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
index 5f07066b4b36d7be277b6a7ead88efb15ecb6566..42e82b7fc92d57eebe21faffe6e705e7f201de3e 100644 (file)
@@ -1 +1 @@
-(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(acpi 1)(usb 1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)(vncdisplay 17)(keymap ja)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(acpi 1)(usb 1)(parallel none)(serial none)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)(vncdisplay 17)(keymap ja)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
index a0264577fe99dfd6f43a7945d43c78c4f427b945..422145ab1a8a229f43b8f59825a9f1fd2033214b 100644 (file)
@@ -1 +1 @@
-(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(acpi 1)(usb 1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)(vncunused 1)(keymap ja)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(acpi 1)(usb 1)(parallel none)(serial none)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)(vncunused 1)(keymap ja)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
index db8b3ff2ae92f12781037827cde9b5f86bfbfed2..2e871b36106b037a84cf254236180676f50fe06d 100644 (file)
@@ -1 +1 @@
-(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
+(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(cdrom '/root/boot.iso')(acpi 1)(usb 1)(parallel none)(serial none)(device_model '/usr/lib64/xen/bin/qemu-dm')(vnc 1)))(device (vbd (dev 'ioemu:hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
\ No newline at end of file
index 50e893cbbaee6cf95f742ce0e6ccdcd302920acd..b9979a30be472868ed299d22c8b7bd8b0d5f2e55 100644 (file)
@@ -1 +1 @@
-(vm (name 'test')(memory 350)(maxmem 382)(vcpus 1)(uuid 'cc2315e7d26a307a438c6d188ec4c09c')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(acpi 1)(apic 1)(pae 1)(usb 1)(device_model '/usr/lib/xen/bin/qemu-dm')(vnc 1)(vncdisplay 6)))(device (vbd (dev 'hda:disk:disk')(uname 'phy:/dev/sda8')(mode 'w')))(device (vbd (dev 'hdc:cdrom')(mode 'r')))(device (vif (mac '00:16:3e:0a:7b:39')(type ioemu))))
\ No newline at end of file
+(vm (name 'test')(memory 350)(maxmem 382)(vcpus 1)(uuid 'cc2315e7d26a307a438c6d188ec4c09c')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(acpi 1)(apic 1)(pae 1)(usb 1)(parallel none)(serial none)(device_model '/usr/lib/xen/bin/qemu-dm')(vnc 1)(vncdisplay 6)))(device (vbd (dev 'hda:disk:disk')(uname 'phy:/dev/sda8')(mode 'w')))(device (vbd (dev 'hdc:cdrom')(mode 'r')))(device (vif (mac '00:16:3e:0a:7b:39')(type ioemu))))
\ No newline at end of file
index d87a852a9d66c6f9fa65a9915ea7928971ecde69..a6d402edfdb4d5b6926f380074eac542a9f4fd5c 100644 (file)
@@ -6,6 +6,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <fcntl.h>
+#include <unistd.h>
 
 #if WITH_XEN
 
 #include "testutils.h"
 
 static char *progname;
-static char *abs_top_srcdir;
+static char *abs_srcdir;
 
 #define MAX_FILE 4096
 
-static int testCompareFiles(const char *xml_rel, const char *sexpr_rel,
+static int testCompareFiles(const char *xml, const char *sexpr,
                             const char *name, int xendConfigVersion) {
   char xmlData[MAX_FILE];
   char sexprData[MAX_FILE];
@@ -27,11 +28,6 @@ static int testCompareFiles(const char *xml_rel, const char *sexpr_rel,
   char *xmlPtr = &(xmlData[0]);
   char *sexprPtr = &(sexprData[0]);
   int ret = -1;
-  char xml[PATH_MAX];
-  char sexpr[PATH_MAX];
-
-  snprintf(xml, sizeof xml - 1, "%s/tests/%s", abs_top_srcdir, xml_rel);
-  snprintf(sexpr, sizeof sexpr - 1, "%s/tests/%s", abs_top_srcdir, sexpr_rel);
 
   if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
     goto fail;
@@ -42,11 +38,8 @@ static int testCompareFiles(const char *xml_rel, const char *sexpr_rel,
   if (!(gotsexpr = virDomainParseXMLDesc(NULL, xmlData, &gotname, xendConfigVersion)))
     goto fail;
 
-  if (strcmp(sexprData, gotsexpr)) {
-      if (getenv("DEBUG_TESTS")) {
-        printf("Expect %d '%s'\n", (int)strlen(sexprData), sexprData);
-        printf("Actual %d '%s'\n", (int)strlen(gotsexpr), gotsexpr);
-      }
+  if (STRNEQ(sexprData, gotsexpr)) {
+      virtTestDifference(stderr, sexprData, gotsexpr);
       goto fail;
   }
 
@@ -65,302 +58,89 @@ static int testCompareFiles(const char *xml_rel, const char *sexpr_rel,
   return ret;
 }
 
-static int testComparePVversion1(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-pv.xml",
-                          "xml2sexprdata/xml2sexpr-pv.sexpr",
-                          "pvtest",
-                          1);
-}
-
-static int testCompareFVversion1(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-fv.xml",
-                          "xml2sexprdata/xml2sexpr-fv.sexpr",
-                          "fvtest",
-                          1);
-}
-
-static int testComparePVversion2(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-pv.xml",
-                          "xml2sexprdata/xml2sexpr-pv.sexpr",
-                          "pvtest",
-                          2);
-}
-
-static int testCompareFVversion2(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-fv.xml",
-                          "xml2sexprdata/xml2sexpr-fv-v2.sexpr",
-                          "fvtest",
-                          2);
-}
-
-static int testCompareFVversion2VNC(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-fv-vncunused.xml",
-                          "xml2sexprdata/xml2sexpr-fv-vncunused.sexpr",
-                          "fvtest",
-                          2);
-}
-
-static int testComparePVOrigVFB(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-pv-vfb-orig.xml",
-                          "xml2sexprdata/xml2sexpr-pv-vfb-orig.sexpr",
-                          "pvtest",
-                          2);
-}
-
-
-static int testComparePVNewVFB(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-pv-vfb-new.xml",
-                          "xml2sexprdata/xml2sexpr-pv-vfb-new.sexpr",
-                          "pvtest",
-                          3);
-}
-
-static int testComparePVBootloader(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-pv-bootloader.xml",
-                          "xml2sexprdata/xml2sexpr-pv-bootloader.sexpr",
-                          "pvtest",
-                          1);
-}
+struct testInfo {
+    const char *input;
+    const char *output;
+    const char *name;
+    int version;
+};
 
-static int testCompareDiskFile(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-disk-file.xml",
-                          "xml2sexprdata/xml2sexpr-disk-file.sexpr",
-                          "pvtest",
-                          2);
+static int testCompareHelper(const void *data) {
+    const struct testInfo *info = data;
+    char xml[PATH_MAX];
+    char args[PATH_MAX];
+    snprintf(xml, PATH_MAX, "%s/xml2sexprdata/xml2sexpr-%s.xml",
+             abs_srcdir, info->input);
+    snprintf(args, PATH_MAX, "%s/xml2sexprdata/xml2sexpr-%s.sexpr",
+             abs_srcdir, info->output);
+    return testCompareFiles(xml, args, info->name, info->version);
 }
 
-static int testCompareDiskBlock(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-disk-block.xml",
-                          "xml2sexprdata/xml2sexpr-disk-block.sexpr",
-                          "pvtest",
-                          2);
-}
-
-static int testCompareDiskShareable(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-disk-block-shareable.xml",
-                          "xml2sexprdata/xml2sexpr-disk-block-shareable.sexpr",
-                          "pvtest",
-                          2);
-}
-
-static int testCompareDiskDrvLoop(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-disk-drv-loop.xml",
-                          "xml2sexprdata/xml2sexpr-disk-drv-loop.sexpr",
-                          "pvtest",
-                          2);
-}
-
-static int testCompareDiskDrvBlkback(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-disk-drv-blkback.xml",
-                          "xml2sexprdata/xml2sexpr-disk-drv-blkback.sexpr",
-                          "pvtest",
-                          2);
-}
-
-static int testCompareDiskDrvBlktap(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-disk-drv-blktap.xml",
-                          "xml2sexprdata/xml2sexpr-disk-drv-blktap.sexpr",
-                          "pvtest",
-                          2);
-}
-
-static int testCompareDiskDrvBlktapQcow(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-disk-drv-blktap-qcow.xml",
-                          "xml2sexprdata/xml2sexpr-disk-drv-blktap-qcow.sexpr",
-                          "pvtest",
-                          2);
-}
-
-static int testCompareDiskDrvBlktapRaw(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-disk-drv-blktap-raw.xml",
-                          "xml2sexprdata/xml2sexpr-disk-drv-blktap-raw.sexpr",
-                          "pvtest",
-                          2);
-}
-
-static int testCompareMemoryResize(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-curmem.xml",
-                          "xml2sexprdata/xml2sexpr-curmem.sexpr",
-                          "rhel5",
-                          2);
-}
-
-static int testCompareNetRouted(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-net-routed.xml",
-                          "xml2sexprdata/xml2sexpr-net-routed.sexpr",
-                          "pvtest",
-                          2);
-}
-
-static int testCompareNetBridged(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-net-bridged.xml",
-                          "xml2sexprdata/xml2sexpr-net-bridged.sexpr",
-                          "pvtest",
-                          2);
-}
-
-static int testCompareNoSourceCDRom(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-no-source-cdrom.xml",
-                          "xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr",
-                          "test",
-                          2);
-}
-
-static int testCompareFVclockUTC(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-fv-utc.xml",
-                          "xml2sexprdata/xml2sexpr-fv-utc.sexpr",
-                          "fvtest",
-                          1);
-}
-
-static int testCompareFVclockLocaltime(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-fv-localtime.xml",
-                          "xml2sexprdata/xml2sexpr-fv-localtime.sexpr",
-                          "fvtest",
-                          1);
-}
-
-
-static int testCompareFVInputUSBMouse(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-fv-usbmouse.xml",
-                          "xml2sexprdata/xml2sexpr-fv-usbmouse.sexpr",
-                          "fvtest",
-                          1);
-}
-
-static int testCompareFVInputUSBTablet(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-fv-usbtablet.xml",
-                          "xml2sexprdata/xml2sexpr-fv-usbtablet.sexpr",
-                          "fvtest",
-                          1);
-}
-
-static int testCompareFVKernel(const void *data ATTRIBUTE_UNUSED) {
-  return testCompareFiles("xml2sexprdata/xml2sexpr-fv-kernel.xml",
-                          "xml2sexprdata/xml2sexpr-fv-kernel.sexpr",
-                          "fvtest",
-                          1);
-}
-
-
 
 int
 main(int argc, char **argv)
 {
     int ret = 0;
+    char cwd[PATH_MAX];
 
     progname = argv[0];
 
-    abs_top_srcdir = getenv("abs_top_srcdir");
-    if (!abs_top_srcdir) {
-        fprintf(stderr, "missing enviroment variable abs_top_srcdir\n");
-        exit(EXIT_FAILURE);
-    }
-
+    abs_srcdir = getenv("abs_srcdir");
+    if (!abs_srcdir)
+        abs_srcdir = getcwd(cwd, sizeof(cwd));
 
     if (argc > 1) {
         fprintf(stderr, "Usage: %s\n", progname);
         exit(EXIT_FAILURE);
     }
 
-    if (virtTestRun("XML-2-SEXPR PV config (format 1)",
-                    1, testComparePVversion1, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR FV config (format 1)",
-                    1, testCompareFVversion1, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR PV config (format 2)",
-                    1, testComparePVversion2, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR FV config (format 2)",
-                    1, testCompareFVversion2, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR FV config (format 2, VNC unused)",
-                    1, testCompareFVversion2VNC, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR PV config (Orig VFB)",
-                    1, testComparePVOrigVFB, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR PV config (New VFB)",
-                    1, testComparePVNewVFB, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR PV config with bootloader",
-                    1, testComparePVBootloader, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR Disk File",
-                    1, testCompareDiskFile, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR Disk Block",
-                    1, testCompareDiskBlock, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR Disk Shareable",
-                    1, testCompareDiskShareable, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR Disk Drv Loop",
-                    1, testCompareDiskDrvLoop, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR Disk Drv Blkback",
-                    1, testCompareDiskDrvBlkback, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR Disk Drv Blktap",
-                    1, testCompareDiskDrvBlktap, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR Disk Drv Blktap QCow",
-                    1, testCompareDiskDrvBlktapQcow, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR Disk Drv Blktap Raw",
-                    1, testCompareDiskDrvBlktapRaw, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR Memory Resize",
-                    1, testCompareMemoryResize, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR Net Routed",
-                    1, testCompareNetRouted, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR Net Bridged",
-                    1, testCompareNetBridged, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR No Source CDRom",
-                    1, testCompareNoSourceCDRom, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR FV usb mouse)",
-                    1, testCompareFVInputUSBMouse, NULL) != 0)
-        ret = -1;
-    if (virtTestRun("XML-2-SEXPR FV usb tablet)",
-                    1, testCompareFVInputUSBTablet, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR clock UTC",
-                    1, testCompareFVclockUTC, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR clock Localtime",
-                    1, testCompareFVclockLocaltime, NULL) != 0)
-        ret = -1;
-
-    if (virtTestRun("XML-2-SEXPR FV kernel",
-                    1, testCompareFVKernel, NULL) != 0)
-        ret = -1;
+#define DO_TEST(in, out, name, version)                                \
+    do {                                                               \
+        struct testInfo info = { in, out, name, version };             \
+        if (virtTestRun("Xen XML-2-SEXPR " in " -> " out,              \
+                        1, testCompareHelper, &info) < 0)     \
+            ret = -1;                                                  \
+    } while (0)
+
+    DO_TEST("pv", "pv", "pvtest", 1);
+    DO_TEST("fv", "fv", "fvtest", 1);
+    DO_TEST("pv", "pv", "pvtest", 2);
+    DO_TEST("fv", "fv-v2", "fvtest", 2);
+    DO_TEST("fv-vncunused", "fv-vncunused", "fvtest", 2);
+    DO_TEST("pv-vfb-orig", "pv-vfb-orig", "pvtest", 2);
+    DO_TEST("pv-vfb-new", "pv-vfb-new", "pvtest", 3);
+    DO_TEST("pv-bootloader", "pv-bootloader", "pvtest", 1);
+
+    DO_TEST("disk-file", "disk-file", "pvtest", 2);
+    DO_TEST("disk-block", "disk-block", "pvtest", 2);
+    DO_TEST("disk-block-shareable", "disk-block-shareable", "pvtest", 2);
+    DO_TEST("disk-drv-loop", "disk-drv-loop", "pvtest", 2);
+    DO_TEST("disk-drv-blkback", "disk-drv-blkback", "pvtest", 2);
+    DO_TEST("disk-drv-blktap", "disk-drv-blktap", "pvtest", 2);
+    DO_TEST("disk-drv-blktap-raw", "disk-drv-blktap-raw", "pvtest", 2);
+    DO_TEST("disk-drv-blktap-qcow", "disk-drv-blktap-qcow", "pvtest", 2);
+
+    DO_TEST("curmem", "curmem", "rhel5", 2);
+    DO_TEST("net-routed", "net-routed", "pvtest", 2);
+    DO_TEST("net-bridged", "net-bridged", "pvtest", 2);
+    DO_TEST("no-source-cdrom", "no-source-cdrom", "test", 2);
+
+    DO_TEST("fv-utc", "fv-utc", "fvtest", 1);
+    DO_TEST("fv-localtime", "fv-localtime", "fvtest", 1);
+    DO_TEST("fv-usbmouse", "fv-usbmouse", "fvtest", 1);
+    DO_TEST("fv-usbmouse", "fv-usbmouse", "fvtest", 1);
+    DO_TEST("fv-kernel", "fv-kernel", "fvtest", 1);
+
+    DO_TEST("fv-serial-null", "fv-serial-null", "fvtest", 1);
+    DO_TEST("fv-serial-file", "fv-serial-file", "fvtest", 1);
+    DO_TEST("fv-serial-stdio", "fv-serial-stdio", "fvtest", 1);
+    DO_TEST("fv-serial-pty", "fv-serial-pty", "fvtest", 1);
+    DO_TEST("fv-serial-pipe", "fv-serial-pipe", "fvtest", 1);
+    DO_TEST("fv-serial-tcp", "fv-serial-tcp", "fvtest", 1);
+    DO_TEST("fv-serial-udp", "fv-serial-udp", "fvtest", 1);
+    DO_TEST("fv-serial-tcp-telnet", "fv-serial-tcp-telnet", "fvtest", 1);
+    DO_TEST("fv-serial-unix", "fv-serial-unix", "fvtest", 1);
+    DO_TEST("fv-parallel-tcp", "fv-parallel-tcp", "fvtest", 1);
 
     exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
 }