[PATCH v5.2] virCaps: get rid of defaultConsoleTargetType callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch refactors various places to allow removing of the
defaultConsoleTargetType callback from the virCaps structure.

A new console character device target type is introduced -
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE - to mark that no type was
specified in the XML. This type is at the end converted to the standard
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL. Other types that are
different from this default have to be processed separately in the
device post parse callback.
---
I had some uncommited changes resulting from the rename of the structures when
I was formatting v5.1. This version has the changes in.

 src/conf/capabilities.h          |   3 -
 src/conf/domain_conf.c           | 269 +++++++++++++++++++++------------------
 src/conf/domain_conf.h           |   3 +-
 src/esx/esx_driver.c             |   8 --
 src/libxl/libxl_conf.c           |  11 --
 src/libxl/libxl_driver.c         |  19 +++
 src/lxc/lxc_conf.c               |   8 --
 src/lxc/lxc_domain.c             |  17 +++
 src/openvz/openvz_conf.c         |  10 +-
 src/openvz/openvz_driver.c       |  16 +++
 src/parallels/parallels_driver.c |   7 -
 src/phyp/phyp_driver.c           |   9 --
 src/qemu/qemu_capabilities.c     |  13 --
 src/qemu/qemu_domain.c           |   7 +
 src/security/virt-aa-helper.c    |   7 -
 src/test/test_driver.c           |   9 --
 src/uml/uml_conf.c               |   9 --
 src/uml/uml_driver.c             |  24 +++-
 src/vbox/vbox_tmpl.c             |   9 --
 src/vmware/vmware_conf.c         |   9 --
 src/xen/xen_driver.c             |  28 +++-
 src/xen/xen_driver.h             |   2 +
 src/xen/xen_hypervisor.c         |  11 --
 src/xenapi/xenapi_driver.c       |  28 ++--
 tests/testutilslxc.c             |   9 --
 tests/testutilsqemu.c            |  11 --
 tests/testutilsxen.c             |  16 ---
 tests/testutilsxen.h             |   2 -
 tests/vmx2xmltest.c              |   7 -
 tests/xmconfigtest.c             |   2 +-
 tests/xml2sexprtest.c            |   3 +-
 tests/xml2vmxtest.c              |   7 -
 32 files changed, 278 insertions(+), 315 deletions(-)

diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 9bb22a7..abcf6de 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -160,9 +160,6 @@ struct _virCaps {
     size_t nguests;
     size_t nguests_max;
     virCapsGuestPtr *guests;
-
-    /* Move to virDomainXMLOption later */
-    int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch);
 };


diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f2269c0..f98af61 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -385,6 +385,7 @@ VIR_ENUM_IMPL(virDomainChrChannelTarget,

 VIR_ENUM_IMPL(virDomainChrConsoleTarget,
               VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST,
+              "none",
               "serial",
               "xen",
               "uml",
@@ -2347,9 +2348,11 @@ virDomainDeviceInfoClearCCWAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
     return 0;
 }

-int virDomainDeviceInfoIterate(virDomainDefPtr def,
-                               virDomainDeviceInfoCallback cb,
-                               void *opaque)
+static int
+virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
+                                   virDomainDeviceInfoCallback cb,
+                                   bool all,
+                                   void *opaque)
 {
     int i;
     virDomainDeviceDef device;
@@ -2413,9 +2416,11 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def,
             return -1;
     }
     for (i = 0; i < def->nconsoles ; i++) {
-        if (i == 0 &&
-            def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL &&
-            STREQ_NULLABLE(def->os.type, "hvm"))
+        if (!all &&
+            i == 0 &&
+            (def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
+             def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) &&
+             STREQ_NULLABLE(def->os.type, "hvm"))
             continue;
         device.data.chr = def->consoles[i];
         if (cb(def, &device, &def->consoles[i]->info, opaque) < 0)
@@ -2491,10 +2496,21 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def,
 }


+int
+virDomainDeviceInfoIterate(virDomainDefPtr def,
+                           virDomainDeviceInfoCallback cb,
+                           void *opaque)
+{
+    return virDomainDeviceInfoIterateInternal(def, cb, false, opaque);
+}
+
+
 static int
 virDomainDefPostParseInternal(virDomainDefPtr def,
                               virCapsPtr caps ATTRIBUTE_UNUSED)
 {
+    int i;
+
     /* verify init path for container based domains */
     if (STREQ(def->os.type, "exe") && !def->os.init) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -2502,6 +2518,91 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
         return -1;
     }

