[libvirt] [PATCH] capabilities: defaultConsoleTargetType can depend on architecture

Viktor Mihajlovski mihajlov at linux.vnet.ibm.com
Fri Nov 9 15:00:36 UTC 2012


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 at linux.vnet.ibm.com>
---
 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 99056f8..641f279 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 e105a02..bb1d632 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5284,7 +5284,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 13e8887..56f31bb 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 52771b8..1c3130b 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 138b697..e512b8f 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 ea86a0e..2bd9caf 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 28779fa..50efd1d 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 a3885a7..e8cef4f 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 1859f53..f4649b6 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -807,9 +807,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 634a3fc..e480b30 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 c974e1a..9e4d9f2 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 036181c..6ef6de3 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 5ec0ba0..bcffb2f 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 8101cc7..2eed4f8 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 d1f7b41..237a6ab 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 a170bef..5a93aea 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 e6193af..822e518 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 69c78ec..4ff4a08 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 b5f20cb..517aeab 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 4913152..e523d1c 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 451b1e4..94dfcf2 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;
 }
-- 
1.7.0.4




More information about the libvir-list mailing list