File 209c2880-multiple-consoles-7.patch of Package libvirt.openSUSE_12.1_Update
commit 209c2880b918a80449d42845ca1fd1497f2ec2da
Author: Daniel P. Berrange <berrange@redhat.com>
Date: Thu Oct 20 14:56:20 2011 +0100
Fix default console type setting
The default console type may vary based on the OS type. ie a Xen
paravirt guests wants a 'xen' console, while a fullvirt guests
wants a 'serial' console.
A plain integer default console type in the capabilities does
not suffice. Instead introduce a callback that is passed the
OS type.
* src/conf/capabilities.h: Use a callback for default console
type
* src/conf/domain_conf.c, src/conf/domain_conf.h: Use callback
for default console type. Add missing LXC/OpenVZ console types.
* src/esx/esx_driver.c, src/libxl/libxl_conf.c,
src/lxc/lxc_conf.c, src/openvz/openvz_conf.c,
src/phyp/phyp_driver.c, src/qemu/qemu_capabilities.c,
src/uml/uml_conf.c, src/vbox/vbox_tmpl.c,
src/vmware/vmware_conf.c, src/xen/xen_hypervisor.c,
src/xenapi/xenapi_driver.c: Set default console type callback
Index: libvirt-0.9.6/src/conf/capabilities.h
===================================================================
--- libvirt-0.9.6.orig/src/conf/capabilities.h
+++ libvirt-0.9.6/src/conf/capabilities.h
@@ -144,7 +144,7 @@ struct _virCaps {
unsigned int emulatorRequired : 1;
const char *defaultDiskDriverName;
const char *defaultDiskDriverType;
- int defaultConsoleTargetType;
+ int (*defaultConsoleTargetType)(const char *ostype);
void *(*privateDataAllocFunc)(void);
void (*privateDataFreeFunc)(void *);
int (*privateDataXMLFormat)(virBufferPtr, void *);
Index: libvirt-0.9.6/src/conf/domain_conf.c
===================================================================
--- libvirt-0.9.6.orig/src/conf/domain_conf.c
+++ libvirt-0.9.6/src/conf/domain_conf.c
@@ -272,7 +272,9 @@ VIR_ENUM_IMPL(virDomainChrConsoleTarget,
"serial",
"xen",
"uml",
- "virtio")
+ "virtio",
+ "lxc",
+ "openvz")
VIR_ENUM_IMPL(virDomainChrDevice, VIR_DOMAIN_CHR_DEVICE_TYPE_LAST,
"parallel",
@@ -3412,7 +3414,9 @@ error:
}
static int
-virDomainChrDefaultTargetType(virCapsPtr caps, int devtype) {
+virDomainChrDefaultTargetType(virCapsPtr caps,
+ virDomainDefPtr def,
+ int devtype) {
int target = -1;
@@ -3424,7 +3428,12 @@ virDomainChrDefaultTargetType(virCapsPtr
break;
case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
- target = caps->defaultConsoleTargetType;
+ if (!caps->defaultConsoleTargetType) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Driver does not have a default console type set"));
+ return -1;
+ }
+ target = caps->defaultConsoleTargetType(def->os.type);
break;
case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
@@ -3440,6 +3449,7 @@ virDomainChrDefaultTargetType(virCapsPtr
static int
virDomainChrTargetTypeFromString(virCapsPtr caps,
+ virDomainDefPtr def,
int devtype,
const char *targetType)
{
@@ -3447,7 +3457,7 @@ virDomainChrTargetTypeFromString(virCaps
int target = 0;
if (!targetType) {
- target = virDomainChrDefaultTargetType(caps, devtype);
+ target = virDomainChrDefaultTargetType(caps, def, devtype);
goto out;
}
@@ -3474,6 +3484,7 @@ out:
static int
virDomainChrDefParseTargetXML(virCapsPtr caps,
+ virDomainDefPtr vmdef,
virDomainChrDefPtr def,
xmlNodePtr cur)
{
@@ -3484,8 +3495,8 @@ virDomainChrDefParseTargetXML(virCapsPtr
const char *portStr = NULL;
if ((def->targetType =
- virDomainChrTargetTypeFromString(caps,
- def->deviceType, targetType)) < 0) {
+ virDomainChrTargetTypeFromString(caps, vmdef,
+ def->deviceType, targetType)) < 0) {
goto error;
}
@@ -3823,6 +3834,7 @@ virDomainChrDefNew(void) {
*/
static virDomainChrDefPtr
virDomainChrDefParseXML(virCapsPtr caps,
+ virDomainDefPtr vmdef,
xmlNodePtr node,
unsigned int flags)
{
@@ -3860,7 +3872,7 @@ virDomainChrDefParseXML(virCapsPtr caps,
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
if (xmlStrEqual(cur->name, BAD_CAST "target")) {
- if (virDomainChrDefParseTargetXML(caps, def, cur) < 0) {
+ if (virDomainChrDefParseTargetXML(caps, vmdef, def, cur) < 0) {
goto error;
}
}
@@ -6941,6 +6953,7 @@ static virDomainDefPtr virDomainDefParse
for (i = 0 ; i < n ; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(caps,
+ def,
nodes[i],
flags);
if (!chr)
@@ -6967,6 +6980,7 @@ static virDomainDefPtr virDomainDefParse
for (i = 0 ; i < n ; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(caps,
+ def,
nodes[i],
flags);
if (!chr)
@@ -6987,6 +7001,7 @@ static virDomainDefPtr virDomainDefParse
if ((node = virXPathNode("./devices/console[1]", ctxt)) != NULL) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(caps,
+ def,
node,
flags);
if (!chr)
@@ -7023,6 +7038,7 @@ static virDomainDefPtr virDomainDefParse
for (i = 0 ; i < n ; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(caps,
+ def,
nodes[i],
flags);
if (!chr)
Index: libvirt-0.9.6/src/conf/domain_conf.h
===================================================================
--- libvirt-0.9.6.orig/src/conf/domain_conf.h
+++ libvirt-0.9.6/src/conf/domain_conf.h
@@ -532,6 +532,8 @@ enum virDomainChrConsoleTargetType {
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN,
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML,
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
+ VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC,
+ VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ,
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST,
};
Index: libvirt-0.9.6/src/esx/esx_driver.c
===================================================================
--- libvirt-0.9.6.orig/src/esx/esx_driver.c
+++ libvirt-0.9.6/src/esx/esx_driver.c
@@ -588,6 +588,11 @@ esxLookupHostSystemBiosUuid(esxPrivate *
}
+static int esxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
+{
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+}
+
static virCapsPtr
esxCapsInit(esxPrivate *priv)
@@ -615,6 +620,7 @@ esxCapsInit(esxPrivate *priv)
virCapabilitiesAddHostMigrateTransport(caps, "vpxmigr");
caps->hasWideScsiBus = true;
+ caps->defaultConsoleTargetType = esxDefaultConsoleType;
if (esxLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0) {
goto failure;
Index: libvirt-0.9.6/src/libxl/libxl_conf.c
===================================================================
--- libvirt-0.9.6.orig/src/libxl/libxl_conf.c
+++ libvirt-0.9.6/src/libxl/libxl_conf.c
@@ -114,6 +114,15 @@ libxlNextFreeVncPort(libxlDriverPrivateP
return -1;
}
+
+static int libxlDefaultConsoleType(const char *ostype)
+{
+ if (STREQ(ostype, "hvm"))
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+ else
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
+}
+
static virCapsPtr
libxlBuildCapabilities(const char *hostmachine,
int host_pae,
@@ -206,7 +215,7 @@ libxlBuildCapabilities(const char *hostm
}
}
- caps->defaultConsoleTargetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
+ caps->defaultConsoleTargetType = libxlDefaultConsoleType;
return caps;
Index: libvirt-0.9.6/src/lxc/lxc_conf.c
===================================================================
--- libvirt-0.9.6.orig/src/lxc/lxc_conf.c
+++ libvirt-0.9.6/src/lxc/lxc_conf.c
@@ -40,6 +40,12 @@
#define VIR_FROM_THIS VIR_FROM_LXC
+static int lxcDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
+{
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC;
+}
+
+
/* Functions */
virCapsPtr lxcCapsInit(void)
{
@@ -54,6 +60,8 @@ virCapsPtr lxcCapsInit(void)
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
Index: libvirt-0.9.6/src/openvz/openvz_conf.c
===================================================================
--- libvirt-0.9.6.orig/src/openvz/openvz_conf.c
+++ libvirt-0.9.6/src/openvz/openvz_conf.c
@@ -129,6 +129,11 @@ int openvzExtractVersion(struct openvz_d
}
+static int openvzDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
+{
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ;
+}
+
virCapsPtr openvzCapsInit(void)
{
struct utsname utsname;
@@ -165,6 +170,7 @@ virCapsPtr openvzCapsInit(void)
goto no_memory;
caps->defaultInitPath = "/sbin/init";
+ caps->defaultConsoleTargetType = openvzDefaultConsoleType;
return caps;
no_memory:
Index: libvirt-0.9.6/src/phyp/phyp_driver.c
===================================================================
--- libvirt-0.9.6.orig/src/phyp/phyp_driver.c
+++ libvirt-0.9.6/src/phyp/phyp_driver.c
@@ -291,6 +291,13 @@ phypGetVIOSPartitionID(virConnectPtr con
return id;
}
+
+static int phypDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
+{
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+}
+
+
static virCapsPtr
phypCapsInit(void)
{
@@ -328,6 +335,8 @@ phypCapsInit(void)
"phyp", NULL, NULL, 0, NULL) == NULL)
goto no_memory;
+ caps->defaultConsoleTargetType = phypDefaultConsoleType;
+
return caps;
no_memory:
Index: libvirt-0.9.6/src/qemu/qemu_capabilities.c
===================================================================
--- libvirt-0.9.6.orig/src/qemu/qemu_capabilities.c
+++ libvirt-0.9.6/src/qemu/qemu_capabilities.c
@@ -803,6 +803,12 @@ error:
}
+static int qemuDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
+{
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+}
+
+
virCapsPtr qemuCapsInit(virCapsPtr old_caps)
{
struct utsname utsname;
@@ -870,7 +876,7 @@ virCapsPtr qemuCapsInit(virCapsPtr old_c
/* QEMU Requires an emulator in the XML */
virCapabilitiesSetEmulatorRequired(caps);
- caps->defaultConsoleTargetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+ caps->defaultConsoleTargetType = qemuDefaultConsoleType;
return caps;
Index: libvirt-0.9.6/src/test/test_driver.c
===================================================================
--- libvirt-0.9.6.orig/src/test/test_driver.c
+++ libvirt-0.9.6/src/test/test_driver.c
@@ -152,6 +152,11 @@ static void testDomainObjPrivateFree(voi
}
+static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
+{
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+}
+
static virCapsPtr
testBuildCapabilities(virConnectPtr conn) {
testConnPtr privconn = conn->privateData;
@@ -163,6 +168,8 @@ testBuildCapabilities(virConnectPtr conn
if ((caps = virCapabilitiesNew(TEST_MODEL, 0, 0)) == NULL)
goto no_memory;
+ caps->defaultConsoleTargetType = testDefaultConsoleType;
+
if (virCapabilitiesAddHostFeature(caps, "pae") < 0)
goto no_memory;
if (virCapabilitiesAddHostFeature(caps ,"nonpae") < 0)
Index: libvirt-0.9.6/src/uml/uml_conf.c
===================================================================
--- libvirt-0.9.6.orig/src/uml/uml_conf.c
+++ libvirt-0.9.6/src/uml/uml_conf.c
@@ -54,6 +54,13 @@
#define umlLog(level, msg, ...) \
virLogMessage(__FILE__, level, 0, msg, __VA_ARGS__)
+
+static int umlDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
+{
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML;
+}
+
+
virCapsPtr umlCapsInit(void) {
struct utsname utsname;
virCapsPtr caps;
@@ -99,7 +106,7 @@ virCapsPtr umlCapsInit(void) {
NULL) == NULL)
goto error;
- caps->defaultConsoleTargetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML;
+ caps->defaultConsoleTargetType = umlDefaultConsoleType;
return caps;
Index: libvirt-0.9.6/src/vbox/vbox_tmpl.c
===================================================================
--- libvirt-0.9.6.orig/src/vbox/vbox_tmpl.c
+++ libvirt-0.9.6/src/vbox/vbox_tmpl.c
@@ -823,6 +823,13 @@ cleanup:
return result;
}
+
+static int vboxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
+{
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+}
+
+
static virCapsPtr vboxCapsInit(void) {
struct utsname utsname;
virCapsPtr caps;
@@ -856,6 +863,9 @@ static virCapsPtr vboxCapsInit(void) {
0,
NULL) == NULL)
goto no_memory;
+
+ caps->defaultConsoleTargetType = vboxDefaultConsoleType;
+
return caps;
no_memory:
Index: libvirt-0.9.6/src/vmware/vmware_conf.c
===================================================================
--- libvirt-0.9.6.orig/src/vmware/vmware_conf.c
+++ libvirt-0.9.6/src/vmware/vmware_conf.c
@@ -49,6 +49,13 @@ vmwareFreeDriver(struct vmware_driver *d
VIR_FREE(driver);
}
+
+static int vmwareDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
+{
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+}
+
+
virCapsPtr
vmwareCapsInit(void)
{
@@ -117,6 +124,8 @@ vmwareCapsInit(void)
goto error;
}
+ caps->defaultConsoleTargetType = vmwareDefaultConsoleType;
+
cleanup:
virCPUDefFree(cpu);
cpuDataFree(utsname.machine, data);
Index: libvirt-0.9.6/src/xen/xen_hypervisor.c
===================================================================
--- libvirt-0.9.6.orig/src/xen/xen_hypervisor.c
+++ libvirt-0.9.6/src/xen/xen_hypervisor.c
@@ -2264,6 +2264,14 @@ struct guest_arch {
};
+static int xenDefaultConsoleType(const char *ostype)
+{
+ 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,
const char *hostmachine,
@@ -2393,7 +2401,7 @@ xenHypervisorBuildCapabilities(virConnec
}
- caps->defaultConsoleTargetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
+ caps->defaultConsoleTargetType = xenDefaultConsoleType;
return caps;
Index: libvirt-0.9.6/src/xenapi/xenapi_driver.c
===================================================================
--- libvirt-0.9.6.orig/src/xenapi/xenapi_driver.c
+++ libvirt-0.9.6/src/xenapi/xenapi_driver.c
@@ -47,6 +47,16 @@
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
+
+static int xenapiDefaultConsoleType(const char *ostype)
+{
+ if (STREQ(ostype, "hvm"))
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+ else
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
+}
+
+
/*
* getCapsObject
*
@@ -77,6 +87,8 @@ getCapsObject (void)
if (!domain2)
goto error_cleanup;
+ caps->defaultConsoleTargetType = xenapiDefaultConsoleType;
+
return caps;
error_cleanup:
Index: libvirt-0.9.6/tests/testutilsqemu.c
===================================================================
--- libvirt-0.9.6.orig/tests/testutilsqemu.c
+++ libvirt-0.9.6/tests/testutilsqemu.c
@@ -55,6 +55,11 @@ static virCapsGuestMachinePtr *testQemuA
return machines;
}
+static int testQemuDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
+{
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+}
+
virCapsPtr testQemuCapsInit(void) {
virCapsPtr caps;
virCapsGuestPtr guest;
@@ -96,6 +101,8 @@ 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;
Index: libvirt-0.9.6/tests/testutilsxen.c
===================================================================
--- libvirt-0.9.6.orig/tests/testutilsxen.c
+++ libvirt-0.9.6/tests/testutilsxen.c
@@ -4,6 +4,15 @@
#include <stdlib.h>
#include "testutilsxen.h"
+#include "domain_conf.h"
+
+static int testXenDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
+{
+ if (STREQ(ostype, "hvm"))
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+ else
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
+}
virCapsPtr testXenCapsInit(void) {
struct utsname utsname;
@@ -23,6 +32,8 @@ 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;
Index: libvirt-0.9.6/tests/vmx2xmltest.c
===================================================================
--- libvirt-0.9.6.orig/tests/vmx2xmltest.c
+++ libvirt-0.9.6/tests/vmx2xmltest.c
@@ -14,6 +14,11 @@
static virCapsPtr caps;
static virVMXContext ctx;
+static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
+{
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+}
+
static void
testCapsInit(void)
{
@@ -25,6 +30,8 @@ testCapsInit(void)
return;
}
+ caps->defaultConsoleTargetType = testDefaultConsoleType;
+
virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 });
virCapabilitiesAddHostMigrateTransport(caps, "esx");
Index: libvirt-0.9.6/tests/xml2vmxtest.c
===================================================================
--- libvirt-0.9.6.orig/tests/xml2vmxtest.c
+++ libvirt-0.9.6/tests/xml2vmxtest.c
@@ -14,6 +14,11 @@
static virCapsPtr caps;
static virVMXContext ctx;
+static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
+{
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+}
+
static void
testCapsInit(void)
{
@@ -25,6 +30,8 @@ testCapsInit(void)
return;
}
+ caps->defaultConsoleTargetType = testDefaultConsoleType;
+
virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 });
virCapabilitiesAddHostMigrateTransport(caps, "esx");