virCaps: get rid of defaultConsoleTargetType callback

This patch refactors various places to allow removing of the
defaultConsoleTargetType callback from the virCaps structure.

A new console character device target type is introduced -
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE - to mark that no type was
specified in the XML. This type is at the end converted to the standard
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL. Other types that are
different from this default have to be processed separately in the
device post parse callback.
This commit is contained in:
Peter Krempa 2013-03-13 21:39:34 +01:00
parent 46becc18ba
commit 482e5f159c
32 changed files with 278 additions and 315 deletions

View File

@ -160,9 +160,6 @@ struct _virCaps {
size_t nguests;
size_t nguests_max;
virCapsGuestPtr *guests;
/* Move to virDomainXMLOption later */
int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch);
};

View File

@ -385,6 +385,7 @@ VIR_ENUM_IMPL(virDomainChrChannelTarget,
VIR_ENUM_IMPL(virDomainChrConsoleTarget,
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST,
"none",
"serial",
"xen",
"uml",
@ -2347,9 +2348,11 @@ virDomainDeviceInfoClearCCWAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
return 0;
}
int virDomainDeviceInfoIterate(virDomainDefPtr def,
virDomainDeviceInfoCallback cb,
void *opaque)
static int
virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
virDomainDeviceInfoCallback cb,
bool all,
void *opaque)
{
int i;
virDomainDeviceDef device;
@ -2413,9 +2416,11 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def,
return -1;
}
for (i = 0; i < def->nconsoles ; i++) {
if (i == 0 &&
def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL &&
STREQ_NULLABLE(def->os.type, "hvm"))
if (!all &&
i == 0 &&
(def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) &&
STREQ_NULLABLE(def->os.type, "hvm"))
continue;
device.data.chr = def->consoles[i];
if (cb(def, &device, &def->consoles[i]->info, opaque) < 0)
@ -2491,10 +2496,21 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def,
}
int
virDomainDeviceInfoIterate(virDomainDefPtr def,
virDomainDeviceInfoCallback cb,
void *opaque)
{
return virDomainDeviceInfoIterateInternal(def, cb, false, opaque);
}
static int
virDomainDefPostParseInternal(virDomainDefPtr def,
virCapsPtr caps ATTRIBUTE_UNUSED)
{
int i;
/* verify init path for container based domains */
if (STREQ(def->os.type, "exe") && !def->os.init) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@ -2502,6 +2518,91 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
return -1;
}
/*
* Some really crazy backcompat stuff for consoles
*
* Historically the first (and only) '<console>' element in an HVM guest
* was treated as being an alias for a <serial> device.
*
* So if we see that this console device should be a serial device, then we
* move the config over to def->serials[0] (or discard it if that already
* exists). However, given console can already be filled with aliased data
* of def->serials[0]. Keep it then.
*
* We then fill def->consoles[0] with a stub just so we get sequencing
* correct for consoles > 0
*/
if (def->nconsoles > 0 && STREQ(def->os.type, "hvm") &&
(def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)) {
/* First verify that only the first console is of type serial */
for (i = 1; i < def->nconsoles; i++) {
virDomainChrDefPtr cons = def->consoles[i];
if (cons->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Only the first console can be a serial port"));
return -1;
}
}
/* If there isn't a corresponding serial port:
* - create one and set, the console to be an alias for it
*
* If there is a corresponding serial port:
* - Check if the source definition is equal:
* - if yes: leave it as-is
* - if no: change the console to be alias of the serial port
*/
/* create the serial port definition from the console definition */
if (def->nserials == 0) {
if (VIR_APPEND_ELEMENT(def->serials, def->nserials,
def->consoles[0]) < 0)
goto no_memory;
/* modify it to be a serial port */
def->serials[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
def->serials[0]->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
def->serials[0]->target.port = 0;
} else {
/* if the console source doesn't match */
if (!virDomainChrSourceDefIsEqual(&def->serials[0]->source,
&def->consoles[0]->source)) {
virDomainChrDefFree(def->consoles[0]);
def->consoles[0] = NULL;
}
}
if (!def->consoles[0]) {
/* allocate a new console type for the stolen one */
if (VIR_ALLOC(def->consoles[0]) < 0)
goto no_memory;
/* Create an console alias for the serial port */
def->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
def->consoles[0]->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
}
return 0;
no_memory:
virReportOOMError();
return -1;
}
static int
virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
virDomainDefPtr def ATTRIBUTE_UNUSED,
virCapsPtr caps ATTRIBUTE_UNUSED)
{
if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
return 0;
}
@ -2521,6 +2622,9 @@ virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
return ret;
}
if ((ret = virDomainDeviceDefPostParseInternal(dev, def, caps)) < 0)
return ret;
return 0;
}
@ -2564,9 +2668,10 @@ virDomainDefPostParse(virDomainDefPtr def,
}
/* iterate the devices */
if ((ret = virDomainDeviceInfoIterate(def,
virDomainDefPostParseDeviceIterator,
&data)) < 0)
if ((ret = virDomainDeviceInfoIterateInternal(def,
virDomainDefPostParseDeviceIterator,
true,
&data)) < 0)
return ret;
@ -5923,87 +6028,66 @@ error:
}
static int
virDomainChrDefaultTargetType(virCapsPtr caps,
virDomainDefPtr def,
int devtype) {
int target = -1;
switch (devtype) {
virDomainChrDefaultTargetType(int devtype) {
switch ((enum virDomainChrDeviceType) devtype) {
case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL:
virReportError(VIR_ERR_XML_ERROR,
_("target type must be specified for %s device"),
virDomainChrDeviceTypeToString(devtype));
break;
return -1;
case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
if (!caps->defaultConsoleTargetType) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Driver does not have a default console type set"));
return -1;
}
target = caps->defaultConsoleTargetType(def->os.type, def->os.arch);
break;
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE;
case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
target = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
break;
return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
default:
case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
/* No target type yet*/
target = 0;
break;
}
return target;
return 0;
}
static int
virDomainChrTargetTypeFromString(virCapsPtr caps,
virDomainDefPtr vmdef,
virDomainChrDefPtr def,
virDomainChrTargetTypeFromString(virDomainChrDefPtr def,
int devtype,
const char *targetType)
{
int ret = -1;
int target = 0;
if (!targetType) {
target = virDomainChrDefaultTargetType(caps, vmdef, devtype);
goto out;
}
if (!targetType)
return virDomainChrDefaultTargetType(devtype);
switch (devtype) {
switch ((enum virDomainChrDeviceType) devtype) {
case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL:
target = virDomainChrChannelTargetTypeFromString(targetType);
ret = virDomainChrChannelTargetTypeFromString(targetType);
break;
case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
target = virDomainChrConsoleTargetTypeFromString(targetType);
ret = virDomainChrConsoleTargetTypeFromString(targetType);
break;
case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
target = virDomainChrSerialTargetTypeFromString(targetType);
ret = virDomainChrSerialTargetTypeFromString(targetType);
break;
case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
default:
case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
/* No target type yet*/
ret = 0;
break;
}
def->targetTypeAttr = true;
out:
ret = target;
return ret;
}
static int
virDomainChrDefParseTargetXML(virCapsPtr caps,
virDomainDefPtr vmdef,
virDomainChrDefPtr def,
virDomainChrDefParseTargetXML(virDomainChrDefPtr def,
xmlNodePtr cur)
{
int ret = -1;
@ -6013,8 +6097,8 @@ virDomainChrDefParseTargetXML(virCapsPtr caps,
const char *portStr = NULL;
if ((def->targetType =
virDomainChrTargetTypeFromString(caps, vmdef, def,
def->deviceType, targetType)) < 0) {
virDomainChrTargetTypeFromString(def, def->deviceType,
targetType)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("unknown target type '%s' specified for character device"),
targetType);
@ -6373,9 +6457,7 @@ virDomainChrDefNew(void) {
*
*/
static virDomainChrDefPtr
virDomainChrDefParseXML(virCapsPtr caps,
virDomainDefPtr vmdef,
xmlXPathContextPtr ctxt,
virDomainChrDefParseXML(xmlXPathContextPtr ctxt,
xmlNodePtr node,
virSecurityLabelDefPtr* vmSeclabels,
int nvmSeclabels,
@ -6419,7 +6501,7 @@ virDomainChrDefParseXML(virCapsPtr caps,
if (cur->type == XML_ELEMENT_NODE) {
if (xmlStrEqual(cur->name, BAD_CAST "target")) {
seenTarget = true;
if (virDomainChrDefParseTargetXML(caps, vmdef, def, cur) < 0) {
if (virDomainChrDefParseTargetXML(def, cur) < 0) {
goto error;
}
}
@ -6429,7 +6511,7 @@ virDomainChrDefParseXML(virCapsPtr caps,
}
if (!seenTarget &&
((def->targetType = virDomainChrDefaultTargetType(caps, vmdef, def->deviceType)) < 0))
((def->targetType = virDomainChrDefaultTargetType(def->deviceType)) < 0))
goto cleanup;
if (def->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) {
@ -10557,9 +10639,7 @@ virDomainDefParseXML(xmlDocPtr xml,
goto no_memory;
for (i = 0 ; i < n ; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(caps,
def,
ctxt,
virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt,
nodes[i],
def->seclabels,
def->nseclabels,
@ -10587,9 +10667,7 @@ virDomainDefParseXML(xmlDocPtr xml,
goto no_memory;
for (i = 0 ; i < n ; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(caps,
def,
ctxt,
virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt,
nodes[i],
def->seclabels,
def->nseclabels,
@ -10619,10 +10697,7 @@ virDomainDefParseXML(xmlDocPtr xml,
goto no_memory;
for (i = 0 ; i < n ; i++) {
bool create_stub = true;
virDomainChrDefPtr chr = virDomainChrDefParseXML(caps,
def,
ctxt,
virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt,
nodes[i],
def->seclabels,
def->nseclabels,
@ -10630,64 +10705,7 @@ virDomainDefParseXML(xmlDocPtr xml,
if (!chr)
goto error;
/*
* Some really crazy backcompat stuff for consoles
*
* Historically the first (and only) '<console>'
* element in an HVM guest was treated as being
* an alias for a <serial> device.
*
* So if we see that this console device should
* be a serial device, then we move the config
* over to def->serials[0] (or discard it if
* that already exists). However, given console
* can already be filled with aliased data of
* def->serials[0]. Keep it then.
*
* We then fill def->consoles[0] with a stub
* just so we get sequencing correct for consoles
* > 0
*/
if (STREQ(def->os.type, "hvm") &&
(chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL)) {
if (i != 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Only the first console can be a serial port"));
virDomainChrDefFree(chr);
goto error;
}
/* Either discard or move this chr to the serial config */
if (def->nserials != 0) {
if (virDomainChrSourceDefIsEqual(&def->serials[0]->source,
&chr->source)) {
/* Alias to def->serial[0]. Skip it */
create_stub = false;
} else {
virDomainChrDefFree(chr);
}
} else {
if (VIR_ALLOC_N(def->serials, 1) < 0) {
virDomainChrDefFree(chr);
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
def->nserials = 1;
def->serials[0] = chr;
chr->target.port = 0;
}
if (create_stub) {
/* And create a stub placeholder */
if (VIR_ALLOC(chr) < 0)
goto no_memory;
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
}
chr->target.port = i;
def->consoles[def->nconsoles++] = chr;
}
VIR_FREE(nodes);
@ -10699,9 +10717,7 @@ virDomainDefParseXML(xmlDocPtr xml,
goto no_memory;
for (i = 0 ; i < n ; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(caps,
def,
ctxt,
virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt,
nodes[i],
def->seclabels,
def->nseclabels,
@ -15200,7 +15216,6 @@ virDomainDefFormatInternal(virDomainDefPtr def,
if (virDomainFSDefFormat(buf, def->fss[n], flags) < 0)
goto error;
for (n = 0 ; n < def->nnets ; n++)
if (virDomainNetDefFormat(buf, def->nets[n], flags) < 0)
goto error;
@ -15223,7 +15238,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
* if it is type == serial
*/
if (STREQ(def->os.type, "hvm") &&
(def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) &&
(def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) &&
(n < def->nserials)) {
memcpy(&console, def->serials[n], sizeof(console));
console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
@ -15240,6 +15256,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virDomainChrDef console;
memcpy(&console, def->serials[n], sizeof(console));
console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
console.targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
if (virDomainChrDefFormat(buf, &console, flags) < 0)
goto error;
}

View File

@ -956,7 +956,8 @@ enum virDomainChrChannelTargetType {
};
enum virDomainChrConsoleTargetType {
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL = 0,
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE = 0,
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL,
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN,
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML,
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,

View File

@ -569,13 +569,6 @@ esxLookupHostSystemBiosUuid(esxPrivate *priv, unsigned char *uuid)
}
static int esxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
static virCapsPtr
esxCapsInit(esxPrivate *priv)
{
@ -600,7 +593,6 @@ esxCapsInit(esxPrivate *priv)
virCapabilitiesAddHostMigrateTransport(caps, "vpxmigr");
caps->defaultConsoleTargetType = esxDefaultConsoleType;
if (esxLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0) {
goto failure;

View File

@ -64,15 +64,6 @@ static const char *xen_cap_re = "(xen|hvm)-[[:digit:]]+\\.[[:digit:]]+-(x86_32|x
static regex_t xen_cap_rec;
static int libxlDefaultConsoleType(const char *ostype,
virArch arch ATTRIBUTE_UNUSED)
{
if (STREQ(ostype, "hvm"))
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
else
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
}
static virCapsPtr
libxlBuildCapabilities(virArch hostarch,
int host_pae,
@ -162,8 +153,6 @@ libxlBuildCapabilities(virArch hostarch,
}
}
caps->defaultConsoleTargetType = libxlDefaultConsoleType;
return caps;
no_memory:

View File

@ -431,10 +431,29 @@ virDomainXMLPrivateDataCallbacks libxlDomainXMLPrivateDataCallbacks = {
.free = libxlDomainObjPrivateFree,
};
static int
libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def,
virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
STRNEQ(def->os.type, "hvm"))
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
return 0;
}
virDomainDefParserConfig libxlDomainDefParserConfig = {
.macPrefix = { 0x00, 0x16, 0x3e },
.devicesPostParseCallback = libxlDomainDeviceDefPostParse,
};
/* driver must be locked before calling */
static void
libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event)

View File

@ -41,12 +41,6 @@
#define VIR_FROM_THIS VIR_FROM_LXC
static int lxcDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC;
}
/* Functions */
virCapsPtr lxcCapsInit(virLXCDriverPtr driver)
@ -59,8 +53,6 @@ virCapsPtr lxcCapsInit(virLXCDriverPtr driver)
0, 0)) == NULL)
goto error;
caps->defaultConsoleTargetType = lxcDefaultConsoleType;
/* Some machines have problematic NUMA toplogy causing
* unexpected failures. We don't want to break the QEMU
* driver in this scenario, so log errors & carry on

View File

@ -93,6 +93,23 @@ virLXCDomainDefPostParse(virDomainDefPtr def,
return 0;
}
static int
virLXCDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def ATTRIBUTE_UNUSED,
virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC;
return 0;
}
virDomainDefParserConfig virLXCDriverDomainDefParserConfig = {
.domainPostParseCallback = virLXCDomainDefPostParse,
.devicesPostParseCallback = virLXCDomainDeviceDefPostParse,
};

View File

@ -168,13 +168,6 @@ error:
}
static int openvzDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ;
}
virCapsPtr openvzCapsInit(void)
{
virCapsPtr caps;
@ -204,9 +197,8 @@ virCapsPtr openvzCapsInit(void)
NULL) == NULL)
goto no_memory;
caps->defaultConsoleTargetType = openvzDefaultConsoleType;
return caps;
no_memory:
virObjectUnref(caps);
return NULL;

View File

@ -115,8 +115,24 @@ openvzDomainDefPostParse(virDomainDefPtr def,
}
static int
openvzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def ATTRIBUTE_UNUSED,
virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ;
return 0;
}
virDomainDefParserConfig openvzDomainDefParserConfig = {
.domainPostParseCallback = openvzDomainDefPostParse,
.devicesPostParseCallback = openvzDomainDeviceDefPostParse,
};

View File

@ -96,12 +96,6 @@ parallelsDriverUnlock(parallelsConnPtr driver)
virMutexUnlock(&driver->lock);
}
static int
parallelsDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
static void
parallelsDomObjFreePrivate(void *p)
@ -149,7 +143,6 @@ parallelsBuildCapabilities(void)
"parallels", NULL, NULL, 0, NULL) == NULL)
goto no_memory;
caps->defaultConsoleTargetType = parallelsDefaultConsoleType;
return caps;
no_memory:

View File

@ -300,13 +300,6 @@ phypGetVIOSPartitionID(virConnectPtr conn)
}
static int phypDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
static virCapsPtr
phypCapsInit(void)
{
@ -337,8 +330,6 @@ phypCapsInit(void)
"phyp", NULL, NULL, 0, NULL) == NULL)
goto no_memory;
caps->defaultConsoleTargetType = phypDefaultConsoleType;
return caps;
no_memory:

View File

@ -856,17 +856,6 @@ error:
}
static int virQEMUCapsDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch)
{
if (arch == VIR_ARCH_S390 ||
arch == VIR_ARCH_S390X)
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
else
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
{
virCapsPtr caps;
@ -906,8 +895,6 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
i) < 0)
goto error;
caps->defaultConsoleTargetType = virQEMUCapsDefaultConsoleType;
return caps;
error:

View File

@ -731,6 +731,13 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
}
}
/* set the default console type for S390 arches */
if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
(def->os.arch == VIR_ARCH_S390 || def->os.arch == VIR_ARCH_S390X))
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
ret = 0;
cleanup:

View File

@ -687,11 +687,6 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
return rc;
}
static int aaDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
static int
get_definition(vahControl * ctl, const char *xmlStr)
@ -716,8 +711,6 @@ get_definition(vahControl * ctl, const char *xmlStr)
goto exit;
}
ctl->caps->defaultConsoleTargetType = aaDefaultConsoleType;
if ((guest = virCapabilitiesAddGuest(ctl->caps,
ctl->hvm,
ctl->arch,

View File

@ -152,13 +152,6 @@ static void testDomainObjPrivateFree(void *data)
}
static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
static virDomainXMLOptionPtr
testBuildXMLConfig(void)
{
@ -179,8 +172,6 @@ testBuildCapabilities(virConnectPtr conn) {
if ((caps = virCapabilitiesNew(VIR_ARCH_I686, 0, 0)) == NULL)
goto no_memory;
caps->defaultConsoleTargetType = testDefaultConsoleType;
if (virCapabilitiesAddHostFeature(caps, "pae") < 0)
goto no_memory;
if (virCapabilitiesAddHostFeature(caps ,"nonpae") < 0)

View File

@ -52,13 +52,6 @@
#define VIR_FROM_THIS VIR_FROM_UML
static int umlDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML;
}
virCapsPtr umlCapsInit(void) {
virCapsPtr caps;
virCapsGuestPtr guest;
@ -102,8 +95,6 @@ virCapsPtr umlCapsInit(void) {
NULL) == NULL)
goto error;
caps->defaultConsoleTargetType = umlDefaultConsoleType;
return caps;
error:

View File

@ -420,6 +420,27 @@ cleanup:
umlDriverUnlock(driver);
}
static int
umlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def ATTRIBUTE_UNUSED,
virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML;
return 0;
}
virDomainDefParserConfig umlDriverDomainDefParserConfig = {
.devicesPostParseCallback = umlDomainDeviceDefPostParse,
};
/**
* umlStartup:
*
@ -505,7 +526,8 @@ umlStartup(bool privileged,
if ((uml_driver->caps = umlCapsInit()) == NULL)
goto out_of_memory;
if (!(uml_driver->xmlopt = virDomainXMLOptionNew(NULL, &privcb, NULL)))
if (!(uml_driver->xmlopt = virDomainXMLOptionNew(&umlDriverDomainDefParserConfig,
&privcb, NULL)))
goto error;
if ((uml_driver->inotifyFD = inotify_init()) < 0) {

View File

@ -844,13 +844,6 @@ cleanup:
}
static int vboxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
static virDomainDefParserConfig vboxDomainDefParserConfig = {
.macPrefix = { 0x08, 0x00, 0x27 },
};
@ -893,8 +886,6 @@ static virCapsPtr vboxCapsInit(void)
NULL) == NULL)
goto no_memory;
caps->defaultConsoleTargetType = vboxDefaultConsoleType;
return caps;
no_memory:

View File

@ -50,13 +50,6 @@ vmwareFreeDriver(struct vmware_driver *driver)
}
static int vmwareDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
virCapsPtr
vmwareCapsInit(void)
{
@ -122,8 +115,6 @@ vmwareCapsInit(void)
goto error;
}
caps->defaultConsoleTargetType = vmwareDefaultConsoleType;
cleanup:
virCPUDefFree(cpu);
if (caps)

View File

@ -265,11 +265,36 @@ xenUnifiedXendProbe(void)
#endif
static int
xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def,
virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
STRNEQ(def->os.type, "hvm"))
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
return 0;
}
virDomainDefParserConfig xenDomainDefParserConfig = {
.macPrefix = { 0x00, 0x16, 0x3e },
.devicesPostParseCallback = xenDomainDeviceDefPostParse,
};
virDomainXMLOptionPtr
xenDomainXMLConfInit(void)
{
return virDomainXMLOptionNew(&xenDomainDefParserConfig,
NULL, NULL);
}
static virDrvOpenStatus
xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
{
@ -405,8 +430,7 @@ xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
goto fail;
}
if (!(priv->xmlopt = virDomainXMLOptionNew(&xenDomainDefParserConfig,
NULL, NULL)))
if (!(priv->xmlopt = xenDomainXMLConfInit()))
goto fail;
#if WITH_XEN_INOTIFY

View File

@ -226,6 +226,8 @@ typedef struct _xenUnifiedPrivate *xenUnifiedPrivatePtr;
char *xenDomainUsedCpus(virDomainPtr dom);
virDomainXMLOptionPtr xenDomainXMLConfInit(void);
void xenUnifiedDomainInfoListFree(xenUnifiedDomainInfoListPtr info);
int xenUnifiedAddDomainInfo(xenUnifiedDomainInfoListPtr info,
int id, char *name,

View File

@ -2279,15 +2279,6 @@ struct guest_arch {
};
static int xenDefaultConsoleType(const char *ostype,
virArch arch ATTRIBUTE_UNUSED)
{
if (STREQ(ostype, "hvm"))
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
else
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
}
static virCapsPtr
xenHypervisorBuildCapabilities(virConnectPtr conn, virArch hostarch,
int host_pae,
@ -2414,8 +2405,6 @@ xenHypervisorBuildCapabilities(virConnectPtr conn, virArch hostarch,
}
caps->defaultConsoleTargetType = xenDefaultConsoleType;
return caps;
no_memory:

View File

@ -43,16 +43,27 @@
#define VIR_FROM_THIS VIR_FROM_XENAPI
static int xenapiDefaultConsoleType(const char *ostype,
virArch arch ATTRIBUTE_UNUSED)
static int
xenapiDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def,
virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
if (STREQ(ostype, "hvm"))
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
else
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
STRNEQ(def->os.type, "hvm"))
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
return 0;
}
virDomainDefParserConfig xenapiDomainDefParserConfig = {
.devicesPostParseCallback = xenapiDomainDeviceDefPostParse,
};
/*
* getCapsObject
*
@ -83,8 +94,6 @@ getCapsObject(void)
if (!domain2)
goto error_cleanup;
caps->defaultConsoleTargetType = xenapiDefaultConsoleType;
return caps;
error_cleanup:
@ -169,7 +178,8 @@ xenapiOpen(virConnectPtr conn, virConnectAuthPtr auth,
goto error;
}
if (!(privP->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) {
if (!(privP->xmlopt = virDomainXMLOptionNew(&xenapiDomainDefParserConfig,
NULL, NULL))) {
xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
_("Failed to create XML conf object"));
goto error;

View File

@ -8,13 +8,6 @@
# include "domain_conf.h"
static int testLXCDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC;
}
virCapsPtr testLXCCapsInit(void) {
virCapsPtr caps;
virCapsGuestPtr guest;
@ -23,8 +16,6 @@ virCapsPtr testLXCCapsInit(void) {
0, 0)) == NULL)
return NULL;
caps->defaultConsoleTargetType = testLXCDefaultConsoleType;
if ((guest = virCapabilitiesAddGuest(caps, "exe", VIR_ARCH_I686,
"/usr/libexec/libvirt_lxc", NULL,
0, NULL)) == NULL)

View File

@ -55,15 +55,6 @@ static virCapsGuestMachinePtr *testQemuAllocNewerMachines(int *nmachines)
return machines;
}
static int testQemuDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch)
{
if (arch == VIR_ARCH_S390 ||
arch == VIR_ARCH_S390X)
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
else
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
static int testQemuAddPPC64Guest(virCapsPtr caps)
{
@ -200,8 +191,6 @@ virCapsPtr testQemuCapsInit(void) {
0, 0)) == NULL)
return NULL;
caps->defaultConsoleTargetType = testQemuDefaultConsoleType;
if ((caps->host.cpu = virCPUDefCopy(&host_cpu)) == NULL ||
(machines = testQemuAllocMachines(&nmachines)) == NULL)
goto cleanup;

View File

@ -6,20 +6,6 @@
#include "testutilsxen.h"
#include "domain_conf.h"
static int testXenDefaultConsoleType(const char *ostype,
virArch arch ATTRIBUTE_UNUSED)
{
if (STREQ(ostype, "hvm"))
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
else
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
}
virDomainXMLOptionPtr
testXenXMLConfInit(void)
{
return virDomainXMLOptionNew(NULL, NULL, NULL);
}
virCapsPtr testXenCapsInit(void) {
struct utsname utsname;
@ -39,8 +25,6 @@ virCapsPtr testXenCapsInit(void) {
0, 0)) == NULL)
return NULL;
caps->defaultConsoleTargetType = testXenDefaultConsoleType;
nmachines = ARRAY_CARDINALITY(x86_machines);
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
goto cleanup;

View File

@ -1,6 +1,4 @@
#include "capabilities.h"
#include "domain_conf.h"
virCapsPtr testXenCapsInit(void);
virDomainXMLOptionPtr testXenXMLConfInit(void);

View File

@ -15,11 +15,6 @@ static virCapsPtr caps;
static virDomainXMLOptionPtr xmlopt;
static virVMXContext ctx;
static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
static void
testCapsInit(void)
@ -32,8 +27,6 @@ testCapsInit(void)
return;
}
caps->defaultConsoleTargetType = testDefaultConsoleType;
virCapabilitiesAddHostMigrateTransport(caps, "esx");
/* i686 guest */

View File

@ -196,7 +196,7 @@ mymain(void)
if (!(caps = testXenCapsInit()))
return EXIT_FAILURE;
if (!(xmlopt = testXenXMLConfInit()))
if (!(xmlopt = xenDomainXMLConfInit()))
return EXIT_FAILURE;
#define DO_TEST(name, version) \

View File

@ -10,6 +10,7 @@
#include "internal.h"
#include "xen/xend_internal.h"
#include "xen/xen_driver.h"
#include "xenxs/xen_sxpr.h"
#include "testutils.h"
#include "testutilsxen.h"
@ -104,7 +105,7 @@ mymain(void)
if (!(caps = testXenCapsInit()))
return EXIT_FAILURE;
if (!(xmlopt = testXenXMLConfInit()))
if (!(xmlopt = xenDomainXMLConfInit()))
return EXIT_FAILURE;
DO_TEST("pv", "pv", "pvtest", 1);

View File

@ -15,11 +15,6 @@ static virCapsPtr caps;
static virVMXContext ctx;
static virDomainXMLOptionPtr xmlopt;
static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
static void
testCapsInit(void)
@ -32,8 +27,6 @@ testCapsInit(void)
return;
}
caps->defaultConsoleTargetType = testDefaultConsoleType;
virCapabilitiesAddHostMigrateTransport(caps, "esx");