+    /*
+     * Some really crazy backcompat stuff for consoles
+     *
+     * Historically the first (and only) '<console>' element in an HVM guest
+     * was treated as being an alias for a <serial> device.
+     *
+     * So if we see that this console device should be a serial device, then we
+     * move the config over to def->serials[0] (or discard it if that already
+     * exists). However, given console can already be filled with aliased data
+     * of def->serials[0]. Keep it then.
+     *
+     * We then fill def->consoles[0] with a stub just so we get sequencing
+     * correct for consoles > 0
+     */
+    if (def->nconsoles > 0 && STREQ(def->os.type, "hvm") &&
+        (def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
+         def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)) {
+        /* First verify that only the first console is of type serial */
+        for (i = 1; i < def->nconsoles; i++) {
+            virDomainChrDefPtr cons = def->consoles[i];
+
+            if (cons->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("Only the first console can be a serial port"));
+                return -1;
+            }
+        }
+
+        /* If there isn't a corresponding serial port:
+         *  - create one and set, the console to be an alias for it
+         *
+         * If there is a corresponding serial port:
+         * - Check if the source definition is equal:
+         *    - if yes: leave it as-is
+         *    - if no: change the console to be alias of the serial port
+         */
+
+        /* create the serial port definition from the console definition */
+        if (def->nserials == 0) {
+            if (VIR_APPEND_ELEMENT(def->serials, def->nserials,
+                                   def->consoles[0]) < 0)
+                goto no_memory;
+
+            /* modify it to be a serial port */
+            def->serials[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+            def->serials[0]->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
+            def->serials[0]->target.port = 0;
+        } else {
+            /* if the console source doesn't match */
+            if (!virDomainChrSourceDefIsEqual(&def->serials[0]->source,
+                                              &def->consoles[0]->source)) {
+                virDomainChrDefFree(def->consoles[0]);
+                def->consoles[0] = NULL;
+            }
+        }
+
+        if (!def->consoles[0]) {
+            /* allocate a new console type for the stolen one */
+            if (VIR_ALLOC(def->consoles[0]) < 0)
+                goto no_memory;
+
+            /* Create an console alias for the serial port */
+            def->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+            def->consoles[0]->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+        }
+    }
+
+    return 0;
+
+no_memory:
+    virReportOOMError();
+    return -1;
+}
+
+
+static int
+virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
+                                    virDomainDefPtr def ATTRIBUTE_UNUSED,
+                                    virCapsPtr caps ATTRIBUTE_UNUSED)
+{
+    if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
+        dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
+        dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
+        dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+
     return 0;
 }

@@ -2521,6 +2622,9 @@ virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
             return ret;
     }

+    if ((ret = virDomainDeviceDefPostParseInternal(dev, def, caps)) < 0)
+        return ret;
+
     return 0;
 }

@@ -2564,9 +2668,10 @@ virDomainDefPostParse(virDomainDefPtr def,
     }

     /* iterate the devices */
-    if ((ret = virDomainDeviceInfoIterate(def,
-                                          virDomainDefPostParseDeviceIterator,
-                                          &data)) < 0)
+    if ((ret = virDomainDeviceInfoIterateInternal(def,
+                                                  virDomainDefPostParseDeviceIterator,
+                                                  true,
+                                                  &data)) < 0)
         return ret;


@@ -5923,87 +6028,66 @@ error:
 }

 static int
-virDomainChrDefaultTargetType(virCapsPtr caps,
-                              virDomainDefPtr def,
-                              int devtype) {
-
-    int target = -1;
-
-    switch (devtype) {
+virDomainChrDefaultTargetType(int devtype) {
+    switch ((enum virDomainChrDeviceType) devtype) {
     case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL:
         virReportError(VIR_ERR_XML_ERROR,
                        _("target type must be specified for %s device"),
                        virDomainChrDeviceTypeToString(devtype));
-        break;
+        return -1;

     case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
-        if (!caps->defaultConsoleTargetType) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("Driver does not have a default console type set"));
-            return -1;
-        }
-        target = caps->defaultConsoleTargetType(def->os.type, def->os.arch);
-        break;
+        return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE;

     case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
-        target = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
-        break;
+        return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;

     case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
-    default:
+    case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
         /* No target type yet*/
-        target = 0;
         break;
     }

-    return target;
+    return 0;
 }

 static int
