There is actually a difference between the character device type (serial, parallel, channel, ...) and the target type (virtio, guestfwd). Currently they are awkwardly conflated. Start to pull them apart by renaming targetType -> deviceType. This is an entirely mechanical change. Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx> --- src/conf/domain_conf.c | 74 +++++++++++++++++++++++----------------------- src/conf/domain_conf.h | 22 +++++++------- src/esx/esx_vmx.c | 4 +- src/qemu/qemu_conf.c | 10 +++--- src/qemu/qemu_driver.c | 2 +- src/vbox/vbox_tmpl.c | 4 +- src/xen/xend_internal.c | 6 ++-- src/xen/xm_internal.c | 6 ++-- 8 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5b59c01..faf1629 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -164,7 +164,7 @@ VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST, "internal", "direct") -VIR_ENUM_IMPL(virDomainChrTarget, VIR_DOMAIN_CHR_TARGET_TYPE_LAST, +VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST, "null", "monitor", "parallel", @@ -523,12 +523,12 @@ void virDomainChrDefFree(virDomainChrDefPtr def) if (!def) return; - switch (def->targetType) { - case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD: + switch (def->deviceType) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: VIR_FREE(def->target.addr); break; - case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO: + case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: VIR_FREE(def->target.name); break; } @@ -2415,7 +2415,7 @@ virDomainChrDefParseXML(xmlNodePtr node, char *mode = NULL; char *protocol = NULL; const char *nodeName; - const char *targetType = NULL; + const char *deviceType = NULL; const char *addrStr = NULL; const char *portStr = NULL; virDomainChrDefPtr def; @@ -2432,7 +2432,7 @@ virDomainChrDefParseXML(xmlNodePtr node, def->type = VIR_DOMAIN_CHR_TYPE_NULL; nodeName = (const char *) node->name; - if ((def->targetType = virDomainChrTargetTypeFromString(nodeName)) < 0) { + if ((def->deviceType = virDomainChrDeviceTypeFromString(nodeName)) < 0) { /* channel is handled below */ if (STRNEQ(nodeName, "channel")) { virDomainReportError(VIR_ERR_XML_ERROR, @@ -2441,7 +2441,7 @@ virDomainChrDefParseXML(xmlNodePtr node, VIR_FREE(def); return NULL; } - def->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_NULL; + def->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_NULL; } cur = node->children; @@ -2491,30 +2491,30 @@ virDomainChrDefParseXML(xmlNodePtr node, protocol = virXMLPropString(cur, "type"); } else if (xmlStrEqual(cur->name, BAD_CAST "target")) { /* If target type isn't set yet, expect it to be set here */ - if (def->targetType == VIR_DOMAIN_CHR_TARGET_TYPE_NULL) { - targetType = virXMLPropString(cur, "type"); - if (targetType == NULL) { + if (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_NULL) { + deviceType = virXMLPropString(cur, "type"); + if (deviceType == NULL) { virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("character device target does " "not define a type")); goto error; } - if ((def->targetType = - virDomainChrTargetTypeFromString(targetType)) < 0) + if ((def->deviceType = + virDomainChrDeviceTypeFromString(deviceType)) < 0) { virDomainReportError(VIR_ERR_XML_ERROR, _("unknown target type for " "character device: %s"), - targetType); + deviceType); goto error; } } unsigned int port; - switch (def->targetType) { - case VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL: - case VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL: - case VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE: + switch (def->deviceType) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: portStr = virXMLPropString(cur, "port"); if (portStr == NULL) { /* Not required. It will be assigned automatically @@ -2530,7 +2530,7 @@ virDomainChrDefParseXML(xmlNodePtr node, } break; - case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD: + case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: addrStr = virXMLPropString(cur, "address"); portStr = virXMLPropString(cur, "port"); @@ -2574,14 +2574,14 @@ virDomainChrDefParseXML(xmlNodePtr node, virSocketSetPort(def->target.addr, port); break; - case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO: + case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: def->target.name = virXMLPropString(cur, "name"); break; default: virDomainReportError(VIR_ERR_XML_ERROR, _("unexpected target type type %u"), - def->targetType); + def->deviceType); } } } @@ -2714,7 +2714,7 @@ cleanup: VIR_FREE(connectHost); VIR_FREE(connectService); VIR_FREE(path); - VIR_FREE(targetType); + VIR_FREE(deviceType); VIR_FREE(addrStr); VIR_FREE(portStr); @@ -4473,7 +4473,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, } def->nserials = 1; def->serials[0] = chr; - chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; } } else { def->console = chr; @@ -4496,7 +4496,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, def->channels[def->nchannels++] = chr; - if (chr->targetType == VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO && + if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO && chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) chr->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL; @@ -5011,7 +5011,7 @@ static int virDomainDefMaybeAddVirtioSerialController(virDomainDefPtr def) for (i = 0 ; i < def->nchannels ; i++) { virDomainChrDefPtr channel = def->channels[i]; - if (channel->targetType == VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO) { + if (channel->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO) { int idx = 0; if (channel->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL) idx = channel->info.addr.vioserial.controller; @@ -5593,15 +5593,15 @@ virDomainChrDefFormat(virBufferPtr buf, int flags) { const char *type = virDomainChrTypeToString(def->type); - const char *targetName = virDomainChrTargetTypeToString(def->targetType); + const char *targetName = virDomainChrDeviceTypeToString(def->deviceType); const char *elementName; int ret = 0; - switch (def->targetType) { + switch (def->deviceType) { /* channel types are in a common channel element */ - case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD: - case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO: + case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: + case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: elementName = "channel"; break; @@ -5618,7 +5618,7 @@ virDomainChrDefFormat(virBufferPtr buf, /* Compat with legacy <console tty='/dev/pts/5'/> syntax */ virBufferVSprintf(buf, " <%s type='%s'", elementName, type); - if (def->targetType == VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE && + if (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && def->type == VIR_DOMAIN_CHR_TYPE_PTY && !(flags & VIR_DOMAIN_XML_INACTIVE) && def->data.file.path) { @@ -5693,8 +5693,8 @@ virDomainChrDefFormat(virBufferPtr buf, break; } - switch (def->targetType) { - case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD: + switch (def->deviceType) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: { int port = virSocketGetPort(def->target.addr); if (port < 0) { @@ -5715,7 +5715,7 @@ virDomainChrDefFormat(virBufferPtr buf, break; } - case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO: + case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: virBufferAddLit(buf, " <target type='virtio'"); if (def->target.name) { virBufferEscapeString(buf, " name='%s'", def->target.name); @@ -5723,16 +5723,16 @@ virDomainChrDefFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); break; - case VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL: - case VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL: - case VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE: + case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: + case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: virBufferVSprintf(buf, " <target port='%d'/>\n", def->target.port); break; default: virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected character destination type %d"), - def->targetType); + def->deviceType); return -1; } @@ -6370,7 +6370,7 @@ char *virDomainDefFormat(virDomainDefPtr def, * console */ virDomainChrDef console; memcpy(&console, def->serials[0], sizeof(console)); - console.targetType = VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE; + console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; if (virDomainChrDefFormat(&buf, &console, flags) < 0) goto cleanup; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9ef687b..86cc02a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -313,16 +313,16 @@ struct _virDomainNetDef { virNWFilterHashTablePtr filterparams; }; -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_GUESTFWD, - VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO, +enum virDomainChrDeviceType { + VIR_DOMAIN_CHR_DEVICE_TYPE_NULL = 0, + VIR_DOMAIN_CHR_DEVICE_TYPE_MONITOR, + VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL, + VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL, + VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE, + VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD, + VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO, - VIR_DOMAIN_CHR_TARGET_TYPE_LAST + VIR_DOMAIN_CHR_DEVICE_TYPE_LAST }; enum virDomainChrType { @@ -350,7 +350,7 @@ enum virDomainChrTcpProtocol { typedef struct _virDomainChrDef virDomainChrDef; typedef virDomainChrDef *virDomainChrDefPtr; struct _virDomainChrDef { - int targetType; + int deviceType; union { int port; /* parallel, serial, console */ virSocketAddrPtr addr; /* guestfwd */ @@ -1129,7 +1129,7 @@ VIR_ENUM_DECL(virDomainController) VIR_ENUM_DECL(virDomainControllerModel) VIR_ENUM_DECL(virDomainFS) VIR_ENUM_DECL(virDomainNet) -VIR_ENUM_DECL(virDomainChrTarget) +VIR_ENUM_DECL(virDomainChrDevice) VIR_ENUM_DECL(virDomainChr) VIR_ENUM_DECL(virDomainSoundModel) VIR_ENUM_DECL(virDomainMemballoonModel) diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c index c63b159..28bddc9 100644 --- a/src/esx/esx_vmx.c +++ b/src/esx/esx_vmx.c @@ -2396,7 +2396,7 @@ esxVMX_ParseSerial(esxVI_Context *ctx, virConfPtr conf, int port, return -1; } - (*def)->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL; + (*def)->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; snprintf(prefix, sizeof(prefix), "serial%d", port); @@ -2526,7 +2526,7 @@ esxVMX_ParseParallel(esxVI_Context *ctx, virConfPtr conf, int port, return -1; } - (*def)->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL; + (*def)->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; snprintf(prefix, sizeof(prefix), "parallel%d", port); diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 0dbab48..bcca274 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -4477,8 +4477,8 @@ int qemudBuildCommandLine(virConnectPtr conn, virDomainChrDefPtr channel = def->channels[i]; char *devstr; - switch(channel->targetType) { - case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD: + switch(channel->deviceType) { + case VIR_DOMAIN_CHR_DEVICE_TYPE_GUESTFWD: if (!(qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV) || !(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) { qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -4504,7 +4504,7 @@ int qemudBuildCommandLine(virConnectPtr conn, ADD_ARG(devstr); break; - case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO: + case VIR_DOMAIN_CHR_DEVICE_TYPE_VIRTIO: if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) { qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("virtio channel requires QEMU to support -device")); @@ -6215,7 +6215,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, virDomainChrDefFree(chr); goto no_memory; } - chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; chr->target.port = def->nserials; def->serials[def->nserials++] = chr; } @@ -6229,7 +6229,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, virDomainChrDefFree(chr); goto no_memory; } - chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; chr->target.port = def->nparallels; def->parallels[def->nparallels++] = chr; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d0bbc63..4558674 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3557,7 +3557,7 @@ qemuPrepareMonitorChr(struct qemud_driver *driver, virDomainChrDefPtr monConfig, const char *vm) { - monConfig->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_MONITOR; + monConfig->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_MONITOR; monConfig->type = VIR_DOMAIN_CHR_TYPE_UNIX; monConfig->data.nix.listen = 1; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index edc7a72..0a91c7f 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2839,7 +2839,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { def->serials[serialPortIncCount]->type = VIR_DOMAIN_CHR_TYPE_NULL; } - def->serials[serialPortIncCount]->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL; + def->serials[serialPortIncCount]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; serialPort->vtbl->GetIRQ(serialPort, &IRQ); serialPort->vtbl->GetIOBase(serialPort, &IOBase); @@ -2918,7 +2918,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { } def->parallels[parallelPortIncCount]->type = VIR_DOMAIN_CHR_TYPE_FILE; - def->parallels[parallelPortIncCount]->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL; + def->parallels[parallelPortIncCount]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; parallelPort->vtbl->GetPath(parallelPort, &pathUtf16); diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index a22d32b..a492231 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -2346,7 +2346,7 @@ xenDaemonParseSxpr(virConnectPtr conn, virDomainChrDefFree(chr); goto no_memory; } - chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; def->serials[def->nserials++] = chr; } tmp = sexpr_node(root, "domain/image/hvm/parallel"); @@ -2359,14 +2359,14 @@ xenDaemonParseSxpr(virConnectPtr conn, virDomainChrDefFree(chr); goto no_memory; } - chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; def->parallels[def->nparallels++] = chr; } } else { /* Fake a paravirt console, since that's not in the sexpr */ if (!(def->console = xenDaemonParseSxprChar("pty", tty))) goto error; - def->console->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE; + def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; } VIR_FREE(tty); diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index a7a09a0..4230504 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -1416,7 +1416,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { virDomainChrDefFree(chr); goto no_memory; } - chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; def->parallels[0] = chr; def->nparallels++; chr = NULL; @@ -1433,14 +1433,14 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { virDomainChrDefFree(chr); goto no_memory; } - chr->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL; + chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; def->serials[0] = chr; def->nserials++; } } else { if (!(def->console = xenDaemonParseSxprChar("pty", NULL))) goto cleanup; - def->console->targetType = VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE; + def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; } if (hvm) { -- 1.7.1.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list