Instead of duplicating the list of attributes that are not
allowed for some of the IOMMU models, use two separate switch
statements: one for the attributes and one for the address.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
src/conf/domain_validate.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 88205c64e0..1c78a3d31c 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -2633,6 +2633,7 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *iommu)
{
switch (iommu->model) {
case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
+ case VIR_DOMAIN_IOMMU_MODEL_VIRTIO:
if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT ||
iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT ||
iommu->eim != VIR_TRISTATE_SWITCH_ABSENT ||
@@ -2643,8 +2644,15 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *iommu)
virDomainIOMMUModelTypeToString(iommu->model));
return -1;
}
- G_GNUC_FALLTHROUGH;
+ break;
+ case VIR_DOMAIN_IOMMU_MODEL_INTEL:
+ case VIR_DOMAIN_IOMMU_MODEL_LAST:
+ break;
+ }
+
+ switch (iommu->model) {
+ case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
case VIR_DOMAIN_IOMMU_MODEL_INTEL:
if (iommu->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
virReportError(VIR_ERR_XML_ERROR,
@@ -2655,18 +2663,6 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *iommu)
break;
case VIR_DOMAIN_IOMMU_MODEL_VIRTIO:
- if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT ||
- iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT ||
- iommu->eim != VIR_TRISTATE_SWITCH_ABSENT ||
- iommu->iotlb != VIR_TRISTATE_SWITCH_ABSENT ||
- iommu->aw_bits != 0) {
- virReportError(VIR_ERR_XML_ERROR,
- _("iommu model '%s' doesn't support additional attributes"),
- virDomainIOMMUModelTypeToString(iommu->model));
- return -1;
- }
- break;
-
case VIR_DOMAIN_IOMMU_MODEL_LAST:
break;
}
--
2.37.1
On a Monday in 2022, Andrea Bolognani wrote: >Instead of duplicating the list of attributes that are not >allowed for some of the IOMMU models, use two separate switch >statements: one for the attributes and one for the address. > >Signed-off-by: Andrea Bolognani <abologna@redhat.com> >--- > src/conf/domain_validate.c | 22 +++++++++------------- > 1 file changed, 9 insertions(+), 13 deletions(-) > Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
On Mon, Aug 08, 2022 at 05:41:16PM +0200, Andrea Bolognani wrote: > Instead of duplicating the list of attributes that are not > allowed for some of the IOMMU models, use two separate switch > statements: one for the attributes and one for the address. > > Signed-off-by: Andrea Bolognani <abologna@redhat.com> > --- > src/conf/domain_validate.c | 22 +++++++++------------- > 1 file changed, 9 insertions(+), 13 deletions(-) Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
© 2016 - 2024 Red Hat, Inc.