Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx> --- src/conf/domain_conf.c | 41 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3c69f3913a..4bcae93c37 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15777,40 +15777,17 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, iommu->model = val; if ((driver = virXPathNode("./driver", ctxt))) { - VIR_FREE(tmp); - if ((tmp = virXMLPropString(driver, "intremap"))) { - if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_XML_ERROR, _("unknown intremap value: %s"), tmp); - return NULL; - } - iommu->intremap = val; - } + if (virXMLPropTristateSwitch(driver, "intremap", false, &iommu->intremap) < 0) + return NULL; - VIR_FREE(tmp); - if ((tmp = virXMLPropString(driver, "caching_mode"))) { - if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_XML_ERROR, _("unknown caching_mode value: %s"), tmp); - return NULL; - } - iommu->caching_mode = val; - } - VIR_FREE(tmp); - if ((tmp = virXMLPropString(driver, "iotlb"))) { - if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_XML_ERROR, _("unknown iotlb value: %s"), tmp); - return NULL; - } - iommu->iotlb = val; - } + if (virXMLPropTristateSwitch(driver, "caching_mode", false, &iommu->caching_mode) < 0) + return NULL; - VIR_FREE(tmp); - if ((tmp = virXMLPropString(driver, "eim"))) { - if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_XML_ERROR, _("unknown eim value: %s"), tmp); - return NULL; - } - iommu->eim = val; - } + if (virXMLPropTristateSwitch(driver, "iotlb", false, &iommu->iotlb) < 0) + return NULL; + + if (virXMLPropTristateSwitch(driver, "eim", false, &iommu->eim) < 0) + return NULL; VIR_FREE(tmp); if ((tmp = virXMLPropString(driver, "aw_bits"))) { -- 2.26.2