libvirt/SOURCES/libvirt-conf-Move-VFIO-AP-validation-from-post-parse-to-QEMU-validation-code.patch
2021-09-10 11:57:18 +00:00

123 lines
4.0 KiB
Diff

From 680d10a61dfab864b5e1bca9e1f197ae06e62d87 Mon Sep 17 00:00:00 2001
Message-Id: <680d10a61dfab864b5e1bca9e1f197ae06e62d87@dist-git>
From: Erik Skultety <eskultet@redhat.com>
Date: Fri, 30 Nov 2018 15:49:26 +0100
Subject: [PATCH] conf: Move VFIO AP validation from post parse to QEMU
validation code
VFIO AP has a limitation on a single device per domain, however, when
commit 11708641 added the support for vfio-ap, check for this limitation
was performed as part of the post parse code. Generally, checks like that
should be performed within the driver's validation callback to eliminate
any slight chance of failing in post parse, which could potentially
result in the domain XML config vanishing.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
(cherry picked from commit 25dde373730545894f60ce5b1497f19d61714c69)
https://bugzilla.redhat.com/show_bug.cgi?id=1508146
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/conf/domain_conf.c | 28 ----------------------------
src/qemu/qemu_domain.c | 28 +++++++++++++++++++++++++++-
2 files changed, 27 insertions(+), 29 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ea7152eb94..e013e9f0c5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4325,31 +4325,6 @@ 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
@@ -5262,9 +5237,6 @@ virDomainDefPostParseCommon(virDomainDefPtr def,
virDomainDefPostParseGraphics(def);
- if (virDomainDefPostParseHostdev(def) < 0)
- return -1;
-
if (virDomainDefPostParseCPU(def) < 0)
return -1;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 4898d58733..08f479fa1d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4486,6 +4486,32 @@ qemuDomainMdevDefVFIOPCIValidate(const virDomainHostdevSubsysMediatedDev *dev,
}
+static int
+qemuDomainMdevDefVFIOAPValidate(const virDomainDef *def)
+{
+ size_t i;
+ bool vfioap_found = false;
+
+ /* VFIO-AP is restricted to a single mediated device only */
+ 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;
+}
+
+
static int
qemuDomainMdevDefValidate(const virDomainHostdevSubsysMediatedDev *mdevsrc,
const virDomainDef *def,
@@ -4495,7 +4521,7 @@ qemuDomainMdevDefValidate(const virDomainHostdevSubsysMediatedDev *mdevsrc,
case VIR_MDEV_MODEL_TYPE_VFIO_PCI:
return qemuDomainMdevDefVFIOPCIValidate(mdevsrc, def, qemuCaps);
case VIR_MDEV_MODEL_TYPE_VFIO_AP:
- break;
+ return qemuDomainMdevDefVFIOAPValidate(def);
case VIR_MDEV_MODEL_TYPE_VFIO_CCW:
break;
case VIR_MDEV_MODEL_TYPE_LAST:
--
2.19.2