mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
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>
This commit is contained in:
parent
208d6e6f5a
commit
25dde37373
@ -4275,31 +4275,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
|
||||
@ -5210,9 +5185,6 @@ virDomainDefPostParseCommon(virDomainDefPtr def,
|
||||
|
||||
virDomainDefPostParseGraphics(def);
|
||||
|
||||
if (virDomainDefPostParseHostdev(def) < 0)
|
||||
return -1;
|
||||
|
||||
if (virDomainDefPostParseCPU(def) < 0)
|
||||
return -1;
|
||||
|
||||
|
@ -4599,6 +4599,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,
|
||||
@ -4608,7 +4634,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:
|
||||
|
Loading…
Reference in New Issue
Block a user