[virt-tools-list] [PATCH] virt-manager : add support for architecture type "s390x".

Kevin Zhao kevinzs at linux.vnet.ibm.com
Mon Jul 13 11:35:24 UTC 2015


For architecture "s390x",the disk and the network device are base
on "virtio" bus.The cdrom is based on "scsi".So set the default
cdrom bus as "scsi",the default bus as "virtio".Also the default
machine type is set to "s390-ccw-virtio" as it is the only supported
in "s390x".Also add a test cast of virt-install by cdrom in s390x.
---
 tests/capabilities-xml/kvm-s390x.xml               | 73 ++++++++++++++++++++++
 .../compare/virt-install-s390x-cdrom.xml           | 43 +++++++++++++
 tests/clitest.py                                   |  4 ++
 tests/utils.py                                     |  1 +
 virtManager/create.py                              |  4 +-
 virtinst/capabilities.py                           |  4 ++
 virtinst/devicedisk.py                             |  3 +
 virtinst/guest.py                                  |  2 +
 virtinst/osxml.py                                  |  3 +
 9 files changed, 135 insertions(+), 2 deletions(-)
 create mode 100644 tests/capabilities-xml/kvm-s390x.xml
 create mode 100644 tests/cli-test-xml/compare/virt-install-s390x-cdrom.xml

