mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
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.
This commit is contained in:
parent
8db32571ba
commit
89d549c3eb
@ -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",
|
||||
@ -1325,6 +1332,7 @@ virDomainChrDefParseXML(virConnectPtr conn,
|
||||
char *path = NULL;
|
||||
char *mode = NULL;
|
||||
char *protocol = NULL;
|
||||
const char *targetType = NULL;
|
||||
virDomainChrDefPtr def;
|
||||
|
||||
if (VIR_ALLOC(def) < 0) {
|
||||
@ -1338,6 +1346,20 @@ 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, "%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;
|
||||
while (cur != NULL) {
|
||||
if (cur->type == XML_ELEMENT_NODE) {
|
||||
@ -2931,7 +2953,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);
|
||||
@ -2951,7 +2973,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);
|
||||
@ -2963,7 +2985,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
|
||||
@ -3965,10 +3987,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,
|
||||
@ -3978,8 +4002,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) {
|
||||
@ -4054,11 +4078,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;
|
||||
}
|
||||
@ -4505,21 +4541,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;
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
@ -812,6 +825,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)
|
||||
|
@ -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 #############################################################
|
||||
@ -1871,6 +1871,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);
|
||||
@ -1907,13 +1909,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,
|
||||
@ -1927,7 +1929,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;
|
||||
|
||||
@ -1993,6 +1995,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);
|
||||
@ -2029,13 +2033,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,
|
||||
@ -2706,9 +2710,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;
|
||||
}
|
||||
|
||||
@ -2719,20 +2723,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);
|
||||
|
||||
@ -2741,22 +2745,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:
|
||||
@ -2769,7 +2773,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;
|
||||
}
|
||||
@ -2782,9 +2786,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;
|
||||
}
|
||||
|
||||
@ -2795,20 +2799,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);
|
||||
|
||||
@ -2817,7 +2821,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;
|
||||
|
@ -3406,7 +3406,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")) {
|
||||
@ -3419,7 +3420,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")) {
|
||||
|
@ -1920,6 +1920,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;
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -2403,9 +2403,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);
|
||||
@ -2469,9 +2469,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;
|
||||
@ -3493,7 +3493,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) {
|
||||
@ -3508,17 +3508,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",
|
||||
@ -3527,12 +3527,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",
|
||||
@ -3573,7 +3573,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, ¶llelPort);
|
||||
if (parallelPort) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user