[libvirt] [PATCH 1/4] character device: Allow character devices to have different target types

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

 



Currently a character device's target (it's interface in the guest) has only a
single property: port. This patch is in preparation for adding targets which
require other properties.

Target properties are moved into a union in virDomainChrDef, and a targetType
field is added to identify which union member should be used. All current code
which touches a virDomainChrDef is updated both to use the new union field,
and to populate targetType if necessary.
---
 src/conf/domain_conf.c  |   66 +++++++++++++++++++++++++++++++++++++---------
 src/conf/domain_conf.h  |   18 +++++++++++-
 src/esx/esx_vmx.c       |   56 +++++++++++++++++++++------------------
 src/qemu/qemu_conf.c    |    6 +++-
 src/qemu/qemu_driver.c  |    2 +
 src/uml/uml_conf.c      |   12 ++++----
 src/uml/uml_driver.c    |    2 +-
 src/vbox/vbox_tmpl.c    |   22 ++++++++--------
 src/xen/xend_internal.c |    3 ++
 src/xen/xm_internal.c   |    3 ++
 10 files changed, 129 insertions(+), 61 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index de07e13..0e49482 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -127,6 +127,13 @@ VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST,
               "bridge",
               "internal")
 
+VIR_ENUM_IMPL(virDomainChrTarget, VIR_DOMAIN_CHR_TARGET_TYPE_LAST,
+              "null",
+              "monitor",
+              "parallel",
+              "serial",
+              "console")
+
 VIR_ENUM_IMPL(virDomainChr, VIR_DOMAIN_CHR_TYPE_LAST,
               "null",
               "vc",
@@ -1305,6 +1312,7 @@ virDomainChrDefParseXML(virConnectPtr conn,
     char *path = NULL;
     char *mode = NULL;
     char *protocol = NULL;
+    const char *targetType = NULL;
     virDomainChrDefPtr def;
 
     if (VIR_ALLOC(def) < 0) {
@@ -1318,6 +1326,21 @@ virDomainChrDefParseXML(virConnectPtr conn,
     else if ((def->type = virDomainChrTypeFromString(type)) < 0)
         def->type = VIR_DOMAIN_CHR_TYPE_NULL;
 
+    targetType = (const char *) node->name;
+    if (targetType == NULL) {
+        /* Shouldn't be possible */
+        virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+                             "node->name is NULL at %s:%i",
+                             __FILE__, __LINE__);
+        return NULL;
+    }
+    if ((def->targetType = virDomainChrTargetTypeFromString(targetType)) < 0) {
+        virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+                             _("unknown target type for character device: %s"),
+                             targetType);
+        def->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_NULL;
+    }
+
     cur = node->children;
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
@@ -2911,7 +2934,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
         if (!chr)
             goto error;
 
-        chr->dstPort = i;
+        chr->target.port = i;
         def->parallels[def->nparallels++] = chr;
     }
     VIR_FREE(nodes);
@@ -2931,7 +2954,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
         if (!chr)
             goto error;
 
-        chr->dstPort = i;
+        chr->target.port = i;
         def->serials[def->nserials++] = chr;
     }
     VIR_FREE(nodes);
@@ -2943,7 +2966,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
         if (!chr)
             goto error;
 
-        chr->dstPort = 0;
+        chr->target.port = 0;
         /*
          * For HVM console actually created a serial device
          * while for non-HVM it was a parvirt console
@@ -3945,10 +3968,12 @@ static int
 virDomainChrDefFormat(virConnectPtr conn,
                       virBufferPtr buf,
                       virDomainChrDefPtr def,
-                      const char *name,
                       int flags)
 {
     const char *type = virDomainChrTypeToString(def->type);
+    const char *targetName = virDomainChrTargetTypeToString(def->targetType);
+
+    const char *elementName = targetName; /* Currently always the same */
 
     if (!type) {
         virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
@@ -3958,8 +3983,8 @@ virDomainChrDefFormat(virConnectPtr conn,
 
     /* Compat with legacy  <console tty='/dev/pts/5'/> syntax */
     virBufferVSprintf(buf, "    <%s type='%s'",
-                      name, type);
-    if (STREQ(name, "console") &&
+                      elementName, type);
+    if (def->targetType == VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE &&
         def->type == VIR_DOMAIN_CHR_TYPE_PTY &&
         !(flags & VIR_DOMAIN_XML_INACTIVE) &&
         def->data.file.path) {
@@ -4034,11 +4059,23 @@ virDomainChrDefFormat(virConnectPtr conn,
         break;
     }
 
-    virBufferVSprintf(buf, "      <target port='%d'/>\n",
-                      def->dstPort);
+    switch (def->targetType) {
+    case VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL:
+    case VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL:
+    case VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE:
+        virBufferVSprintf(buf, "      <target port='%d'/>\n",
+                          def->target.port);
+        break;
+
+    default:
+        virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+                             _("unexpected character destination type %d"),
+                             def->targetType);
+        return -1;
+    }
 
     virBufferVSprintf(buf, "    </%s>\n",
-                      name);
+                      elementName);
 
     return 0;
 }
