qemu: vfio-ccw device address generation

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>
This commit is contained in:
Shalini Chellathurai Saroja 2018-05-07 16:41:14 +02:00 committed by John Ferlan
parent 2b9690b62d
commit 7224144400
8 changed files with 94 additions and 2 deletions

View File

@ -4457,7 +4457,10 @@
<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"/>

View 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:

View 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);

View 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;

View 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;

View File

@ -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>

View File

@ -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>

View 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",