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 0b009bb237..c7d2e86dfe 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15776,40 +15776,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