@@ -4485,21 +4522,24 @@ char *virDomainDefFormat(virConnectPtr conn,
             goto cleanup;
 
     for (n = 0 ; n < def->nserials ; n++)
-        if (virDomainChrDefFormat(conn, &buf, def->serials[n], "serial", flags) < 0)
+        if (virDomainChrDefFormat(conn, &buf, def->serials[n], flags) < 0)
             goto cleanup;
 
     for (n = 0 ; n < def->nparallels ; n++)
-        if (virDomainChrDefFormat(conn, &buf, def->parallels[n], "parallel", flags) < 0)
+        if (virDomainChrDefFormat(conn, &buf, def->parallels[n], flags) < 0)
             goto cleanup;
 
     /* If there's a PV console that's preferred.. */
     if (def->console) {
-        if (virDomainChrDefFormat(conn, &buf, def->console, "console", flags) < 0)
+        if (virDomainChrDefFormat(conn, &buf, def->console, flags) < 0)
             goto cleanup;
     } else if (def->nserials != 0) {
         /* ..else for legacy compat duplicate the first serial device as a
          * console */
-        if (virDomainChrDefFormat(conn, &buf, def->serials[0], "console", flags) < 0)
+        virDomainChrDef console;
+        memcpy(&console, def->serials[0], sizeof(console));
+        console.targetType = VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE;
+        if (virDomainChrDefFormat(conn, &buf, &console, flags) < 0)
             goto cleanup;
     }
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 389e259..3bfa84d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -211,7 +211,17 @@ virNetHasValidPciAddr(virDomainNetDefPtr def)
     return def->pci_addr.domain || def->pci_addr.bus || def->pci_addr.slot;
 }
 
