mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
conf: Simplify IOMMU device validation
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> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
2dd3ec6f57
commit
d9afab48af
@ -2633,27 +2633,6 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *iommu)
|
||||
{
|
||||
switch (iommu->model) {
|
||||
case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
|
||||
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;
|
||||
}
|
||||
G_GNUC_FALLTHROUGH;
|
||||
|
||||
case VIR_DOMAIN_IOMMU_MODEL_INTEL:
|
||||
if (iommu->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("iommu model '%s' can't have address"),
|
||||
virDomainIOMMUModelTypeToString(iommu->model));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_IOMMU_MODEL_VIRTIO:
|
||||
if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT ||
|
||||
iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT ||
|
||||
@ -2667,6 +2646,23 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *iommu)
|
||||
}
|
||||
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,
|
||||
_("iommu model '%s' can't have address"),
|
||||
virDomainIOMMUModelTypeToString(iommu->model));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_IOMMU_MODEL_VIRTIO:
|
||||
case VIR_DOMAIN_IOMMU_MODEL_LAST:
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user