All other validations from virDomainDefValidateInternal() are done in their own functions. Take IOMMU validation out of the function body and into its own function. Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx> --- src/conf/domain_validate.c | 41 ++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 2a881f1f06..4cc1d11647 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1042,6 +1042,31 @@ virDomainDefCputuneValidate(const virDomainDef *def) #undef CPUTUNE_VALIDATE_QUOTA +static int +virDomainDefIOMMUValidate(const virDomainDef *def) +{ + if (!def->iommu) + return 0; + + if (def->iommu->intremap == VIR_TRISTATE_SWITCH_ON && + def->features[VIR_DOMAIN_FEATURE_IOAPIC] != VIR_DOMAIN_IOAPIC_QEMU) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("IOMMU interrupt remapping requires split I/O APIC " + "(ioapic driver='qemu')")); + return -1; + } + + if (def->iommu->eim == VIR_TRISTATE_SWITCH_ON && + def->iommu->intremap != VIR_TRISTATE_SWITCH_ON) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("IOMMU eim requires interrupt remapping to be enabled")); + return -1; + } + + return 0; +} + + static int virDomainDefValidateInternal(const virDomainDef *def, virDomainXMLOptionPtr xmlopt) @@ -1058,22 +1083,8 @@ virDomainDefValidateInternal(const virDomainDef *def, if (virDomainDefValidateAliases(def, NULL) < 0) return -1; - if (def->iommu && - def->iommu->intremap == VIR_TRISTATE_SWITCH_ON && - def->features[VIR_DOMAIN_FEATURE_IOAPIC] != VIR_DOMAIN_IOAPIC_QEMU) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("IOMMU interrupt remapping requires split I/O APIC " - "(ioapic driver='qemu')")); - return -1; - } - - if (def->iommu && - def->iommu->eim == VIR_TRISTATE_SWITCH_ON && - def->iommu->intremap != VIR_TRISTATE_SWITCH_ON) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("IOMMU eim requires interrupt remapping to be enabled")); + if (virDomainDefIOMMUValidate(def) < 0) return -1; - } if (virDomainDefLifecycleActionValidate(def) < 0) return -1; -- 2.26.2