-enum virDomainChrSrcType {
+enum virDomainChrTargetType {
+    VIR_DOMAIN_CHR_TARGET_TYPE_NULL = 0,
+    VIR_DOMAIN_CHR_TARGET_TYPE_MONITOR,
+    VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL,
+    VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL,
+    VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE,
+
+    VIR_DOMAIN_CHR_TARGET_TYPE_LAST
+};
+
+enum virDomainChrType {
     VIR_DOMAIN_CHR_TYPE_NULL,
     VIR_DOMAIN_CHR_TYPE_VC,
     VIR_DOMAIN_CHR_TYPE_PTY,
@@ -236,7 +246,10 @@ enum virDomainChrTcpProtocol {
 typedef struct _virDomainChrDef virDomainChrDef;
 typedef virDomainChrDef *virDomainChrDefPtr;
 struct _virDomainChrDef {
-    int dstPort;
+    int targetType;
+    union {
+        int port; /* parallel, serial, console */
+    } target;
 
     int type;
     union {
@@ -808,6 +821,7 @@ VIR_ENUM_DECL(virDomainDiskBus)
 VIR_ENUM_DECL(virDomainDiskCache)
 VIR_ENUM_DECL(virDomainFS)
 VIR_ENUM_DECL(virDomainNet)
+VIR_ENUM_DECL(virDomainChrTarget)
 VIR_ENUM_DECL(virDomainChr)
 VIR_ENUM_DECL(virDomainSoundModel)
 VIR_ENUM_DECL(virDomainWatchdogModel)
diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
index 8e2bdec..4d498ef 100644
--- a/src/esx/esx_vmx.c
+++ b/src/esx/esx_vmx.c
@@ -319,7 +319,7 @@ def->nets[0]...
                                         serial0.startConnected = "true"         # defaults to "true"
 
 def->serials[0]...
-->dstPort = <port>
+->target.port = <port>
 
 
 ## serials: device #############################################################
@@ -378,7 +378,7 @@ def->serials[0]...
                                         parallel0.startConnected = "true"       # defaults to "true"
 
 def->parallels[0]...
-->dstPort = <port>
+->target.port = <port>
 
 
 ## parallels: device #############################################################
@@ -1868,6 +1868,8 @@ esxVMX_ParseSerial(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
         goto failure;
     }
 
+    (*def)->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL;
+
     snprintf(prefix, sizeof(prefix), "serial%d", port);
 
     ESX_BUILD_VMX_NAME(present);
@@ -1904,13 +1906,13 @@ esxVMX_ParseSerial(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
 
     /* Setup virDomainChrDef */
     if (STRCASEEQ(fileType, "device")) {
-        (*def)->dstPort = port;
+        (*def)->target.port = port;
         (*def)->type = VIR_DOMAIN_CHR_TYPE_DEV;
         (*def)->data.file.path = fileName;
 
         fileName = NULL;
     } else if (STRCASEEQ(fileType, "file")) {
-        (*def)->dstPort = port;
+        (*def)->target.port = port;
         (*def)->type = VIR_DOMAIN_CHR_TYPE_FILE;
         (*def)->data.file.path = esxVMX_ParseFileName(conn, ctx, fileName,
                                                       datastoreName,
@@ -1924,7 +1926,7 @@ esxVMX_ParseSerial(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
          * FIXME: Differences between client/server and VM/application pipes
          *        not representable in domain XML form
          */
-        (*def)->dstPort = port;
+        (*def)->target.port = port;
         (*def)->type = VIR_DOMAIN_CHR_TYPE_PIPE;
         (*def)->data.file.path = fileName;
 
@@ -1990,6 +1992,8 @@ esxVMX_ParseParallel(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
         goto failure;
     }
 
+    (*def)->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL;
+
     snprintf(prefix, sizeof(prefix), "parallel%d", port);
 
     ESX_BUILD_VMX_NAME(present);
@@ -2026,13 +2030,13 @@ esxVMX_ParseParallel(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
 
     /* Setup virDomainChrDef */
     if (STRCASEEQ(fileType, "device")) {
-        (*def)->dstPort = port;
+        (*def)->target.port = port;
         (*def)->type = VIR_DOMAIN_CHR_TYPE_DEV;
         (*def)->data.file.path = fileName;
 
         fileName = NULL;
     } else if (STRCASEEQ(fileType, "file")) {
-        (*def)->dstPort = port;
+        (*def)->target.port = port;
         (*def)->type = VIR_DOMAIN_CHR_TYPE_FILE;
         (*def)->data.file.path = esxVMX_ParseFileName(conn, ctx, fileName,
                                                       datastoreName,
@@ -2703,9 +2707,9 @@ esxVMX_FormatSerial(virConnectPtr conn, esxVI_Context *ctx,
 {
     char *fileName = NULL;
 
-    if (def->dstPort < 0 || def->dstPort > 3) {
+    if (def->target.port < 0 || def->target.port > 3) {
         ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
-                  "Serial port index %d out of [0..3] range", def->dstPort);
+                  "Serial port index %d out of [0..3] range", def->target.port);
         return -1;
     }
 
@@ -2716,20 +2720,20 @@ esxVMX_FormatSerial(virConnectPtr conn, esxVI_Context *ctx,
         return -1;
     }
 
-    virBufferVSprintf(buffer, "serial%d.present = \"true\"\n", def->dstPort);
+    virBufferVSprintf(buffer, "serial%d.present = \"true\"\n", def->target.port);
 
     /* def:type -> vmx:fileType and def:data.file.path -> vmx:fileName */
     switch (def->type) {
       case VIR_DOMAIN_CHR_TYPE_DEV:
         virBufferVSprintf(buffer, "serial%d.fileType = \"device\"\n",
-                          def->dstPort);
+                          def->target.port);
         virBufferVSprintf(buffer, "serial%d.fileName = \"%s\"\n",
-                          def->dstPort, def->data.file.path);
+                          def->target.port, def->data.file.path);
         break;
 
       case VIR_DOMAIN_CHR_TYPE_FILE:
         virBufferVSprintf(buffer, "serial%d.fileType = \"file\"\n",
-                          def->dstPort);
+                          def->target.port);
 
         fileName = esxVMX_FormatFileName(conn, ctx, def->data.file.path);
 
@@ -2738,22 +2742,22 @@ esxVMX_FormatSerial(virConnectPtr conn, esxVI_Context *ctx,
         }
 
         virBufferVSprintf(buffer, "serial%d.fileName = \"%s\"\n",
-                          def->dstPort, fileName);
+                          def->target.port, fileName);
 
         VIR_FREE(fileName);
         break;
 
       case VIR_DOMAIN_CHR_TYPE_PIPE:
         virBufferVSprintf(buffer, "serial%d.fileType = \"pipe\"\n",
-                          def->dstPort);
+                          def->target.port);
         /* FIXME: Based on VI Client GUI default */
         virBufferVSprintf(buffer, "serial%d.pipe.endPoint = \"client\"\n",
-                          def->dstPort);
+                          def->target.port);
         /* FIXME: Based on VI Client GUI default */
         virBufferVSprintf(buffer, "serial%d.tryNoRxLoss = \"false\"\n",
-                          def->dstPort);
+                          def->target.port);
         virBufferVSprintf(buffer, "serial%d.fileName = \"%s\"\n",
-                          def->dstPort, def->data.file.path);
+                          def->target.port, def->data.file.path);
         break;
 
       default:
@@ -2766,7 +2770,7 @@ esxVMX_FormatSerial(virConnectPtr conn, esxVI_Context *ctx,
     /* vmx:yieldOnMsrRead */
     /* FIXME: Based on VI Client GUI default */
     virBufferVSprintf(buffer, "serial%d.yieldOnMsrRead = \"true\"\n",
-                      def->dstPort);
+                      def->target.port);
 
     return 0;
 }
@@ -2779,9 +2783,9 @@ esxVMX_FormatParallel(virConnectPtr conn, esxVI_Context *ctx,
 {
     char *fileName = NULL;
 
-    if (def->dstPort < 0 || def->dstPort > 2) {
+    if (def->target.port < 0 || def->target.port > 2) {
         ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
-                  "Parallel port index %d out of [0..2] range", def->dstPort);
+                  "Parallel port index %d out of [0..2] range", def->target.port);
         return -1;
     }
 
@@ -2792,20 +2796,20 @@ esxVMX_FormatParallel(virConnectPtr conn, esxVI_Context *ctx,
         return -1;
     }
 
-    virBufferVSprintf(buffer, "parallel%d.present = \"true\"\n", def->dstPort);
+    virBufferVSprintf(buffer, "parallel%d.present = \"true\"\n", def->target.port);
 
     /* def:type -> vmx:fileType and def:data.file.path -> vmx:fileName */
     switch (def->type) {
       case VIR_DOMAIN_CHR_TYPE_DEV:
         virBufferVSprintf(buffer, "parallel%d.fileType = \"device\"\n",
-                          def->dstPort);
+                          def->target.port);
         virBufferVSprintf(buffer, "parallel%d.fileName = \"%s\"\n",
-                          def->dstPort, def->data.file.path);
+                          def->target.port, def->data.file.path);
         break;
 
       case VIR_DOMAIN_CHR_TYPE_FILE:
         virBufferVSprintf(buffer, "parallel%d.fileType = \"file\"\n",
-                          def->dstPort);
+                          def->target.port);
 
         fileName = esxVMX_FormatFileName(conn, ctx, def->data.file.path);
 
@@ -2814,7 +2818,7 @@ esxVMX_FormatParallel(virConnectPtr conn, esxVI_Context *ctx,
         }
 
         virBufferVSprintf(buffer, "parallel%d.fileName = \"%s\"\n",
-                          def->dstPort, fileName);
+                          def->target.port, fileName);
 
         VIR_FREE(fileName);
         break;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index a095cb7..767965c 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -3374,7 +3374,8 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn,
                     virDomainChrDefFree(chr);
                     goto no_memory;
                 }
-                chr->dstPort = def->nserials;
+                chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL;
+                chr->target.port = def->nserials;
                 def->serials[def->nserials++] = chr;
             }
         } else if (STREQ(arg, "-parallel")) {
@@ -3387,7 +3388,8 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn,
                     virDomainChrDefFree(chr);
                     goto no_memory;
                 }
