Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx> --- src/conf/domain_conf.c | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7dfbca12e5..6997b7d743 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1591,9 +1591,7 @@ static int virDomainVirtioOptionsParseXML(xmlNodePtr driver, virDomainVirtioOptionsPtr *virtio) { - int val; virDomainVirtioOptionsPtr res; - g_autofree char *str = NULL; if (*virtio || !driver) return 0; @@ -1602,34 +1600,14 @@ virDomainVirtioOptionsParseXML(xmlNodePtr driver, res = *virtio; - if ((str = virXMLPropString(driver, "iommu"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("invalid iommu value")); - return -1; - } - res->iommu = val; - } - VIR_FREE(str); + if (virXMLPropTristateSwitch(driver, "iommu", false, &res->iommu) < 0) + return -1; - if ((str = virXMLPropString(driver, "ats"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("invalid ats value")); - return -1; - } - res->ats = val; - } - VIR_FREE(str); + if (virXMLPropTristateSwitch(driver, "ats", false, &res->ats) < 0) + return -1; - if ((str = virXMLPropString(driver, "packed"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("invalid packed value")); - return -1; - } - res->packed = val; - } + if (virXMLPropTristateSwitch(driver, "packed", false, &res->packed) < 0) + return -1; return 0; } -- 2.26.2