提交 89d549c3 编写于 作者: M Matthew Booth 提交者: Daniel Veillard

Allow character devices to have different target types

A character device's target (it's interface in the guest) had only a
single property: port. This patch is in preparation for adding targets
which require other properties.
Since this changes the conf type for character devices this affects
a number of drivers:

* src/conf/domain_conf.[ch] src/esx/esx_vmx.c src/qemu/qemu_conf.c
  src/qemu/qemu_driver.c src/uml/uml_conf.c src/uml/uml_driver.c
  src/vbox/vbox_tmpl.c src/xen/xend_internal.c src/xen/xm_internal.c:
  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.
上级 8db32571
...@@ -127,6 +127,13 @@ VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST, ...@@ -127,6 +127,13 @@ VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST,
"bridge", "bridge",
"internal") "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, VIR_ENUM_IMPL(virDomainChr, VIR_DOMAIN_CHR_TYPE_LAST,
"null", "null",
"vc", "vc",
...@@ -1325,6 +1332,7 @@ virDomainChrDefParseXML(virConnectPtr conn, ...@@ -1325,6 +1332,7 @@ virDomainChrDefParseXML(virConnectPtr conn,
char *path = NULL; char *path = NULL;
char *mode = NULL; char *mode = NULL;
char *protocol = NULL; char *protocol = NULL;
const char *targetType = NULL;
virDomainChrDefPtr def; virDomainChrDefPtr def;
if (VIR_ALLOC(def) < 0) { if (VIR_ALLOC(def) < 0) {
...@@ -1338,6 +1346,20 @@ virDomainChrDefParseXML(virConnectPtr conn, ...@@ -1338,6 +1346,20 @@ virDomainChrDefParseXML(virConnectPtr conn,
else if ((def->type = virDomainChrTypeFromString(type)) < 0) else if ((def->type = virDomainChrTypeFromString(type)) < 0)
def->type = VIR_DOMAIN_CHR_TYPE_NULL; 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, "%s",
_("node->name is NULL in virDomainChrDefParseXML()"));
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; cur = node->children;
while (cur != NULL) { while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) { if (cur->type == XML_ELEMENT_NODE) {
...@@ -2931,7 +2953,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, ...@@ -2931,7 +2953,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
if (!chr) if (!chr)
goto error; goto error;
chr->dstPort = i; chr->target.port = i;
def->parallels[def->nparallels++] = chr; def->parallels[def->nparallels++] = chr;
} }
VIR_FREE(nodes); VIR_FREE(nodes);
...@@ -2951,7 +2973,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, ...@@ -2951,7 +2973,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
if (!chr) if (!chr)
goto error; goto error;
chr->dstPort = i; chr->target.port = i;
def->serials[def->nserials++] = chr; def->serials[def->nserials++] = chr;
} }
VIR_FREE(nodes); VIR_FREE(nodes);
...@@ -2963,7 +2985,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, ...@@ -2963,7 +2985,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
if (!chr) if (!chr)
goto error; goto error;
chr->dstPort = 0; chr->target.port = 0;
/* /*
* For HVM console actually created a serial device * For HVM console actually created a serial device
* while for non-HVM it was a parvirt console * while for non-HVM it was a parvirt console
...@@ -3965,10 +3987,12 @@ static int ...@@ -3965,10 +3987,12 @@ static int
virDomainChrDefFormat(virConnectPtr conn, virDomainChrDefFormat(virConnectPtr conn,
virBufferPtr buf, virBufferPtr buf,
virDomainChrDefPtr def, virDomainChrDefPtr def,
const char *name,
int flags) int flags)
{ {
const char *type = virDomainChrTypeToString(def->type); const char *type = virDomainChrTypeToString(def->type);
const char *targetName = virDomainChrTargetTypeToString(def->targetType);
const char *elementName = targetName; /* Currently always the same */
if (!type) { if (!type) {
virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
...@@ -3978,8 +4002,8 @@ virDomainChrDefFormat(virConnectPtr conn, ...@@ -3978,8 +4002,8 @@ virDomainChrDefFormat(virConnectPtr conn,
/* Compat with legacy <console tty='/dev/pts/5'/> syntax */ /* Compat with legacy <console tty='/dev/pts/5'/> syntax */
virBufferVSprintf(buf, " <%s type='%s'", virBufferVSprintf(buf, " <%s type='%s'",
name, type); elementName, type);
if (STREQ(name, "console") && if (def->targetType == VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE &&
def->type == VIR_DOMAIN_CHR_TYPE_PTY && def->type == VIR_DOMAIN_CHR_TYPE_PTY &&
!(flags & VIR_DOMAIN_XML_INACTIVE) && !(flags & VIR_DOMAIN_XML_INACTIVE) &&
def->data.file.path) { def->data.file.path) {
...@@ -4054,11 +4078,23 @@ virDomainChrDefFormat(virConnectPtr conn, ...@@ -4054,11 +4078,23 @@ virDomainChrDefFormat(virConnectPtr conn,
break; break;
} }
virBufferVSprintf(buf, " <target port='%d'/>\n", switch (def->targetType) {
def->dstPort); 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", virBufferVSprintf(buf, " </%s>\n",
name); elementName);
return 0; return 0;
} }
...@@ -4505,21 +4541,24 @@ char *virDomainDefFormat(virConnectPtr conn, ...@@ -4505,21 +4541,24 @@ char *virDomainDefFormat(virConnectPtr conn,
goto cleanup; goto cleanup;
for (n = 0 ; n < def->nserials ; n++) 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; goto cleanup;
for (n = 0 ; n < def->nparallels ; n++) 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; goto cleanup;
/* If there's a PV console that's preferred.. */ /* If there's a PV console that's preferred.. */
if (def->console) { if (def->console) {
if (virDomainChrDefFormat(conn, &buf, def->console, "console", flags) < 0) if (virDomainChrDefFormat(conn, &buf, def->console, flags) < 0)
goto cleanup; goto cleanup;
} else if (def->nserials != 0) { } else if (def->nserials != 0) {
/* ..else for legacy compat duplicate the first serial device as a /* ..else for legacy compat duplicate the first serial device as a
* console */ * 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; goto cleanup;
} }
......
...@@ -211,7 +211,17 @@ virNetHasValidPciAddr(virDomainNetDefPtr def) ...@@ -211,7 +211,17 @@ virNetHasValidPciAddr(virDomainNetDefPtr def)
return def->pci_addr.domain || def->pci_addr.bus || def->pci_addr.slot; 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_NULL,
VIR_DOMAIN_CHR_TYPE_VC, VIR_DOMAIN_CHR_TYPE_VC,
VIR_DOMAIN_CHR_TYPE_PTY, VIR_DOMAIN_CHR_TYPE_PTY,
...@@ -236,7 +246,10 @@ enum virDomainChrTcpProtocol { ...@@ -236,7 +246,10 @@ enum virDomainChrTcpProtocol {
typedef struct _virDomainChrDef virDomainChrDef; typedef struct _virDomainChrDef virDomainChrDef;
typedef virDomainChrDef *virDomainChrDefPtr; typedef virDomainChrDef *virDomainChrDefPtr;
struct _virDomainChrDef { struct _virDomainChrDef {
int dstPort; int targetType;
union {
int port; /* parallel, serial, console */
} target;
int type; int type;
union { union {
...@@ -812,6 +825,7 @@ VIR_ENUM_DECL(virDomainDiskBus) ...@@ -812,6 +825,7 @@ VIR_ENUM_DECL(virDomainDiskBus)
VIR_ENUM_DECL(virDomainDiskCache) VIR_ENUM_DECL(virDomainDiskCache)
VIR_ENUM_DECL(virDomainFS) VIR_ENUM_DECL(virDomainFS)
VIR_ENUM_DECL(virDomainNet) VIR_ENUM_DECL(virDomainNet)
VIR_ENUM_DECL(virDomainChrTarget)
VIR_ENUM_DECL(virDomainChr) VIR_ENUM_DECL(virDomainChr)
VIR_ENUM_DECL(virDomainSoundModel) VIR_ENUM_DECL(virDomainSoundModel)
VIR_ENUM_DECL(virDomainWatchdogModel) VIR_ENUM_DECL(virDomainWatchdogModel)
......
...@@ -319,7 +319,7 @@ def->nets[0]... ...@@ -319,7 +319,7 @@ def->nets[0]...
serial0.startConnected = "true" # defaults to "true" serial0.startConnected = "true" # defaults to "true"
def->serials[0]... def->serials[0]...
->dstPort = <port> ->target.port = <port>
## serials: device ############################################################# ## serials: device #############################################################
...@@ -378,7 +378,7 @@ def->serials[0]... ...@@ -378,7 +378,7 @@ def->serials[0]...
parallel0.startConnected = "true" # defaults to "true" parallel0.startConnected = "true" # defaults to "true"
def->parallels[0]... def->parallels[0]...
->dstPort = <port> ->target.port = <port>
## parallels: device ############################################################# ## parallels: device #############################################################
...@@ -1871,6 +1871,8 @@ esxVMX_ParseSerial(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf, ...@@ -1871,6 +1871,8 @@ esxVMX_ParseSerial(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
goto failure; goto failure;
} }
(*def)->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL;
snprintf(prefix, sizeof(prefix), "serial%d", port); snprintf(prefix, sizeof(prefix), "serial%d", port);
ESX_BUILD_VMX_NAME(present); ESX_BUILD_VMX_NAME(present);
...@@ -1907,13 +1909,13 @@ esxVMX_ParseSerial(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf, ...@@ -1907,13 +1909,13 @@ esxVMX_ParseSerial(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
/* Setup virDomainChrDef */ /* Setup virDomainChrDef */
if (STRCASEEQ(fileType, "device")) { if (STRCASEEQ(fileType, "device")) {
(*def)->dstPort = port; (*def)->target.port = port;
(*def)->type = VIR_DOMAIN_CHR_TYPE_DEV; (*def)->type = VIR_DOMAIN_CHR_TYPE_DEV;
(*def)->data.file.path = fileName; (*def)->data.file.path = fileName;
fileName = NULL; fileName = NULL;
} else if (STRCASEEQ(fileType, "file")) { } else if (STRCASEEQ(fileType, "file")) {
(*def)->dstPort = port; (*def)->target.port = port;
(*def)->type = VIR_DOMAIN_CHR_TYPE_FILE; (*def)->type = VIR_DOMAIN_CHR_TYPE_FILE;
(*def)->data.file.path = esxVMX_ParseFileName(conn, ctx, fileName, (*def)->data.file.path = esxVMX_ParseFileName(conn, ctx, fileName,
datastoreName, datastoreName,
...@@ -1927,7 +1929,7 @@ esxVMX_ParseSerial(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf, ...@@ -1927,7 +1929,7 @@ esxVMX_ParseSerial(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
* FIXME: Differences between client/server and VM/application pipes * FIXME: Differences between client/server and VM/application pipes
* not representable in domain XML form * not representable in domain XML form
*/ */
(*def)->dstPort = port; (*def)->target.port = port;
(*def)->type = VIR_DOMAIN_CHR_TYPE_PIPE; (*def)->type = VIR_DOMAIN_CHR_TYPE_PIPE;
(*def)->data.file.path = fileName; (*def)->data.file.path = fileName;
...@@ -1993,6 +1995,8 @@ esxVMX_ParseParallel(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf, ...@@ -1993,6 +1995,8 @@ esxVMX_ParseParallel(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
goto failure; goto failure;
} }
(*def)->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL;
snprintf(prefix, sizeof(prefix), "parallel%d", port); snprintf(prefix, sizeof(prefix), "parallel%d", port);
ESX_BUILD_VMX_NAME(present); ESX_BUILD_VMX_NAME(present);
...@@ -2029,13 +2033,13 @@ esxVMX_ParseParallel(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf, ...@@ -2029,13 +2033,13 @@ esxVMX_ParseParallel(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
/* Setup virDomainChrDef */ /* Setup virDomainChrDef */
if (STRCASEEQ(fileType, "device")) { if (STRCASEEQ(fileType, "device")) {
(*def)->dstPort = port; (*def)->target.port = port;
(*def)->type = VIR_DOMAIN_CHR_TYPE_DEV; (*def)->type = VIR_DOMAIN_CHR_TYPE_DEV;
(*def)->data.file.path = fileName; (*def)->data.file.path = fileName;
fileName = NULL; fileName = NULL;
} else if (STRCASEEQ(fileType, "file")) { } else if (STRCASEEQ(fileType, "file")) {
(*def)->dstPort = port; (*def)->target.port = port;
(*def)->type = VIR_DOMAIN_CHR_TYPE_FILE; (*def)->type = VIR_DOMAIN_CHR_TYPE_FILE;
(*def)->data.file.path = esxVMX_ParseFileName(conn, ctx, fileName, (*def)->data.file.path = esxVMX_ParseFileName(conn, ctx, fileName,
datastoreName, datastoreName,
...@@ -2706,9 +2710,9 @@ esxVMX_FormatSerial(virConnectPtr conn, esxVI_Context *ctx, ...@@ -2706,9 +2710,9 @@ esxVMX_FormatSerial(virConnectPtr conn, esxVI_Context *ctx,
{ {
char *fileName = NULL; 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, 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; return -1;
} }
...@@ -2719,20 +2723,20 @@ esxVMX_FormatSerial(virConnectPtr conn, esxVI_Context *ctx, ...@@ -2719,20 +2723,20 @@ esxVMX_FormatSerial(virConnectPtr conn, esxVI_Context *ctx,
return -1; 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 */ /* def:type -> vmx:fileType and def:data.file.path -> vmx:fileName */
switch (def->type) { switch (def->type) {
case VIR_DOMAIN_CHR_TYPE_DEV: case VIR_DOMAIN_CHR_TYPE_DEV:
virBufferVSprintf(buffer, "serial%d.fileType = \"device\"\n", virBufferVSprintf(buffer, "serial%d.fileType = \"device\"\n",
def->dstPort); def->target.port);
virBufferVSprintf(buffer, "serial%d.fileName = \"%s\"\n", virBufferVSprintf(buffer, "serial%d.fileName = \"%s\"\n",
def->dstPort, def->data.file.path); def->target.port, def->data.file.path);
break; break;
case VIR_DOMAIN_CHR_TYPE_FILE: case VIR_DOMAIN_CHR_TYPE_FILE:
virBufferVSprintf(buffer, "serial%d.fileType = \"file\"\n", virBufferVSprintf(buffer, "serial%d.fileType = \"file\"\n",
def->dstPort); def->target.port);
fileName = esxVMX_FormatFileName(conn, ctx, def->data.file.path); fileName = esxVMX_FormatFileName(conn, ctx, def->data.file.path);
...@@ -2741,22 +2745,22 @@ esxVMX_FormatSerial(virConnectPtr conn, esxVI_Context *ctx, ...@@ -2741,22 +2745,22 @@ esxVMX_FormatSerial(virConnectPtr conn, esxVI_Context *ctx,
} }
virBufferVSprintf(buffer, "serial%d.fileName = \"%s\"\n", virBufferVSprintf(buffer, "serial%d.fileName = \"%s\"\n",
def->dstPort, fileName); def->target.port, fileName);
VIR_FREE(fileName); VIR_FREE(fileName);
break; break;
case VIR_DOMAIN_CHR_TYPE_PIPE: case VIR_DOMAIN_CHR_TYPE_PIPE:
virBufferVSprintf(buffer, "serial%d.fileType = \"pipe\"\n", virBufferVSprintf(buffer, "serial%d.fileType = \"pipe\"\n",
def->dstPort); def->target.port);
/* FIXME: Based on VI Client GUI default */ /* FIXME: Based on VI Client GUI default */
virBufferVSprintf(buffer, "serial%d.pipe.endPoint = \"client\"\n", virBufferVSprintf(buffer, "serial%d.pipe.endPoint = \"client\"\n",
def->dstPort); def->target.port);
/* FIXME: Based on VI Client GUI default */ /* FIXME: Based on VI Client GUI default */
virBufferVSprintf(buffer, "serial%d.tryNoRxLoss = \"false\"\n", virBufferVSprintf(buffer, "serial%d.tryNoRxLoss = \"false\"\n",
def->dstPort); def->target.port);
virBufferVSprintf(buffer, "serial%d.fileName = \"%s\"\n", virBufferVSprintf(buffer, "serial%d.fileName = \"%s\"\n",
def->dstPort, def->data.file.path); def->target.port, def->data.file.path);
break; break;
default: default:
...@@ -2769,7 +2773,7 @@ esxVMX_FormatSerial(virConnectPtr conn, esxVI_Context *ctx, ...@@ -2769,7 +2773,7 @@ esxVMX_FormatSerial(virConnectPtr conn, esxVI_Context *ctx,
/* vmx:yieldOnMsrRead */ /* vmx:yieldOnMsrRead */
/* FIXME: Based on VI Client GUI default */ /* FIXME: Based on VI Client GUI default */
virBufferVSprintf(buffer, "serial%d.yieldOnMsrRead = \"true\"\n", virBufferVSprintf(buffer, "serial%d.yieldOnMsrRead = \"true\"\n",
def->dstPort); def->target.port);
return 0; return 0;
} }
...@@ -2782,9 +2786,9 @@ esxVMX_FormatParallel(virConnectPtr conn, esxVI_Context *ctx, ...@@ -2782,9 +2786,9 @@ esxVMX_FormatParallel(virConnectPtr conn, esxVI_Context *ctx,
{ {
char *fileName = NULL; 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, 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; return -1;
} }
...@@ -2795,20 +2799,20 @@ esxVMX_FormatParallel(virConnectPtr conn, esxVI_Context *ctx, ...@@ -2795,20 +2799,20 @@ esxVMX_FormatParallel(virConnectPtr conn, esxVI_Context *ctx,
return -1; 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 */ /* def:type -> vmx:fileType and def:data.file.path -> vmx:fileName */
switch (def->type) { switch (def->type) {
case VIR_DOMAIN_CHR_TYPE_DEV: case VIR_DOMAIN_CHR_TYPE_DEV:
virBufferVSprintf(buffer, "parallel%d.fileType = \"device\"\n", virBufferVSprintf(buffer, "parallel%d.fileType = \"device\"\n",
def->dstPort); def->target.port);
virBufferVSprintf(buffer, "parallel%d.fileName = \"%s\"\n", virBufferVSprintf(buffer, "parallel%d.fileName = \"%s\"\n",
def->dstPort, def->data.file.path); def->target.port, def->data.file.path);
break; break;
case VIR_DOMAIN_CHR_TYPE_FILE: case VIR_DOMAIN_CHR_TYPE_FILE:
virBufferVSprintf(buffer, "parallel%d.fileType = \"file\"\n", virBufferVSprintf(buffer, "parallel%d.fileType = \"file\"\n",
def->dstPort); def->target.port);
fileName = esxVMX_FormatFileName(conn, ctx, def->data.file.path); fileName = esxVMX_FormatFileName(conn, ctx, def->data.file.path);
...@@ -2817,7 +2821,7 @@ esxVMX_FormatParallel(virConnectPtr conn, esxVI_Context *ctx, ...@@ -2817,7 +2821,7 @@ esxVMX_FormatParallel(virConnectPtr conn, esxVI_Context *ctx,
} }
virBufferVSprintf(buffer, "parallel%d.fileName = \"%s\"\n", virBufferVSprintf(buffer, "parallel%d.fileName = \"%s\"\n",
def->dstPort, fileName); def->target.port, fileName);
VIR_FREE(fileName); VIR_FREE(fileName);
break; break;
......
...@@ -3406,7 +3406,8 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, ...@@ -3406,7 +3406,8 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn,
virDomainChrDefFree(chr); virDomainChrDefFree(chr);
goto no_memory; 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; def->serials[def->nserials++] = chr;
} }
} else if (STREQ(arg, "-parallel")) { } else if (STREQ(arg, "-parallel")) {
...@@ -3419,7 +3420,8 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn, ...@@ -3419,7 +3420,8 @@ virDomainDefPtr qemuParseCommandLine(virConnectPtr conn,
virDomainChrDefFree(chr); virDomainChrDefFree(chr);
goto no_memory; 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; def->parallels[def->nparallels++] = chr;
} }
} else if (STREQ(arg, "-usbdevice")) { } else if (STREQ(arg, "-usbdevice")) {
......
...@@ -1920,6 +1920,8 @@ qemuPrepareMonitorChr(virConnectPtr conn, ...@@ -1920,6 +1920,8 @@ qemuPrepareMonitorChr(virConnectPtr conn,
virDomainChrDefPtr monitor_chr, virDomainChrDefPtr monitor_chr,
const char *vm) const char *vm)
{ {
monitor_chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_MONITOR;
monitor_chr->type = VIR_DOMAIN_CHR_TYPE_UNIX; monitor_chr->type = VIR_DOMAIN_CHR_TYPE_UNIX;
monitor_chr->data.nix.listen = 1; monitor_chr->data.nix.listen = 1;
......
...@@ -279,21 +279,21 @@ umlBuildCommandLineChr(virConnectPtr conn, ...@@ -279,21 +279,21 @@ umlBuildCommandLineChr(virConnectPtr conn,
switch (def->type) { switch (def->type) {
case VIR_DOMAIN_CHR_TYPE_NULL: 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); virReportOOMError(conn);
return NULL; return NULL;
} }
break; break;
case VIR_DOMAIN_CHR_TYPE_PTY: 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); virReportOOMError(conn);
return NULL; return NULL;
} }
break; break;
case VIR_DOMAIN_CHR_TYPE_DEV: 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) { def->data.file.path) < 0) {
virReportOOMError(conn); virReportOOMError(conn);
return NULL; return NULL;
...@@ -301,7 +301,7 @@ umlBuildCommandLineChr(virConnectPtr conn, ...@@ -301,7 +301,7 @@ umlBuildCommandLineChr(virConnectPtr conn,
break; break;
case VIR_DOMAIN_CHR_TYPE_STDIO: 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); virReportOOMError(conn);
return NULL; return NULL;
} }
...@@ -314,7 +314,7 @@ umlBuildCommandLineChr(virConnectPtr conn, ...@@ -314,7 +314,7 @@ umlBuildCommandLineChr(virConnectPtr conn,
return NULL; 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) { def->data.tcp.service) < 0) {
virReportOOMError(conn); virReportOOMError(conn);
return NULL; return NULL;
...@@ -502,7 +502,7 @@ int umlBuildCommandLine(virConnectPtr conn, ...@@ -502,7 +502,7 @@ int umlBuildCommandLine(virConnectPtr conn,
virDomainChrDefPtr chr = NULL; virDomainChrDefPtr chr = NULL;
char *ret; char *ret;
for (j = 0 ; j < vm->def->nserials ; j++) 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]; chr = vm->def->serials[j];
if (chr) if (chr)
ret = umlBuildCommandLineChr(conn, chr, "ssl"); ret = umlBuildCommandLineChr(conn, chr, "ssl");
......
...@@ -169,7 +169,7 @@ umlIdentifyOneChrPTY(virConnectPtr conn, ...@@ -169,7 +169,7 @@ umlIdentifyOneChrPTY(virConnectPtr conn,
char *cmd; char *cmd;
char *res = NULL; char *res = NULL;
int retries = 0; 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); virReportOOMError(conn);
return -1; return -1;
} }
......
...@@ -2403,9 +2403,9 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { ...@@ -2403,9 +2403,9 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
serialPort->vtbl->GetIRQ(serialPort, &IRQ); serialPort->vtbl->GetIRQ(serialPort, &IRQ);
serialPort->vtbl->GetIOBase(serialPort, &IOBase); serialPort->vtbl->GetIOBase(serialPort, &IOBase);
if ((IRQ == 4) && (IOBase == 1016)) { if ((IRQ == 4) && (IOBase == 1016)) {
def->serials[serialPortIncCount]->dstPort = 0; def->serials[serialPortIncCount]->target.port = 0;
} else if ((IRQ == 3) && (IOBase == 760)) { } else if ((IRQ == 3) && (IOBase == 760)) {
def->serials[serialPortIncCount]->dstPort = 1; def->serials[serialPortIncCount]->target.port = 1;
} }
serialPort->vtbl->GetPath(serialPort, &pathUtf16); serialPort->vtbl->GetPath(serialPort, &pathUtf16);
...@@ -2469,9 +2469,9 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { ...@@ -2469,9 +2469,9 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
parallelPort->vtbl->GetIRQ(parallelPort, &IRQ); parallelPort->vtbl->GetIRQ(parallelPort, &IRQ);
parallelPort->vtbl->GetIOBase(parallelPort, &IOBase); parallelPort->vtbl->GetIOBase(parallelPort, &IOBase);
if ((IRQ == 7) && (IOBase == 888)) { if ((IRQ == 7) && (IOBase == 888)) {
def->parallels[parallelPortIncCount]->dstPort = 0; def->parallels[parallelPortIncCount]->target.port = 0;
} else if ((IRQ == 5) && (IOBase == 632)) { } 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; def->parallels[parallelPortIncCount]->type = VIR_DOMAIN_CHR_TYPE_FILE;
...@@ -3493,7 +3493,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { ...@@ -3493,7 +3493,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
ISerialPort *serialPort = NULL; ISerialPort *serialPort = NULL;
DEBUG("SerialPort(%d): Type: %d", i, def->serials[i]->type); 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); machine->vtbl->GetSerialPort(machine, i, &serialPort);
if (serialPort) { if (serialPort) {
...@@ -3508,17 +3508,17 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { ...@@ -3508,17 +3508,17 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
* TODO: make this more flexible * TODO: make this more flexible
*/ */
/* TODO: to improve the libvirt XMl handling so /* 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 * and not always start at 0
*/ */
if (def->serials[i]->type == VIR_DOMAIN_CHR_TYPE_DEV) { if (def->serials[i]->type == VIR_DOMAIN_CHR_TYPE_DEV) {
serialPort->vtbl->SetPath(serialPort, pathUtf16); 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->SetIRQ(serialPort, 4);
serialPort->vtbl->SetIOBase(serialPort, 1016); serialPort->vtbl->SetIOBase(serialPort, 1016);
DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s", DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s",
i, 4, 1016, def->serials[i]->data.file.path); 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->SetIRQ(serialPort, 3);
serialPort->vtbl->SetIOBase(serialPort, 760); serialPort->vtbl->SetIOBase(serialPort, 760);
DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s", DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s",
...@@ -3527,12 +3527,12 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { ...@@ -3527,12 +3527,12 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
serialPort->vtbl->SetHostMode(serialPort, PortMode_HostDevice); serialPort->vtbl->SetHostMode(serialPort, PortMode_HostDevice);
} else if (def->serials[i]->type == VIR_DOMAIN_CHR_TYPE_PIPE) { } else if (def->serials[i]->type == VIR_DOMAIN_CHR_TYPE_PIPE) {
serialPort->vtbl->SetPath(serialPort, pathUtf16); 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->SetIRQ(serialPort, 4);
serialPort->vtbl->SetIOBase(serialPort, 1016); serialPort->vtbl->SetIOBase(serialPort, 1016);
DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s", DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s",
i, 4, 1016, def->serials[i]->data.file.path); 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->SetIRQ(serialPort, 3);
serialPort->vtbl->SetIOBase(serialPort, 760); serialPort->vtbl->SetIOBase(serialPort, 760);
DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s", DEBUG(" serialPort-%d irq: %d, iobase 0x%x, path: %s",
...@@ -3573,7 +3573,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { ...@@ -3573,7 +3573,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
IParallelPort *parallelPort = NULL; IParallelPort *parallelPort = NULL;
DEBUG("ParallelPort(%d): Type: %d", i, def->parallels[i]->type); 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); machine->vtbl->GetParallelPort(machine, i, &parallelPort);
if (parallelPort) { if (parallelPort) {
......
...@@ -2569,6 +2569,7 @@ xenDaemonParseSxpr(virConnectPtr conn, ...@@ -2569,6 +2569,7 @@ xenDaemonParseSxpr(virConnectPtr conn,
virDomainChrDefFree(chr); virDomainChrDefFree(chr);
goto no_memory; goto no_memory;
} }
chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL;
def->serials[def->nserials++] = chr; def->serials[def->nserials++] = chr;
} }
tmp = sexpr_node(root, "domain/image/hvm/parallel"); tmp = sexpr_node(root, "domain/image/hvm/parallel");
...@@ -2581,12 +2582,14 @@ xenDaemonParseSxpr(virConnectPtr conn, ...@@ -2581,12 +2582,14 @@ xenDaemonParseSxpr(virConnectPtr conn,
virDomainChrDefFree(chr); virDomainChrDefFree(chr);
goto no_memory; goto no_memory;
} }
chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL;
def->parallels[def->nparallels++] = chr; def->parallels[def->nparallels++] = chr;
} }
} else { } else {
/* Fake a paravirt console, since that's not in the sexpr */ /* Fake a paravirt console, since that's not in the sexpr */
if (!(def->console = xenDaemonParseSxprChar(conn, "pty", tty))) if (!(def->console = xenDaemonParseSxprChar(conn, "pty", tty)))
goto error; goto error;
def->console->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE;
} }
VIR_FREE(tty); VIR_FREE(tty);
......
...@@ -1415,6 +1415,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { ...@@ -1415,6 +1415,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) {
virDomainChrDefFree(chr); virDomainChrDefFree(chr);
goto no_memory; goto no_memory;
} }
chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL;
def->parallels[0] = chr; def->parallels[0] = chr;
def->nparallels++; def->nparallels++;
chr = NULL; chr = NULL;
...@@ -1431,12 +1432,14 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { ...@@ -1431,12 +1432,14 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) {
virDomainChrDefFree(chr); virDomainChrDefFree(chr);
goto no_memory; goto no_memory;
} }
chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL;
def->serials[0] = chr; def->serials[0] = chr;
def->nserials++; def->nserials++;
} }
} else { } else {
if (!(def->console = xenDaemonParseSxprChar(conn, "pty", NULL))) if (!(def->console = xenDaemonParseSxprChar(conn, "pty", NULL)))
goto cleanup; goto cleanup;
def->console->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE;
} }
if (hvm) { if (hvm) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册