diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 818995977321d2d682b19eafda27ffdef2ceab01..269741a690c6a0db8f795c4ba69bbcd18e6627e1 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4616,8 +4616,9 @@
For mediated devices (Since 3.2.0) the model attribute specifies the device API which determines how the host's vfio driver will expose the device to the - guest. Currently, model='vfio-pci' and + guest. Currently, model='vfio-pci', model='vfio-ccw' (Since 4.4.0) + and model='vfio-ap' (Since 4.9.0) is supported. MDEV section provides more information about mediated devices as well as how to create mediated devices on the host. diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 099a949cf8b8f911a1ee82847dc8ee4d5d98b140..b9ac5df47906a563f32f45fddfa90d9d501e3f4e 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4618,6 +4618,7 @@ vfio-pci vfio-ccw + vfio-ap diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e8e0adc8194e26823cf3ee46e7a84af1b068a462..237540bccc3b79b6dd993d7d2bf2c81fe0d5119d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4275,6 +4275,31 @@ virDomainDefPostParseGraphics(virDomainDef *def) } +static int +virDomainDefPostParseHostdev(virDomainDefPtr def) +{ + size_t i; + bool vfioap_found = false; + + /* verify settings of hostdevs vfio-ap */ + for (i = 0; i < def->nhostdevs; i++) { + virDomainHostdevDefPtr hostdev = def->hostdevs[i]; + + if (virHostdevIsMdevDevice(hostdev) && + hostdev->source.subsys.u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_AP) { + if (vfioap_found) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only one hostdev of model vfio-ap is " + "supported")); + return -1; + } + vfioap_found = true; + } + } + return 0; +} + + /** * virDomainDriveAddressIsUsedByDisk: * @def: domain definition containing the disks to check @@ -5185,6 +5210,9 @@ virDomainDefPostParseCommon(virDomainDefPtr def, virDomainDefPostParseGraphics(def); + if (virDomainDefPostParseHostdev(def) < 0) + return -1; + if (virDomainDefPostParseCPU(def) < 0) return -1; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1ff593c657f03d5d0cd4e6aa7f9ef2aae1a6bbcf..6e3ff6766082a6b370cd891b4f2c297e919849d4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5476,6 +5476,14 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, return -1; } break; + case VIR_MDEV_MODEL_TYPE_VFIO_AP: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_AP)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("VFIO AP device assignment is not " + "supported by this version of QEMU")); + return -1; + } + break; case VIR_MDEV_MODEL_TYPE_LAST: default: virReportEnumRangeError(virMediatedDeviceModelType, diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 8a8764cff5a47a369e885983ff1682f5ef43397c..24dd7c1a581e6fcdf013af9d8d595b3a48c6c687 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -294,6 +294,10 @@ qemuDomainPrimeVfioDeviceAddresses(virDomainDefPtr def, 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; + + if (virHostdevIsMdevDevice(def->hostdevs[i]) && + subsys->u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_AP) + def->hostdevs[i]->info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; } } diff --git a/src/util/virmdev.c b/src/util/virmdev.c index 10a2b08337019f8b22b34b8b8e871903f4c7f5b6..3e11e388023c8285054e4f24c16126fe0d5d3cb7 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -48,7 +48,8 @@ struct _virMediatedDeviceList { VIR_ENUM_IMPL(virMediatedDeviceModel, VIR_MDEV_MODEL_TYPE_LAST, "vfio-pci", - "vfio-ccw") + "vfio-ccw", + "vfio-ap") static virClassPtr virMediatedDeviceListClass; diff --git a/src/util/virmdev.h b/src/util/virmdev.h index 7c93c4d390cefb0b2012ee9551a81f335186aa9b..c856ff5bdb5b21379b783d1cc9c8476de9b6e298 100644 --- a/src/util/virmdev.h +++ b/src/util/virmdev.h @@ -27,6 +27,7 @@ typedef enum { VIR_MDEV_MODEL_TYPE_VFIO_PCI = 0, VIR_MDEV_MODEL_TYPE_VFIO_CCW = 1, + VIR_MDEV_MODEL_TYPE_VFIO_AP = 2, VIR_MDEV_MODEL_TYPE_LAST } virMediatedDeviceModelType;