提交 72241444 编写于 作者: S Shalini Chellathurai Saroja 提交者: John Ferlan

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: NShalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
Reviewed-by: NBjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: NBoris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: NMarc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: NStefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 2b9690b6
......@@ -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"/>
......
......@@ -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:
......
......@@ -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);
......
......@@ -48,7 +48,8 @@ struct _virMediatedDeviceList {
};
VIR_ENUM_IMPL(virMediatedDeviceModel, VIR_MDEV_MODEL_TYPE_LAST,
"vfio-pci")
"vfio-pci",
"vfio-ccw")
static virClassPtr virMediatedDeviceListClass;
......
......@@ -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;
......
<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>
<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>
......@@ -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",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册