-virDomainChrTargetTypeFromString(virCapsPtr caps,
-                                 virDomainDefPtr vmdef,
-                                 virDomainChrDefPtr def,
+virDomainChrTargetTypeFromString(virDomainChrDefPtr def,
                                  int devtype,
                                  const char *targetType)
 {
     int ret = -1;
-    int target = 0;

-    if (!targetType) {
-        target = virDomainChrDefaultTargetType(caps, vmdef, devtype);
-        goto out;
-    }
+    if (!targetType)
+        return virDomainChrDefaultTargetType(devtype);

-    switch (devtype) {
+    switch ((enum virDomainChrDeviceType) devtype) {
     case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL:
-        target = virDomainChrChannelTargetTypeFromString(targetType);
+        ret = virDomainChrChannelTargetTypeFromString(targetType);
         break;

     case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
-        target = virDomainChrConsoleTargetTypeFromString(targetType);
+        ret = virDomainChrConsoleTargetTypeFromString(targetType);
         break;

     case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
-        target = virDomainChrSerialTargetTypeFromString(targetType);
+        ret = virDomainChrSerialTargetTypeFromString(targetType);
         break;

     case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
-    default:
+    case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
         /* No target type yet*/
+        ret = 0;
         break;
     }

     def->targetTypeAttr = true;

-out:
-    ret = target;
     return ret;
 }

 static int
-virDomainChrDefParseTargetXML(virCapsPtr caps,
-                              virDomainDefPtr vmdef,
-                              virDomainChrDefPtr def,
+virDomainChrDefParseTargetXML(virDomainChrDefPtr def,
                               xmlNodePtr cur)
 {
     int ret = -1;
@@ -6013,8 +6097,8 @@ virDomainChrDefParseTargetXML(virCapsPtr caps,
     const char *portStr = NULL;

     if ((def->targetType =
-         virDomainChrTargetTypeFromString(caps, vmdef, def,
-                                          def->deviceType, targetType)) < 0) {
+         virDomainChrTargetTypeFromString(def, def->deviceType,
+                                          targetType)) < 0) {
         virReportError(VIR_ERR_XML_ERROR,
                        _("unknown target type '%s' specified for character device"),
                        targetType);
@@ -6373,9 +6457,7 @@ virDomainChrDefNew(void) {
  *
  */
 static virDomainChrDefPtr
-virDomainChrDefParseXML(virCapsPtr caps,
-                        virDomainDefPtr vmdef,
-                        xmlXPathContextPtr ctxt,
+virDomainChrDefParseXML(xmlXPathContextPtr ctxt,
                         xmlNodePtr node,
                         virSecurityLabelDefPtr* vmSeclabels,
                         int nvmSeclabels,
@@ -6419,7 +6501,7 @@ virDomainChrDefParseXML(virCapsPtr caps,
             if (cur->type == XML_ELEMENT_NODE) {
                 if (xmlStrEqual(cur->name, BAD_CAST "target")) {
                     seenTarget = true;
-                    if (virDomainChrDefParseTargetXML(caps, vmdef, def, cur) < 0) {
+                    if (virDomainChrDefParseTargetXML(def, cur) < 0) {
                         goto error;
                     }
                 }
@@ -6429,7 +6511,7 @@ virDomainChrDefParseXML(virCapsPtr caps,
     }

     if (!seenTarget &&
-        ((def->targetType = virDomainChrDefaultTargetType(caps, vmdef, def->deviceType)) < 0))
+        ((def->targetType = virDomainChrDefaultTargetType(def->deviceType)) < 0))
         goto cleanup;

     if (def->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) {
@@ -10557,9 +10639,7 @@ virDomainDefParseXML(xmlDocPtr xml,
         goto no_memory;

     for (i = 0 ; i < n ; i++) {
-        virDomainChrDefPtr chr = virDomainChrDefParseXML(caps,
-                                                         def,
-                                                         ctxt,
+        virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt,
                                                          nodes[i],
                                                          def->seclabels,
                                                          def->nseclabels,
@@ -10587,9 +10667,7 @@ virDomainDefParseXML(xmlDocPtr xml,
         goto no_memory;

     for (i = 0 ; i < n ; i++) {
-        virDomainChrDefPtr chr = virDomainChrDefParseXML(caps,
-                                                         def,
-                                                         ctxt,
+        virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt,
                                                          nodes[i],
                                                          def->seclabels,
                                                          def->nseclabels,
@@ -10619,10 +10697,7 @@ virDomainDefParseXML(xmlDocPtr xml,
         goto no_memory;

     for (i = 0 ; i < n ; i++) {
-        bool create_stub = true;
-        virDomainChrDefPtr chr = virDomainChrDefParseXML(caps,
-                                                         def,
-                                                         ctxt,
+        virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt,
                                                          nodes[i],
                                                          def->seclabels,
                                                          def->nseclabels,
@@ -10630,64 +10705,7 @@ virDomainDefParseXML(xmlDocPtr xml,
         if (!chr)
             goto error;

-        /*
-         * Some really crazy backcompat stuff for consoles
-         *
-         * Historically the first (and only) '<console>'
-         * element in an HVM guest was treated as being
-         * an alias for a <serial> device.
-         *
-         * So if we see that this console device should
-         * be a serial device, then we move the config
-         * over to def->serials[0] (or discard it if
-         * that already exists). However, given console
-         * can already be filled with aliased data of
-         * def->serials[0]. Keep it then.
-         *
-         * We then fill def->consoles[0] with a stub
-         * just so we get sequencing correct for consoles
-         * > 0
-         */
-        if (STREQ(def->os.type, "hvm") &&
-            (chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL)) {
-            if (i != 0) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("Only the first console can be a serial port"));
-                virDomainChrDefFree(chr);
-                goto error;
-            }
-
-            /* Either discard or move this chr to the serial config */
-            if (def->nserials != 0) {
-                if (virDomainChrSourceDefIsEqual(&def->serials[0]->source,
-                                                 &chr->source)) {
-                    /* Alias to def->serial[0]. Skip it */
-                    create_stub = false;
-                } else {
-                    virDomainChrDefFree(chr);
-                }
-            } else {
-                if (VIR_ALLOC_N(def->serials, 1) < 0) {
-                    virDomainChrDefFree(chr);
-                    goto no_memory;
-                }
-                chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
-                def->nserials = 1;
-                def->serials[0] = chr;
-                chr->target.port = 0;
-            }
-
-            if (create_stub) {
-                /* And create a stub placeholder */
-                if (VIR_ALLOC(chr) < 0)
-                    goto no_memory;
-                chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
-                chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-            }
-        }
-
         chr->target.port = i;
-
         def->consoles[def->nconsoles++] = chr;
     }
     VIR_FREE(nodes);
@@ -10699,9 +10717,7 @@ virDomainDefParseXML(xmlDocPtr xml,
         goto no_memory;

     for (i = 0 ; i < n ; i++) {
-        virDomainChrDefPtr chr = virDomainChrDefParseXML(caps,
-                                                         def,
-                                                         ctxt,
+        virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt,
                                                          nodes[i],
                                                          def->seclabels,
                                                          def->nseclabels,
@@ -15200,7 +15216,6 @@ virDomainDefFormatInternal(virDomainDefPtr def,
         if (virDomainFSDefFormat(buf, def->fss[n], flags) < 0)
             goto error;

-
     for (n = 0 ; n < def->nnets ; n++)
         if (virDomainNetDefFormat(buf, def->nets[n], flags) < 0)
             goto error;
@@ -15223,7 +15238,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
          * if it is type == serial
          */
         if (STREQ(def->os.type, "hvm") &&
-            (def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) &&
+            (def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
+             def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) &&
             (n < def->nserials)) {
             memcpy(&console, def->serials[n], sizeof(console));
             console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
@@ -15240,6 +15256,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
         virDomainChrDef console;
         memcpy(&console, def->serials[n], sizeof(console));
         console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+        console.targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
         if (virDomainChrDefFormat(buf, &console, flags) < 0)
             goto error;
     }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 45a79a4..700f03f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -956,7 +956,8 @@ enum virDomainChrChannelTargetType {
 };

 enum virDomainChrConsoleTargetType {
-    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL = 0,
+    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE  = 0,
+    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL,
     VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN,
     VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML,
     VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 3a21395..4828209 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -569,13 +569,6 @@ esxLookupHostSystemBiosUuid(esxPrivate *priv, unsigned char *uuid)
 }


-static int esxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                                 virArch arch ATTRIBUTE_UNUSED)
-{
-    return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-}
-
-
 static virCapsPtr
 esxCapsInit(esxPrivate *priv)
 {
@@ -600,7 +593,6 @@ esxCapsInit(esxPrivate *priv)

     virCapabilitiesAddHostMigrateTransport(caps, "vpxmigr");

-    caps->defaultConsoleTargetType = esxDefaultConsoleType;

     if (esxLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0) {
         goto failure;
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index ed3e832..7e0753a 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -64,15 +64,6 @@ static const char *xen_cap_re = "(xen|hvm)-[[:digit:]]+\\.[[:digit:]]+-(x86_32|x
 static regex_t xen_cap_rec;


-static int libxlDefaultConsoleType(const char *ostype,
-                                   virArch arch ATTRIBUTE_UNUSED)
-{
-    if (STREQ(ostype, "hvm"))
-        return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-    else
-        return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
-}
-
 static virCapsPtr
 libxlBuildCapabilities(virArch hostarch,
                        int host_pae,
@@ -162,8 +153,6 @@ libxlBuildCapabilities(virArch hostarch,
         }
     }

-    caps->defaultConsoleTargetType = libxlDefaultConsoleType;
-
     return caps;

  no_memory:
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 32818ff..9980b38 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -431,10 +431,29 @@ virDomainXMLPrivateDataCallbacks libxlDomainXMLPrivateDataCallbacks = {
     .free = libxlDomainObjPrivateFree,
 };

+
+static int
+libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
+                              virDomainDefPtr def,
+                              virCapsPtr caps ATTRIBUTE_UNUSED,
+                              void *opaque ATTRIBUTE_UNUSED)
+{
+    if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
+        dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
+        dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
+        STRNEQ(def->os.type, "hvm"))
+        dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
+
+    return 0;
+}
+
+
 virDomainDefParserConfig libxlDomainDefParserConfig = {
     .macPrefix = { 0x00, 0x16, 0x3e },
+    .devicesPostParseCallback = libxlDomainDeviceDefPostParse,
 };

+
 /* driver must be locked before calling */
 static void
 libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event)
diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index 05e0d45..13c0d97 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -41,12 +41,6 @@

 #define VIR_FROM_THIS VIR_FROM_LXC

-static int lxcDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                                 virArch arch ATTRIBUTE_UNUSED)
-{
-    return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC;
-}
-

 /* Functions */
 virCapsPtr lxcCapsInit(virLXCDriverPtr driver)
@@ -59,8 +53,6 @@ virCapsPtr lxcCapsInit(virLXCDriverPtr driver)
                                    0, 0)) == NULL)
         goto error;

-    caps->defaultConsoleTargetType = lxcDefaultConsoleType;
-
     /* Some machines have problematic NUMA toplogy causing
      * unexpected failures. We don't want to break the QEMU
      * driver in this scenario, so log errors & carry on
diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index 8090789..e7a85ca 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -93,6 +93,23 @@ virLXCDomainDefPostParse(virDomainDefPtr def,
     return 0;
 }

+
+static int
+virLXCDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
+                               virDomainDefPtr def ATTRIBUTE_UNUSED,
+                               virCapsPtr caps ATTRIBUTE_UNUSED,
+                               void *opaque ATTRIBUTE_UNUSED)
+{
+    if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
+        dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
+        dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
+        dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC;
+
+    return 0;
+}
+
+
 virDomainDefParserConfig virLXCDriverDomainDefParserConfig = {
     .domainPostParseCallback = virLXCDomainDefPostParse,
+    .devicesPostParseCallback = virLXCDomainDeviceDefPostParse,
 };
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 22dea79..4b21c4e 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -168,13 +168,6 @@ error:
 }


-static int openvzDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                                    virArch arch ATTRIBUTE_UNUSED)
-{
-    return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ;
-}
-
-
 virCapsPtr openvzCapsInit(void)
 {
     virCapsPtr caps;
@@ -204,9 +197,8 @@ virCapsPtr openvzCapsInit(void)
                                       NULL) == NULL)
         goto no_memory;

-    caps->defaultConsoleTargetType = openvzDefaultConsoleType;
-
     return caps;
+
 no_memory:
     virObjectUnref(caps);
     return NULL;
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 180d047..9b10624 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -115,8 +115,24 @@ openvzDomainDefPostParse(virDomainDefPtr def,
 }


+static int
+openvzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
+                               virDomainDefPtr def ATTRIBUTE_UNUSED,
+                               virCapsPtr caps ATTRIBUTE_UNUSED,
+                               void *opaque ATTRIBUTE_UNUSED)
+{
+    if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
+        dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
+        dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
+        dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ;
+
+    return 0;
+}
+
+
 virDomainDefParserConfig openvzDomainDefParserConfig = {
         .domainPostParseCallback = openvzDomainDefPostParse,
+        .devicesPostParseCallback = openvzDomainDeviceDefPostParse,
 };


diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index c6833f7..c524bf1 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -96,12 +96,6 @@ parallelsDriverUnlock(parallelsConnPtr driver)
     virMutexUnlock(&driver->lock);
 }

-static int
-parallelsDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                            virArch arch ATTRIBUTE_UNUSED)
-{
-    return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-}

 static void
 parallelsDomObjFreePrivate(void *p)
@@ -149,7 +143,6 @@ parallelsBuildCapabilities(void)
                                       "parallels", NULL, NULL, 0, NULL) == NULL)
         goto no_memory;

-    caps->defaultConsoleTargetType = parallelsDefaultConsoleType;
     return caps;

   no_memory:
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 07f230f..071caf2 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -300,13 +300,6 @@ phypGetVIOSPartitionID(virConnectPtr conn)
 }


-static int phypDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                                  virArch arch ATTRIBUTE_UNUSED)
-{
-    return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-}
-
-
 static virCapsPtr
 phypCapsInit(void)
 {
@@ -337,8 +330,6 @@ phypCapsInit(void)
                                       "phyp", NULL, NULL, 0, NULL) == NULL)
         goto no_memory;

-    caps->defaultConsoleTargetType = phypDefaultConsoleType;
-
     return caps;

 no_memory:
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 7760542..50712b0 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -856,17 +856,6 @@ error:
 }


-static int virQEMUCapsDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                                         virArch arch)
-{
-    if (arch == VIR_ARCH_S390 ||
-        arch == VIR_ARCH_S390X)
-        return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
-    else
-        return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-}
-
-
 virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
 {
     virCapsPtr caps;
@@ -906,8 +895,6 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
                                  i) < 0)
             goto error;

-    caps->defaultConsoleTargetType = virQEMUCapsDefaultConsoleType;
-
     return caps;

 error:
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e5e9223..f431aec 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -731,6 +731,13 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
         }
     }

+    /* set the default console type for S390 arches */
+    if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
+        dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
+        dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
+        (def->os.arch == VIR_ARCH_S390 || def->os.arch == VIR_ARCH_S390X))
+        dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
+
     ret = 0;

 cleanup:
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index fee63ec..3d3b772 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -687,11 +687,6 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
     return rc;
 }

-static int aaDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                                virArch arch ATTRIBUTE_UNUSED)
-{
-    return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-}

 static int
 get_definition(vahControl * ctl, const char *xmlStr)
@@ -716,8 +711,6 @@ get_definition(vahControl * ctl, const char *xmlStr)
         goto exit;
     }

-    ctl->caps->defaultConsoleTargetType = aaDefaultConsoleType;
-
     if ((guest = virCapabilitiesAddGuest(ctl->caps,
                                          ctl->hvm,
                                          ctl->arch,
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index ecfbe33..76fbfda 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -152,13 +152,6 @@ static void testDomainObjPrivateFree(void *data)
 }


-static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                                  virArch arch ATTRIBUTE_UNUSED)
-{
-    return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-}
-
-
 static virDomainXMLOptionPtr
 testBuildXMLConfig(void)
 {
@@ -179,8 +172,6 @@ testBuildCapabilities(virConnectPtr conn) {
     if ((caps = virCapabilitiesNew(VIR_ARCH_I686, 0, 0)) == NULL)
         goto no_memory;

-    caps->defaultConsoleTargetType = testDefaultConsoleType;
-
     if (virCapabilitiesAddHostFeature(caps, "pae") < 0)
         goto no_memory;
     if (virCapabilitiesAddHostFeature(caps ,"nonpae") < 0)
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index 0fe59fb..4fa7927 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -52,13 +52,6 @@
 #define VIR_FROM_THIS VIR_FROM_UML


-static int umlDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                                 virArch arch ATTRIBUTE_UNUSED)
-{
-    return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML;
-}
-
-
 virCapsPtr umlCapsInit(void) {
     virCapsPtr caps;
     virCapsGuestPtr guest;
@@ -102,8 +95,6 @@ virCapsPtr umlCapsInit(void) {
                                       NULL) == NULL)
         goto error;

-    caps->defaultConsoleTargetType = umlDefaultConsoleType;
-
     return caps;

  error:
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 2476d1c..6cff6fd 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -420,6 +420,27 @@ cleanup:
     umlDriverUnlock(driver);
 }

+
+static int
+umlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
+                             virDomainDefPtr def ATTRIBUTE_UNUSED,
+                             virCapsPtr caps ATTRIBUTE_UNUSED,
+                             void *opaque ATTRIBUTE_UNUSED)
+{
+    if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
+        dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
+        dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
+        dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML;
+
+    return 0;
+}
+
+
+virDomainDefParserConfig umlDriverDomainDefParserConfig = {
+    .devicesPostParseCallback = umlDomainDeviceDefPostParse,
+};
+
+
 /**
  * umlStartup:
  *
@@ -505,7 +526,8 @@ umlStartup(bool privileged,
     if ((uml_driver->caps = umlCapsInit()) == NULL)
         goto out_of_memory;

-    if (!(uml_driver->xmlopt = virDomainXMLOptionNew(NULL, &privcb, NULL)))
+    if (!(uml_driver->xmlopt = virDomainXMLOptionNew(&umlDriverDomainDefParserConfig,
+                                                     &privcb, NULL)))
         goto error;

     if ((uml_driver->inotifyFD = inotify_init()) < 0) {
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 4490d0c..0248ee0 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -844,13 +844,6 @@ cleanup:
 }


-static int vboxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                                  virArch arch ATTRIBUTE_UNUSED)
-{
-    return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-}
-
-
 static virDomainDefParserConfig vboxDomainDefParserConfig = {
     .macPrefix = { 0x08, 0x00, 0x27 },
 };
@@ -893,8 +886,6 @@ static virCapsPtr vboxCapsInit(void)
                                       NULL) == NULL)
         goto no_memory;

-    caps->defaultConsoleTargetType = vboxDefaultConsoleType;
-
     return caps;

 no_memory:
diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index d8d2611..573fb33 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -50,13 +50,6 @@ vmwareFreeDriver(struct vmware_driver *driver)
 }


-static int vmwareDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                                    virArch arch ATTRIBUTE_UNUSED)
-{
-    return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-}
-
-
 virCapsPtr
 vmwareCapsInit(void)
 {
@@ -122,8 +115,6 @@ vmwareCapsInit(void)
             goto error;
     }

-    caps->defaultConsoleTargetType = vmwareDefaultConsoleType;
-
 cleanup:
     virCPUDefFree(cpu);
     if (caps)
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 6761090..5a15b58 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -265,11 +265,36 @@ xenUnifiedXendProbe(void)
 #endif


+static int
+xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
+                            virDomainDefPtr def,
+                            virCapsPtr caps ATTRIBUTE_UNUSED,
+                            void *opaque ATTRIBUTE_UNUSED)
+{
+    if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
+        dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
+        dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
+        STRNEQ(def->os.type, "hvm"))
+        dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
+
+    return 0;
+}
+
+
 virDomainDefParserConfig xenDomainDefParserConfig = {
     .macPrefix = { 0x00, 0x16, 0x3e },
+    .devicesPostParseCallback = xenDomainDeviceDefPostParse,
 };


+virDomainXMLOptionPtr
+xenDomainXMLConfInit(void)
+{
+    return virDomainXMLOptionNew(&xenDomainDefParserConfig,
+                                 NULL, NULL);
+}
+
+
 static virDrvOpenStatus
 xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
 {
@@ -405,8 +430,7 @@ xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
         goto fail;
     }

-    if (!(priv->xmlopt = virDomainXMLOptionNew(&xenDomainDefParserConfig,
-                                               NULL, NULL)))
+    if (!(priv->xmlopt = xenDomainXMLConfInit()))
         goto fail;

 #if WITH_XEN_INOTIFY
diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h
index f1f5d74..702b1e8 100644
--- a/src/xen/xen_driver.h
+++ b/src/xen/xen_driver.h
@@ -226,6 +226,8 @@ typedef struct _xenUnifiedPrivate *xenUnifiedPrivatePtr;

 char *xenDomainUsedCpus(virDomainPtr dom);

+virDomainXMLOptionPtr xenDomainXMLConfInit(void);
+
 void xenUnifiedDomainInfoListFree(xenUnifiedDomainInfoListPtr info);
 int  xenUnifiedAddDomainInfo(xenUnifiedDomainInfoListPtr info,
                              int id, char *name,
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 69bc6cd..e16fffe 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -2279,15 +2279,6 @@ struct guest_arch {
 };


-static int xenDefaultConsoleType(const char *ostype,
-                                 virArch arch ATTRIBUTE_UNUSED)
-{
-    if (STREQ(ostype, "hvm"))
-        return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-    else
-        return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
-}
-
 static virCapsPtr
 xenHypervisorBuildCapabilities(virConnectPtr conn, virArch hostarch,
                                int host_pae,
@@ -2414,8 +2405,6 @@ xenHypervisorBuildCapabilities(virConnectPtr conn, virArch hostarch,

     }

-    caps->defaultConsoleTargetType = xenDefaultConsoleType;
-
     return caps;

  no_memory:
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index d619609..123c4f2 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -43,16 +43,27 @@
 #define VIR_FROM_THIS VIR_FROM_XENAPI


-static int xenapiDefaultConsoleType(const char *ostype,
-                                    virArch arch ATTRIBUTE_UNUSED)
+static int
+xenapiDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
+                               virDomainDefPtr def,
+                               virCapsPtr caps ATTRIBUTE_UNUSED,
+                               void *opaque ATTRIBUTE_UNUSED)
 {
-    if (STREQ(ostype, "hvm"))
-        return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-    else
-        return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
+    if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
+        dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
+        dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
+        STRNEQ(def->os.type, "hvm"))
+        dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
+
+    return 0;
 }


+virDomainDefParserConfig xenapiDomainDefParserConfig = {
+    .devicesPostParseCallback = xenapiDomainDeviceDefPostParse,
+};
+
+
 /*
  * getCapsObject
  *
@@ -83,8 +94,6 @@ getCapsObject(void)
     if (!domain2)
         goto error_cleanup;

-    caps->defaultConsoleTargetType = xenapiDefaultConsoleType;
-
     return caps;

   error_cleanup:
@@ -169,7 +178,8 @@ xenapiOpen(virConnectPtr conn, virConnectAuthPtr auth,
         goto error;
     }

-    if (!(privP->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) {
+    if (!(privP->xmlopt = virDomainXMLOptionNew(&xenapiDomainDefParserConfig,
+                                                NULL, NULL))) {
         xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
                                   _("Failed to create XML conf object"));
         goto error;
diff --git a/tests/testutilslxc.c b/tests/testutilslxc.c
index 0c2170c..1bc6feb 100644
--- a/tests/testutilslxc.c
+++ b/tests/testutilslxc.c
@@ -8,13 +8,6 @@
 # include "domain_conf.h"


-static int testLXCDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                                     virArch arch ATTRIBUTE_UNUSED)
-{
-    return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC;
-}
-
-
 virCapsPtr testLXCCapsInit(void) {
     virCapsPtr caps;
     virCapsGuestPtr guest;
@@ -23,8 +16,6 @@ virCapsPtr testLXCCapsInit(void) {
                                    0, 0)) == NULL)
         return NULL;

-    caps->defaultConsoleTargetType = testLXCDefaultConsoleType;
-
     if ((guest = virCapabilitiesAddGuest(caps, "exe", VIR_ARCH_I686,
                                          "/usr/libexec/libvirt_lxc", NULL,
                                          0, NULL)) == NULL)
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index db15ee6..fba17a3 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -55,15 +55,6 @@ static virCapsGuestMachinePtr *testQemuAllocNewerMachines(int *nmachines)
     return machines;
 }

-static int testQemuDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                                      virArch arch)
-{
-    if (arch == VIR_ARCH_S390 ||
-        arch == VIR_ARCH_S390X)
-        return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
-    else
-        return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-}

 static int testQemuAddPPC64Guest(virCapsPtr caps)
 {
@@ -200,8 +191,6 @@ virCapsPtr testQemuCapsInit(void) {
                                    0, 0)) == NULL)
         return NULL;

-    caps->defaultConsoleTargetType = testQemuDefaultConsoleType;
-
     if ((caps->host.cpu = virCPUDefCopy(&host_cpu)) == NULL ||
         (machines = testQemuAllocMachines(&nmachines)) == NULL)
         goto cleanup;
diff --git a/tests/testutilsxen.c b/tests/testutilsxen.c
index 2eb4730..1b5ee79 100644
--- a/tests/testutilsxen.c
+++ b/tests/testutilsxen.c
@@ -6,20 +6,6 @@
 #include "testutilsxen.h"
 #include "domain_conf.h"

-static int testXenDefaultConsoleType(const char *ostype,
-                                     virArch arch ATTRIBUTE_UNUSED)
-{
-    if (STREQ(ostype, "hvm"))
-        return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-    else
-        return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
-}
-
-virDomainXMLOptionPtr
-testXenXMLConfInit(void)
-{
-    return virDomainXMLOptionNew(NULL, NULL, NULL);
-}

 virCapsPtr testXenCapsInit(void) {
     struct utsname utsname;
@@ -39,8 +25,6 @@ virCapsPtr testXenCapsInit(void) {
                                    0, 0)) == NULL)
         return NULL;

-    caps->defaultConsoleTargetType = testXenDefaultConsoleType;
-
     nmachines = ARRAY_CARDINALITY(x86_machines);
     if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
         goto cleanup;
diff --git a/tests/testutilsxen.h b/tests/testutilsxen.h
index a38b03a..7f27e22 100644
--- a/tests/testutilsxen.h
+++ b/tests/testutilsxen.h
@@ -1,6 +1,4 @@

 #include "capabilities.h"
-#include "domain_conf.h"

 virCapsPtr testXenCapsInit(void);
-virDomainXMLOptionPtr testXenXMLConfInit(void);
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index d63ac52..2d04da7 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -15,11 +15,6 @@ static virCapsPtr caps;
 static virDomainXMLOptionPtr xmlopt;
 static virVMXContext ctx;

-static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                                  virArch arch ATTRIBUTE_UNUSED)
-{
-    return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-}

 static void
 testCapsInit(void)
@@ -32,8 +27,6 @@ testCapsInit(void)
         return;
     }

-    caps->defaultConsoleTargetType = testDefaultConsoleType;
-
     virCapabilitiesAddHostMigrateTransport(caps, "esx");

     /* i686 guest */
diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c
index af80061..b7ff48c 100644
--- a/tests/xmconfigtest.c
+++ b/tests/xmconfigtest.c
@@ -196,7 +196,7 @@ mymain(void)
     if (!(caps = testXenCapsInit()))
         return EXIT_FAILURE;

-    if (!(xmlopt = testXenXMLConfInit()))
+    if (!(xmlopt = xenDomainXMLConfInit()))
         return EXIT_FAILURE;

 #define DO_TEST(name, version)                                          \
diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c
index a091d45..062ff07 100644
--- a/tests/xml2sexprtest.c
+++ b/tests/xml2sexprtest.c
@@ -10,6 +10,7 @@

 #include "internal.h"
 #include "xen/xend_internal.h"
+#include "xen/xen_driver.h"
 #include "xenxs/xen_sxpr.h"
 #include "testutils.h"
 #include "testutilsxen.h"
@@ -104,7 +105,7 @@ mymain(void)
     if (!(caps = testXenCapsInit()))
         return EXIT_FAILURE;

-    if (!(xmlopt = testXenXMLConfInit()))
+    if (!(xmlopt = xenDomainXMLConfInit()))
         return EXIT_FAILURE;

     DO_TEST("pv", "pv", "pvtest", 1);
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index 659b0c8..1957659 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -15,11 +15,6 @@ static virCapsPtr caps;
 static virVMXContext ctx;
 static virDomainXMLOptionPtr xmlopt;

-static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
-                                  virArch arch ATTRIBUTE_UNUSED)
-{
-    return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-}

 static void
 testCapsInit(void)
@@ -32,8 +27,6 @@ testCapsInit(void)
         return;
     }

-    caps->defaultConsoleTargetType = testDefaultConsoleType;
-
     virCapabilitiesAddHostMigrateTransport(caps, "esx");


-- 
1.8.1.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]