-                chr->dstPort = def->nparallels;
+                chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL;
+                chr->target.port = def->nparallels;
                 def->parallels[def->nparallels++] = chr;
             }
         } else if (STREQ(arg, "-usbdevice")) {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a91c60f..f6af383 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1921,6 +1921,8 @@ qemuPrepareMonitorChr(virConnectPtr conn,
                       virDomainChrDefPtr monitor_chr,
                       const char *vm)
 {
+    monitor_chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_MONITOR;
+
     monitor_chr->type = VIR_DOMAIN_CHR_TYPE_UNIX;
     monitor_chr->data.nix.listen = 1;
 
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index 1c1db61..0ace58f 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -279,21 +279,21 @@ umlBuildCommandLineChr(virConnectPtr conn,
 
     switch (def->type) {
     case VIR_DOMAIN_CHR_TYPE_NULL:
-        if (virAsprintf(&ret, "%s%d=null", dev, def->dstPort) < 0) {
+        if (virAsprintf(&ret, "%s%d=null", dev, def->target.port) < 0) {
             virReportOOMError(conn);
             return NULL;
         }
         break;
 
     case VIR_DOMAIN_CHR_TYPE_PTY:
-        if (virAsprintf(&ret, "%s%d=pts", dev, def->dstPort) < 0) {
+        if (virAsprintf(&ret, "%s%d=pts", dev, def->target.port) < 0) {
             virReportOOMError(conn);
             return NULL;
         }
         break;
 
     case VIR_DOMAIN_CHR_TYPE_DEV:
-        if (virAsprintf(&ret, "%s%d=tty:%s", dev, def->dstPort,
+        if (virAsprintf(&ret, "%s%d=tty:%s", dev, def->target.port,
                         def->data.file.path) < 0) {
             virReportOOMError(conn);
             return NULL;
@@ -301,7 +301,7 @@ umlBuildCommandLineChr(virConnectPtr conn,
         break;
 
     case VIR_DOMAIN_CHR_TYPE_STDIO:
-        if (virAsprintf(&ret, "%s%d=fd:0,fd:1", dev, def->dstPort) < 0) {
+        if (virAsprintf(&ret, "%s%d=fd:0,fd:1", dev, def->target.port) < 0) {
             virReportOOMError(conn);
             return NULL;
         }
@@ -314,7 +314,7 @@ umlBuildCommandLineChr(virConnectPtr conn,
             return NULL;
         }
 
-        if (virAsprintf(&ret, "%s%d=port:%s", dev, def->dstPort,
+        if (virAsprintf(&ret, "%s%d=port:%s", dev, def->target.port,
                         def->data.tcp.service) < 0) {
             virReportOOMError(conn);
             return NULL;
@@ -502,7 +502,7 @@ int umlBuildCommandLine(virConnectPtr conn,
         virDomainChrDefPtr chr = NULL;
         char *ret;
         for (j = 0 ; j < vm->def->nserials ; j++)
-            if (vm->def->serials[j]->dstPort == i)
+            if (vm->def->serials[j]->target.port == i)
                 chr = vm->def->serials[j];
         if (chr)
             ret = umlBuildCommandLineChr(conn, chr, "ssl");
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 80cf477..c94ad93 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -169,7 +169,7 @@ umlIdentifyOneChrPTY(virConnectPtr conn,
     char *cmd;
     char *res = NULL;
     int retries = 0;
-    if (virAsprintf(&cmd, "config %s%d", dev, def->dstPort) < 0) {
+    if (virAsprintf(&cmd, "config %s%d", dev, def->target.port) < 0) {
         virReportOOMError(conn);
         return -1;
     }
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 4741c57..e83368e 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -2415,9 +2415,9 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
                             serialPort->vtbl->GetIRQ(serialPort, &IRQ);
                             serialPort->vtbl->GetIOBase(serialPort, &IOBase);
                             if ((IRQ == 4) && (IOBase == 1016)) {
-                                def->serials[serialPortIncCount]->dstPort = 0;
+                                def->serials[serialPortIncCount]->target.port = 0;
                             } else if ((IRQ == 3) && (IOBase == 760)) {
-                                def->serials[serialPortIncCount]->dstPort = 1;
+                                def->serials[serialPortIncCount]->target.port = 1;
                             }
 
                             serialPort->vtbl->GetPath(serialPort, &pathUtf16);
@@ -2481,9 +2481,9 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
                             parallelPort->vtbl->GetIRQ(parallelPort, &IRQ);
                             parallelPort->vtbl->GetIOBase(parallelPort, &IOBase);
                             if ((IRQ == 7) && (IOBase == 888)) {
-                                def->parallels[parallelPortIncCount]->dstPort = 0;
+                                def->parallels[parallelPortIncCount]->target.port = 0;
                             } else if ((IRQ == 5) && (IOBase == 632)) {
-                                def->parallels[parallelPortIncCount]->dstPort = 1;
+                                def->parallels[parallelPortIncCount]->target.port = 1;
                             }
 
                             def->parallels[parallelPortIncCount]->type = VIR_DOMAIN_CHR_TYPE_FILE;
@@ -3505,7 +3505,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
                 ISerialPort *serialPort = NULL;
 
                 DEBUG("SerialPort(%d): Type: %d", i, def->serials[i]->type);
-                DEBUG("SerialPort(%d): dstPort: %d", i, def->serials[i]->dstPort);
+                DEBUG("SerialPort(%d): target.port: %d", i, def->serials[i]->target.port);
 
                 machine->vtbl->GetSerialPort(machine, i, &serialPort);
                 if (serialPort) {
@@ -3520,17 +3520,17 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
                      * TODO: make this more flexible
                      */
                     /* TODO: to improve the libvirt XMl handling so
-                     * that def->serials[i]->dstPort shows real port
+                     * that def->serials[i]->target.port shows real port
                      * and not always start at 0
                      */
                     if (def->serials[i]->type == VIR_DOMAIN_CHR_TYPE_DEV) {
                         serialPort->vtbl->SetPath(serialPort, pathUtf16);
-                        if (def->serials[i]->dstPort == 0) {
+                        if (def->serials[i]->target.port == 0) {
                             serialPort->vtbl->SetIRQ(serialPort, 4);
                             serialPort->vtbl->SetIOBase(serialPort, 1016);
                             DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s",
                                   i, 4, 1016, def->serials[i]->data.file.path);
-                        } else if (def->serials[i]->dstPort == 1) {
+                        } else if (def->serials[i]->target.port == 1) {
                             serialPort->vtbl->SetIRQ(serialPort, 3);
                             serialPort->vtbl->SetIOBase(serialPort, 760);
                             DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s",
@@ -3539,12 +3539,12 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
                         serialPort->vtbl->SetHostMode(serialPort, PortMode_HostDevice);
                     } else if (def->serials[i]->type == VIR_DOMAIN_CHR_TYPE_PIPE) {
                         serialPort->vtbl->SetPath(serialPort, pathUtf16);
-                        if (def->serials[i]->dstPort == 0) {
+                        if (def->serials[i]->target.port == 0) {
                             serialPort->vtbl->SetIRQ(serialPort, 4);
                             serialPort->vtbl->SetIOBase(serialPort, 1016);
                             DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s",
                                   i, 4, 1016, def->serials[i]->data.file.path);
-                        } else if (def->serials[i]->dstPort == 1) {
+                        } else if (def->serials[i]->target.port == 1) {
                             serialPort->vtbl->SetIRQ(serialPort, 3);
                             serialPort->vtbl->SetIOBase(serialPort, 760);
                             DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s",
@@ -3585,7 +3585,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
                 IParallelPort *parallelPort = NULL;
 
                 DEBUG("ParallelPort(%d): Type: %d", i, def->parallels[i]->type);
-                DEBUG("ParallelPort(%d): dstPort: %d", i, def->parallels[i]->dstPort);
+                DEBUG("ParallelPort(%d): target.port: %d", i, def->parallels[i]->target.port);
 
                 machine->vtbl->GetParallelPort(machine, i, &parallelPort);
                 if (parallelPort) {
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index d3ab019..b8790d3 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -2569,6 +2569,7 @@ xenDaemonParseSxpr(virConnectPtr conn,
                 virDomainChrDefFree(chr);
                 goto no_memory;
             }
+            chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL;
             def->serials[def->nserials++] = chr;
         }
         tmp = sexpr_node(root, "domain/image/hvm/parallel");
@@ -2581,12 +2582,14 @@ xenDaemonParseSxpr(virConnectPtr conn,
                 virDomainChrDefFree(chr);
                 goto no_memory;
             }
+            chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL;
             def->parallels[def->nparallels++] = chr;
         }
     } else {
         /* Fake a paravirt console, since that's not in the sexpr */
         if (!(def->console = xenDaemonParseSxprChar(conn, "pty", tty)))
             goto error;
+        def->console->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE;
     }
     VIR_FREE(tty);
 
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 732b2d3..ad97db2 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -1415,6 +1415,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) {
                 virDomainChrDefFree(chr);
                 goto no_memory;
             }
+            chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL;
             def->parallels[0] = chr;
             def->nparallels++;
             chr = NULL;
@@ -1431,12 +1432,14 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) {
                 virDomainChrDefFree(chr);
                 goto no_memory;
             }
+            chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL;
             def->serials[0] = chr;
             def->nserials++;
         }
     } else {
         if (!(def->console = xenDaemonParseSxprChar(conn, "pty", NULL)))
             goto cleanup;
+        def->console->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE;
     }
 
     if (hvm) {
-- 
1.6.2.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]