提交 b1c88c14 编写于 作者: V Viktor Mihajlovski 提交者: Eric Blake

capabilities: defaultConsoleTargetType can depend on architecture

For S390, the default console target type cannot be of type 'serial'.
It is necessary to at least interpret the 'arch' attribute
value of the os/type element to produce the correct default type.

Therefore we need to extend the signature of defaultConsoleTargetType
to account for architecture. As a consequence all the drivers
supporting this capability function must be updated.

Despite the amount of changed files, the only change in behavior is
that for S390 the default console target type will be 'virtio'.

N.B.: A more future-proof approach could be to to use hypervisor
specific capabilities to determine the best possible console type.
For instance one could add an opaque private data pointer to the
virCaps structure (in case of QEMU to hold capsCache) which could
then be passed to the defaultConsoleTargetType callback to determine
the console target type.
Seems to be however a bit overengineered for the use case...
Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
上级 02cf57c0
......@@ -150,7 +150,7 @@ struct _virCaps {
unsigned int emulatorRequired : 1;
const char *defaultDiskDriverName;
int defaultDiskDriverType; /* enum virStorageFileFormat */
int (*defaultConsoleTargetType)(const char *ostype);
int (*defaultConsoleTargetType)(const char *ostype, const char *arch);
void *(*privateDataAllocFunc)(void);
void (*privateDataFreeFunc)(void *);
int (*privateDataXMLFormat)(virBufferPtr, void *);
......
......@@ -5282,7 +5282,7 @@ virDomainChrDefaultTargetType(virCapsPtr caps,
_("Driver does not have a default console type set"));
return -1;
}
target = caps->defaultConsoleTargetType(def->os.type);
target = caps->defaultConsoleTargetType(def->os.type, def->os.arch);
break;
case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
......
......@@ -566,7 +566,8 @@ esxLookupHostSystemBiosUuid(esxPrivate *priv, unsigned char *uuid)
}
static int esxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int esxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
......
......@@ -117,7 +117,8 @@ libxlNextFreeVncPort(libxlDriverPrivatePtr driver, int startPort)
}
static int libxlDefaultConsoleType(const char *ostype)
static int libxlDefaultConsoleType(const char *ostype,
const char *arch ATTRIBUTE_UNUSED)
{
if (STREQ(ostype, "hvm"))
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
......
......@@ -42,7 +42,8 @@
#define VIR_FROM_THIS VIR_FROM_LXC
static int lxcDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int lxcDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC;
}
......
......@@ -169,7 +169,8 @@ error:
}
static int openvzDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int openvzDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ;
}
......
......@@ -87,7 +87,8 @@ parallelsDriverUnlock(parallelsConnPtr driver)
}
static int
parallelsDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
parallelsDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
......
......@@ -288,7 +288,8 @@ phypGetVIOSPartitionID(virConnectPtr conn)
}
static int phypDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int phypDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
......
......@@ -805,9 +805,13 @@ error:
}
static int qemuDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int qemuDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
if (STRPREFIX(arch, "s390"))
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
else
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
......
......@@ -698,7 +698,8 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
return rc;
}
static int aaDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int aaDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
......
......@@ -149,7 +149,8 @@ static void testDomainObjPrivateFree(void *data)
}
static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
......
......@@ -53,7 +53,8 @@
#define VIR_FROM_THIS VIR_FROM_UML
static int umlDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int umlDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML;
}
......
......@@ -822,7 +822,8 @@ cleanup:
}
static int vboxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int vboxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
......
......@@ -50,7 +50,8 @@ vmwareFreeDriver(struct vmware_driver *driver)
}
static int vmwareDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int vmwareDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
......
......@@ -2301,7 +2301,8 @@ struct guest_arch {
};
static int xenDefaultConsoleType(const char *ostype)
static int xenDefaultConsoleType(const char *ostype,
const char *arch ATTRIBUTE_UNUSED)
{
if (STREQ(ostype, "hvm"))
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
......
......@@ -43,7 +43,8 @@
#define VIR_FROM_THIS VIR_FROM_XENAPI
static int xenapiDefaultConsoleType(const char *ostype)
static int xenapiDefaultConsoleType(const char *ostype,
const char *arch ATTRIBUTE_UNUSED)
{
if (STREQ(ostype, "hvm"))
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
......
......@@ -8,7 +8,8 @@
# include "domain_conf.h"
static int testLXCDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int testLXCDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC;
}
......
......@@ -55,9 +55,13 @@ static virCapsGuestMachinePtr *testQemuAllocNewerMachines(int *nmachines)
return machines;
}
static int testQemuDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int testQemuDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
if (STRPREFIX(arch, "s390"))
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
else
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
static int testQemuAddPPC64Guest(virCapsPtr caps)
......
......@@ -6,7 +6,8 @@
#include "testutilsxen.h"
#include "domain_conf.h"
static int testXenDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int testXenDefaultConsoleType(const char *ostype,
const char *arch ATTRIBUTE_UNUSED)
{
if (STREQ(ostype, "hvm"))
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
......
......@@ -14,7 +14,8 @@
static virCapsPtr caps;
static virVMXContext ctx;
static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
......
......@@ -14,7 +14,8 @@
static virCapsPtr caps;
static virVMXContext ctx;
static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册