diff --git a/tests/capabilities-xml/kvm-s390x.xml b/tests/capabilities-xml/kvm-s390x.xml
new file mode 100644
index 0000000..a37ce68
--- /dev/null
+++ b/tests/capabilities-xml/kvm-s390x.xml
@@ -0,0 +1,73 @@
+<capabilities>
+
+  <host>
+    <uuid>b88e553c-5920-4aa8-bb09-cc0ab8e6e0c2</uuid>
+    <cpu>
+      <arch>s390x</arch>
+      <model>host</model>
+      <topology sockets="2" cores="2" threads="1"/>
+      <pages unit="KiB" size="4"/>
+      <pages unit="KiB" size="1024"/>
+    </cpu>
+    <power_management>
+      <suspend_disk/>
+      <suspend_hybrid/>
+    </power_management>
+    <migration_features>
+      <live/>
+      <uri_transports>
+        <uri_transport>tcp</uri_transport>
+        <uri_transport>rdma</uri_transport>
+      </uri_transports>
+    </migration_features>
+    <topology>
+      <cells num="1">
+        <cell id="0">
+          <memory unit="KiB">2878860</memory>
+          <cpus num="4">
+            <cpu id="0" socket_id="0" core_id="0" siblings="0"/>
+            <cpu id="1" socket_id="0" core_id="1" siblings="1"/>
+            <cpu id="2" socket_id="1" core_id="0" siblings="2"/>
+            <cpu id="3" socket_id="1" core_id="1" siblings="3"/>
+          </cpus>
+        </cell>
+      </cells>
+    </topology>
+    <secmodel>
+      <model>selinux</model>
+      <doi>0</doi>
+      <baselabel type="kvm">system_u:system_r:svirt_t:s0</baselabel>
+      <baselabel type="qemu">system_u:system_r:svirt_tcg_t:s0</baselabel>
+    </secmodel>
+    <secmodel>
+      <model>dac</model>
+      <doi>0</doi>
+      <baselabel type="kvm">+107:+107</baselabel>
+      <baselabel type="qemu">+107:+107</baselabel>
+    </secmodel>
+  </host>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name="s390x">
+      <wordsize>64</wordsize>
+      <emulator>/usr/bin/qemu-system-s390x</emulator>
+      <machine canonical="s390-virtio" maxCpus="255">s390</machine>
+      <machine canonical="s390-ccw-virtio" maxCpus="255">s390-ccw</machine>
+      <domain type="qemu">
+        <emulator>/usr/bin/qemu-system-s390x</emulator>
+      </domain>
+      <domain type="kvm">
+        <emulator>/usr/bin/qemu-kvm</emulator>
+        <machine canonical="s390-virtio" maxCpus="255">s390</machine>
+        <machine canonical="s390-ccw-virtio" maxCpus="255">s390-ccw</machine>
+      </domain>
+    </arch>
+    <features>
+      <cpuselection/>
+      <deviceboot/>
+      <disksnapshot default="on" toggle="no"/>
+    </features>
+  </guest>
+
+</capabilities>
diff --git a/tests/cli-test-xml/compare/virt-install-s390x-cdrom.xml b/tests/cli-test-xml/compare/virt-install-s390x-cdrom.xml
new file mode 100644
index 0000000..1e78379
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-install-s390x-cdrom.xml
@@ -0,0 +1,43 @@
+<domain type="qemu">
+  <name>rhel7.0</name>
+  <uuid>00000000-1111-2222-3333-444444444444</uuid>
+  <memory>1048576</memory>
+  <currentMemory>1048576</currentMemory>
+  <vcpu>4</vcpu>
+  <os>
+    <type arch="s390x" machine="s390-ccw-virtio">hvm</type>
+    <kernel>/kernel.img</kernel>
+    <initrd>/initrd.img</initrd>
+  </os>
+  <features>
+    <acpi/>
+    <apic/>
+  </features>
+  <clock offset="utc"/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-s390x</emulator>
+    <disk type="file" device="disk">
+      <driver name="qemu" type="qcow2"/>
+      <source file="/dev/default-pool/testvol1.img"/>
+      <target dev="vda" bus="virtio"/>
+    </disk>
+    <disk type="file" device="cdrom">
+      <driver name="qemu" type="raw"/>
+      <source file="/dev/default-pool/testvol2.img"/>
+      <target dev="sda" bus="scsi"/>
+      <readonly/>
+    </disk>
+    <interface type="network">
+      <source network="default"/>
+      <mac address="00:11:22:33:44:55"/>
+    </interface>
+    <console type="pty"/>
+    <channel type="unix">
+      <source mode="bind"/>
+      <target type="virtio" name="org.qemu.guest_agent.0"/>
+    </channel>
+  </devices>
+</domain>
diff --git a/tests/clitest.py b/tests/clitest.py
index 2e5df3b..1fc4495 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -76,6 +76,7 @@ test_files = {
     'URI-KVM-ARMV7L' : utils.uri_kvm_armv7l,
     'URI-KVM-AARCH64' : utils.uri_kvm_aarch64,
     'URI-KVM-PPC64LE' : utils.uri_kvm_ppc64le,
+    'URI-KVM-S390X' : utils.uri_kvm_s390x,
     'URI-XEN': utils.uri_xen,
     'URI-LXC': utils.uri_lxc,
 
@@ -694,6 +695,9 @@ c.add_compare("--arch ppc64 --machine pseries --boot network --disk %(EXISTIMG1)
 c.add_compare("--arch ppc64 --boot network --disk %(EXISTIMG1)s --os-variant fedora20 --network none", "ppc64-machdefault-f20")
 c.add_compare("--connect %(URI-KVM-PPC64LE)s --import --disk %(EXISTIMG1)s --os-variant fedora20", "ppc64le-kvm-import")
 
+# s390x tests
+c.add_compare("--arch s390x --machine s390-ccw-virtio --connect %(URI-KVM-S390X)s --boot kernel=/kernel.img,initrd=/initrd.img --disk %(EXISTIMG1)s,device=disk,bus=virtio,format=qcow2 --disk %(EXISTIMG2)s,device=cdrom,bus=scsi", "s390x-cdrom")
+
 c.add_compare("--disk none --location %(EXISTIMG3)s --nonetworks", "location-iso")  # Using --location iso mounting
 c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel6.4", "kvm-rhel6")  # RHEL6 defaults
 c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel7.0", "kvm-rhel7")  # RHEL7 defaults
diff --git a/tests/utils.py b/tests/utils.py
index 811016c..fe99155 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -46,6 +46,7 @@ uri_kvm = (_uri_kvm_domcaps + _capsprefix + "kvm-x86_64.xml")
 uri_kvm_armv7l = (_uri_kvm_domcaps + _capsprefix + "kvm-armv7l.xml")
 uri_kvm_aarch64 = (_uri_kvm_domcaps + _capsprefix + "kvm-aarch64.xml")
 uri_kvm_ppc64le = (_uri_kvm_domcaps + _capsprefix + "kvm-ppc64le.xml")
+uri_kvm_s390x = (_uri_kvm_domcaps + _capsprefix + "kvm-s390x.xml")
 
 uri_xen = uri_test + _capsprefix + "xen-rhel5.4.xml,xen"
 uri_lxc = uri_test + _capsprefix + "lxc.xml,lxc"
diff --git a/virtManager/create.py b/virtManager/create.py
index 8401a7a..90c6b34 100644
--- a/virtManager/create.py
+++ b/virtManager/create.py
@@ -409,7 +409,7 @@ class vmmCreate(vmmGObjectUI):
         can_remote_url = self.conn.get_backend().support_remote_url_install()
 
         installable_arch = (self.capsinfo.arch in
-            ["i686", "x86_64", "ppc64", "ppc64le", "ia64"])
+            ["i686", "x86_64", "ppc64", "ppc64le", "ia64", "s390x"])
 
         if self.capsinfo.arch == "aarch64":
             try:
@@ -676,7 +676,7 @@ class vmmCreate(vmmGObjectUI):
             archs.remove("i686")
         archs.sort()
 
-        prios = ["x86_64", "i686", "aarch64", "armv7l", "ppc64", "ppc64le"]
+        prios = ["x86_64", "i686", "aarch64", "armv7l", "ppc64", "ppc64le", "s390x"]
         if self.conn.caps.host.cpu.arch not in prios:
             prios = []
         else:
diff --git a/virtinst/capabilities.py b/virtinst/capabilities.py
index bed8596..5823da2 100644
--- a/virtinst/capabilities.py
+++ b/virtinst/capabilities.py
@@ -323,6 +323,10 @@ class _CapsInfo(object):
             if "vexpress-a15" in self.machines:
                 return "vexpress-a15"
 
+        if self.arch in ["s390x"]:
+            if "s390-ccw-virtio" in self.machines:
+                return "s390-ccw-virtio"
+
         return None
 
 
diff --git a/virtinst/devicedisk.py b/virtinst/devicedisk.py
index 6ca76e5..679b0cd 100644
--- a/virtinst/devicedisk.py
+++ b/virtinst/devicedisk.py
@@ -897,6 +897,9 @@ class VirtualDisk(VirtualDevice):
         if self.is_cdrom():
             self.read_only = True
 
+        if self.is_cdrom() and guest.os.is_s390x():
+            self.bus = "scsi"
+
         if (guest.os.is_xenpv() and
             self.type == VirtualDisk.TYPE_FILE and
             self.driver_name is None and
diff --git a/virtinst/guest.py b/virtinst/guest.py
index bf4b70b..c958068 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -987,6 +987,8 @@ class Guest(XMLBuilder):
                 d.bus = "sd"
             elif self.os.is_q35():
                 d.bus = "sata"
+            elif self.os.is_s390x():
+                d.bus = "virtio"
             else:
                 d.bus = "ide"
 
diff --git a/virtinst/osxml.py b/virtinst/osxml.py
index 77771bd..f195f19 100644
--- a/virtinst/osxml.py
+++ b/virtinst/osxml.py
@@ -71,6 +71,9 @@ class OSXML(XMLBuilder):
     def is_pseries(self):
         return self.is_ppc64() and self.machine == "pseries"
 
+    def is_s390x(self):
+        return self.arch == "s390x"
+
     _XML_ROOT_NAME = "os"
     _XML_PROP_ORDER = ["arch", "os_type", "loader", "loader_ro", "loader_type",
                        "nvram", "nvram_template", "kernel", "initrd",
-- 
1.8.3.1




More information about the virt-tools-list mailing list