]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
capabilities: defaultConsoleTargetType can depend on architecture
authorViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Fri, 9 Nov 2012 15:00:36 +0000 (16:00 +0100)
committerEric Blake <eblake@redhat.com>
Fri, 9 Nov 2012 16:20:59 +0000 (09:20 -0700)
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 <mihajlov@linux.vnet.ibm.com>
21 files changed:
src/conf/capabilities.h
src/conf/domain_conf.c
src/esx/esx_driver.c
src/libxl/libxl_conf.c
src/lxc/lxc_conf.c
src/openvz/openvz_conf.c
src/parallels/parallels_driver.c
src/phyp/phyp_driver.c
src/qemu/qemu_capabilities.c
src/security/virt-aa-helper.c
src/test/test_driver.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
tests/testutilslxc.c
tests/testutilsqemu.c
tests/testutilsxen.c
tests/vmx2xmltest.c
tests/xml2vmxtest.c

index 99056f87c8fbe169ecdfd56bf95bdbad48d27780..641f279201daa5f68c4b5ebfcb05c47fd3598795 100644 (file)
@@ -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 *);
index 0575fcd76b7323935fece27ad7cdfb05a4c2d717..99f03a9038854e567c444e5458b24c8ffcad6143 100644 (file)
@@ -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:
index 13e8887b75cb5b79b019c101a85b6817822e1089..56f31bb98a938cc49ef47484db74b519c2e1e5ce 100644 (file)
@@ -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;
 }
index 52771b8b198994ef4f35169eb704e056ca000a2e..1c3130b0003a46b0f39a1464ad8c24a15c8314fe 100644 (file)
@@ -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;
index 138b697fe8d5f03bf0087d1014c017f2c05331df..e512b8f4fa002318bd064df6fd87216d5a8a7f6b 100644 (file)
@@ -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;
 }
index ea86a0efce73f22054ee5f486dad01c89a695f7c..2bd9caff4f7937b62a7aa0b867f39aef54c56b84 100644 (file)
@@ -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;
 }
index 28779fa16f6df21a2c62c5b915022e2cfc3c60b9..50efd1db4f79ed76676cb9da54baf60c65159af4 100644 (file)
@@ -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;
 }
index a3885a74104692108c0d550b3a2f554acc50fe5d..e8cef4fa7d79d5d904295f172e91b9466a9c73f1 100644 (file)
@@ -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;
 }
index 97b0b248dc61913db3dd3519ab76252f55d9b1c3..5ce93f2156ab0d4d665ef24166515e6fe474ef34 100644 (file)
@@ -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;
 }
 
 
index 634a3fc34a831178f2b0c088d86e87fe1c21f037..e480b305bd111b20678fea76db73a39bec48298b 100644 (file)
@@ -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;
 }
index c974e1abb4462f7c259082fb6559b0618fd0176d..9e4d9f2b2f1ebfc5e3958cb423a63e8e6fe4990a 100644 (file)
@@ -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;
 }
index 036181cc5d6d2bdb17f3704705d6c4b6017a5540..6ef6de325e5eb052d2160ab9c3f0d4b424b2d203 100644 (file)
@@ -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;
 }
index 5ec0ba0d89f6be6e5fa6dd627ac4b3e9f908812b..bcffb2f6b4ce505c22e8f810105d339cc1cd4240 100644 (file)
@@ -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;
 }
index 8101cc78a2f9a2f444d521db5e84abf2a0d41c80..2eed4f8795c02e4ebc434a0c865ecaef3ba109b8 100644 (file)
@@ -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;
 }
index d1f7b41cf7aaec4c9dffe030d8a41ee66e3f8fef..237a6ab4f1aec962e53227668422f2a0bc76d52f 100644 (file)
@@ -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;
index a170befd976b0622635b9661ff31249547555a2e..5a93aeac156b18c2f664e85b839c7f9142d17e07 100644 (file)
@@ -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;
index e6193afcf04644929c33e557ddd874087860e865..822e51880a7e4fdeeed84232542c094afc9955d1 100644 (file)
@@ -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;
 }
index 69c78ecf60971c58f8b4bcf94b23b5e6e8d2cb5f..4ff4a08bc5375f82743b7212037f99bd25d79a65 100644 (file)
@@ -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)
index b5f20cb1a4de80c4d3c3be86793a0d7f33023a52..517aeab37ebe4ddeca18b69faf9c61216bb2c5f8 100644 (file)
@@ -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;
index 49131524e09501193d4bd17e3c140f1b03b4aaaa..e523d1cc6342d944cdb324bd35f45059191d9ead 100644 (file)
@@ -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;
 }
index 451b1e4822765c8c922ff5208a44b8397a8e36bf..94dfcf22522ccad6ca806e680e16d655d102d542 100644 (file)
@@ -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;
 }