]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: vfio-ccw device address generation
authorShalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
Mon, 7 May 2018 14:41:14 +0000 (16:41 +0200)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 14 May 2018 16:27:44 +0000 (12:27 -0400)
Introduces the vfio-ccw model for mediated devices and prime vfio-ccw
devices such that CCW address will be generated.

Alters the qemuxml2xmltest for testing a basic mdev device using vfio-ccw.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/qemu/qemu_domain_address.c
src/util/virmdev.c
src/util/virmdev.h
tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.xml [new file with mode: 0644]
tests/qemuxml2xmloutdata/hostdev-subsys-mdev-vfio-ccw.xml [new file with mode: 0644]
tests/qemuxml2xmltest.c

index 13af5b74a4988ecd4076e5235e5c6dcdbaef9f53..ff539607cc0bf309f1a699658482c0e28d9da346 100644 (file)
       <value>mdev</value>
     </attribute>
     <attribute name="model">
-      <value>vfio-pci</value>
+      <choice>
+        <value>vfio-pci</value>
+        <value>vfio-ccw</value>
+      </choice>
     </attribute>
     <element name="source">
       <ref name="mdevaddress"/>
index 86229db654f98da12ae2d3e857c64deb850e22da..d38a775f21860d98dc7243a8f8d4c46324bb5c52 100644 (file)
@@ -4470,6 +4470,18 @@ virDomainHostdevDefPostParse(virDomainHostdevDefPtr dev,
                            virMediatedDeviceModelTypeToString(model));
             return -1;
         }
+
+        if ((model == VIR_MDEV_MODEL_TYPE_VFIO_PCI &&
+            dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) ||
+            (model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
+            dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("Unsupported address type '%s' with mediated "
+                             "device model '%s'"),
+                           virDomainDeviceAddressTypeToString(dev->info->type),
+                           virMediatedDeviceModelTypeToString(model));
+            return -1;
+        }
     }
 
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
index 50f815c8cfd0eab463ace3963389d7070b66985a..b7c82cb6f104ed821efacadcd24da91260386ed3 100644 (file)
@@ -281,6 +281,23 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
 }
 
 
+static void
+qemuDomainPrimeVfioDeviceAddresses(virDomainDefPtr def,
+                                   virDomainDeviceAddressType type)
+{
+    size_t i;
+
+    for (i = 0; i < def->nhostdevs; i++) {
+        virDomainHostdevSubsysPtr subsys = &def->hostdevs[i]->source.subsys;
+
+        if (virHostdevIsMdevDevice(def->hostdevs[i]) &&
+            subsys->u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
+            def->hostdevs[i]->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
+            def->hostdevs[i]->info->type = type;
+    }
+}
+
+
 static void
 qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def,
                                      virDomainDeviceAddressType type)
@@ -397,6 +414,9 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def,
 
     if (qemuDomainIsS390CCW(def) &&
         virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW)) {
+        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_CCW))
+            qemuDomainPrimeVfioDeviceAddresses(
+                def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW);
         qemuDomainPrimeVirtioDeviceAddresses(
             def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW);
 
index 536ddbeed2862b50607a0c71a2200b19056968e6..6c513884b8d60092ee541698ccde1195995303ac 100644 (file)
@@ -48,7 +48,8 @@ struct _virMediatedDeviceList {
 };
 
 VIR_ENUM_IMPL(virMediatedDeviceModel, VIR_MDEV_MODEL_TYPE_LAST,
-              "vfio-pci")
+              "vfio-pci",
+              "vfio-ccw")
 
 static virClassPtr virMediatedDeviceListClass;
 
index 01ab02e751b933bdb005014a3455b9e5800dfec6..cfda2cacab4e7c34dcf428183307d9c207fd99b1 100644 (file)
@@ -25,6 +25,7 @@
 
 typedef enum {
     VIR_MDEV_MODEL_TYPE_VFIO_PCI = 0,
+    VIR_MDEV_MODEL_TYPE_VFIO_CCW = 1,
 
     VIR_MDEV_MODEL_TYPE_LAST
 } virMediatedDeviceModelType;
diff --git a/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.xml b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.xml
new file mode 100644 (file)
index 0000000..96f30f5
--- /dev/null
@@ -0,0 +1,22 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>524288</memory>
+  <currentMemory unit='KiB'>524288</currentMemory>
+  <vcpu placement='static'>2</vcpu>
+  <os>
+    <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-s390x</emulator>
+    <hostdev mode='subsystem' type='mdev' model='vfio-ccw'>
+      <source>
+        <address uuid='90c6c135-ad44-41d0-b1b7-bae47de48627'/>
+      </source>
+    </hostdev>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/hostdev-subsys-mdev-vfio-ccw.xml b/tests/qemuxml2xmloutdata/hostdev-subsys-mdev-vfio-ccw.xml
new file mode 100644 (file)
index 0000000..a14ab05
--- /dev/null
@@ -0,0 +1,28 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>524288</memory>
+  <currentMemory unit='KiB'>524288</currentMemory>
+  <vcpu placement='static'>2</vcpu>
+  <os>
+    <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-s390x</emulator>
+    <hostdev mode='subsystem' type='mdev' managed='no' model='vfio-ccw'>
+      <source>
+        <address uuid='90c6c135-ad44-41d0-b1b7-bae47de48627'/>
+      </source>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+    </hostdev>
+    <memballoon model='virtio'>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
+    </memballoon>
+    <panic model='s390'/>
+  </devices>
+</domain>
index 7448c6d668262f59523e8507780fba7369d40685..5faf318b7bec9161515ebd683f0a20c0557fc643 100644 (file)
@@ -962,6 +962,11 @@ mymain(void)
             QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
             QEMU_CAPS_DEVICE_SCSI_GENERIC);
 
+    DO_TEST("hostdev-subsys-mdev-vfio-ccw",
+            QEMU_CAPS_CCW,
+            QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
+            QEMU_CAPS_DEVICE_VFIO_CCW);
+
     DO_TEST("s390-defaultconsole",
             QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
     DO_TEST("s390-panic",