From b1c88c14764e0b043a269d454a83a6ac7af34eac Mon Sep 17 00:00:00 2001 From: Viktor Mihajlovski Date: Fri, 9 Nov 2012 16:00:36 +0100 Subject: [PATCH] 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: Viktor Mihajlovski --- src/conf/capabilities.h | 2 +- src/conf/domain_conf.c | 2 +- src/esx/esx_driver.c | 3 ++- src/libxl/libxl_conf.c | 3 ++- src/lxc/lxc_conf.c | 3 ++- src/openvz/openvz_conf.c | 3 ++- src/parallels/parallels_driver.c | 3 ++- src/phyp/phyp_driver.c | 3 ++- src/qemu/qemu_capabilities.c | 8 ++++++-- src/security/virt-aa-helper.c | 3 ++- src/test/test_driver.c | 3 ++- src/uml/uml_conf.c | 3 ++- src/vbox/vbox_tmpl.c | 3 ++- src/vmware/vmware_conf.c | 3 ++- src/xen/xen_hypervisor.c | 3 ++- src/xenapi/xenapi_driver.c | 3 ++- tests/testutilslxc.c | 3 ++- tests/testutilsqemu.c | 8 ++++++-- tests/testutilsxen.c | 3 ++- tests/vmx2xmltest.c | 3 ++- tests/xml2vmxtest.c | 3 ++- 21 files changed, 48 insertions(+), 23 deletions(-) diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 99056f87c..641f27920 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -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 *); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0575fcd76..99f03a903 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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: diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 13e8887b7..56f31bb98 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -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; } diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 52771b8b1..1c3130b00 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -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; diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index 138b697fe..e512b8f4f 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -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; } diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index ea86a0efc..2bd9caff4 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -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; } diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 28779fa16..50efd1db4 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -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; } diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index a3885a741..e8cef4fa7 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -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; } diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 97b0b248d..5ce93f215 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -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; } diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 634a3fc34..e480b305b 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -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; } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index c974e1abb..9e4d9f2b2 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -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; } diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index 036181cc5..6ef6de325 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -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; } diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 5ec0ba0d8..bcffb2f6b 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -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; } diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 8101cc78a..2eed4f879 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -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; } diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index d1f7b41cf..237a6ab4f 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -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; diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index a170befd9..5a93aeac1 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -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; diff --git a/tests/testutilslxc.c b/tests/testutilslxc.c index e6193afcf..822e51880 100644 --- a/tests/testutilslxc.c +++ b/tests/testutilslxc.c @@ -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; } diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 69c78ecf6..4ff4a08bc 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -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) diff --git a/tests/testutilsxen.c b/tests/testutilsxen.c index b5f20cb1a..517aeab37 100644 --- a/tests/testutilsxen.c +++ b/tests/testutilsxen.c @@ -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; diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 49131524e..e523d1cc6 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -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; } diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 451b1e482..94dfcf225 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -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; } -- 2.39.5