From 4b249d6de82cd42d29aeccccef4ae483c71b1528 Mon Sep 17 00:00:00 2001 Message-Id: <4b249d6de82cd42d29aeccccef4ae483c71b1528@dist-git> From: Boris Fiuczynski Date: Fri, 30 Nov 2018 15:49:24 +0100 Subject: [PATCH] qemu: vfio-ap device support Adjusting domain format documentation, adding device address support and adding command line generation for vfio-ap. Since only one mediated hostdev with model vfio-ap is supported a check disallows to define domains with more than one such hostdev device. Signed-off-by: Boris Fiuczynski Reviewed-by: Bjoern Walk Reviewed-by: Chris Venteicher (cherry picked from commit 11708641983e9107a129c62fd343d0fec228342f) https://bugzilla.redhat.com/show_bug.cgi?id=1508146 Signed-off-by: Pino Toscano Reviewed-by: Jiri Denemark --- docs/formatdomain.html.in | 3 ++- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 28 ++++++++++++++++++++++++++++ src/qemu/qemu_command.c | 8 ++++++++ src/qemu/qemu_domain_address.c | 4 ++++ src/util/virmdev.c | 3 ++- src/util/virmdev.h | 1 + 7 files changed, 46 insertions(+), 2 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index c019b26644..54eb298414 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4528,8 +4528,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 1c6f2a295d..e4ce7804b9 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4578,6 +4578,7 @@ vfio-pci vfio-ccw + vfio-ap diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e013e9f0c5..ea7152eb94 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4325,6 +4325,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 @@ -5237,6 +5262,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 a3d605c00f..320ecd902c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5430,6 +5430,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: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected vfio type '%d'"), subsys->u.mdev.model); diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 0cb5af4a87..3e50521c11 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 6c513884b8..1b5897c654 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -49,7 +49,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 cfda2cacab..ba411a933a 100644 --- a/src/util/virmdev.h +++ b/src/util/virmdev.h @@ -26,6 +26,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; -- 2.19.2