domain conf: Rename character prop targetType -> deviceType

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@redhat.com>
This commit is contained in:
Cole Robinson 2010-07-13 15:05:34 -04:00
parent 4a34633a7f
commit 50147933a5
8 changed files with 64 additions and 64 deletions

View File

@ -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);
@ -4484,7 +4484,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;
@ -4507,7 +4507,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;
@ -5022,7 +5022,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;
@ -5604,15 +5604,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;
@ -5629,7 +5629,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) {
@ -5704,8 +5704,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) {
@ -5726,7 +5726,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);
@ -5734,16 +5734,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;
}
@ -6388,7 +6388,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;
}

View File

@ -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 */
@ -1135,7 +1135,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)

View File

@ -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);

View File

@ -4498,8 +4498,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,
@ -4525,7 +4525,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"));
@ -6253,7 +6253,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;
}
@ -6267,7 +6267,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;
}

View File

@ -3573,7 +3573,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;

View File

@ -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);

View File

@ -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);

View File

@ -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) {