Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx> --- src/conf/domain_conf.c | 166 +++++++++-------------------------------- 1 file changed, 37 insertions(+), 129 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 52e1668010..54c647bfd5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10759,7 +10759,6 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, g_autofree char *queues = NULL; g_autofree char *rx_queue_size = NULL; g_autofree char *tx_queue_size = NULL; - g_autofree char *str = NULL; g_autofree char *filter = NULL; g_autofree char *internal = NULL; g_autofree char *mode = NULL; @@ -10769,8 +10768,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, g_autofree char *vhostuser_mode = NULL; g_autofree char *vhostuser_path = NULL; g_autofree char *vhostuser_type = NULL; - g_autofree char *trustGuestRxFilters = NULL; g_autofree char *vhost_path = NULL; + virTristateBool trustGuestRxFilters = VIR_TRISTATE_BOOL_ABSENT; const char *prefix = xmlopt ? xmlopt->config.netPrefix : NULL; if (!(def = virDomainNetDefNew(xmlopt))) @@ -10789,15 +10788,9 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, def->type = VIR_DOMAIN_NET_TYPE_USER; } - trustGuestRxFilters = virXMLPropString(node, "trustGuestRxFilters"); - if (trustGuestRxFilters && - ((def->trustGuestRxFilters - = virTristateBoolTypeFromString(trustGuestRxFilters)) <= 0)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown trustGuestRxFilters value '%s'"), - trustGuestRxFilters); + if (virXMLPropYesNo(node, "trustGuestRxFilters", &trustGuestRxFilters) < 0) goto error; - } + def->trustGuestRxFilters = trustGuestRxFilters; cur = node->children; while (cur != NULL) { @@ -11367,128 +11360,43 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, } if ((tmpNode = virXPathNode("./driver/host", ctxt))) { - if ((str = virXMLPropString(tmpNode, "csum"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown host csum mode '%s'"), - str); - goto error; - } - def->driver.virtio.host.csum = val; - } - VIR_FREE(str); - if ((str = virXMLPropString(tmpNode, "gso"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown host gso mode '%s'"), - str); - goto error; - } - def->driver.virtio.host.gso = val; - } - VIR_FREE(str); - if ((str = virXMLPropString(tmpNode, "tso4"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown host tso4 mode '%s'"), - str); - goto error; - } - def->driver.virtio.host.tso4 = val; - } - VIR_FREE(str); - if ((str = virXMLPropString(tmpNode, "tso6"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown host tso6 mode '%s'"), - str); - goto error; - } - def->driver.virtio.host.tso6 = val; - } - VIR_FREE(str); - if ((str = virXMLPropString(tmpNode, "ecn"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown host ecn mode '%s'"), - str); - goto error; - } - def->driver.virtio.host.ecn = val; - } - VIR_FREE(str); - if ((str = virXMLPropString(tmpNode, "ufo"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown host ufo mode '%s'"), - str); - goto error; - } - def->driver.virtio.host.ufo = val; - } - VIR_FREE(str); - if ((str = virXMLPropString(tmpNode, "mrg_rxbuf"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown host mrg_rxbuf mode '%s'"), - str); - goto error; - } - def->driver.virtio.host.mrg_rxbuf = val; - } - VIR_FREE(str); + if (virXMLPropOnOff(tmpNode, "csum", &def->driver.virtio.host.csum) < 0) + goto error; + + if (virXMLPropOnOff(tmpNode, "gso", &def->driver.virtio.host.gso) < 0) + goto error; + + if (virXMLPropOnOff(tmpNode, "tso4", &def->driver.virtio.host.tso4) < 0) + goto error; + + if (virXMLPropOnOff(tmpNode, "tso6", &def->driver.virtio.host.tso6) < 0) + goto error; + + if (virXMLPropOnOff(tmpNode, "ecn", &def->driver.virtio.host.ecn) < 0) + goto error; + + if (virXMLPropOnOff(tmpNode, "ufo", &def->driver.virtio.host.ufo) < 0) + goto error; + + if (virXMLPropOnOff(tmpNode, "mrg_rxbuf", &def->driver.virtio.host.mrg_rxbuf) < 0) + goto error; } if ((tmpNode = virXPathNode("./driver/guest", ctxt))) { - if ((str = virXMLPropString(tmpNode, "csum"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown guest csum mode '%s'"), - str); - goto error; - } - def->driver.virtio.guest.csum = val; - } - VIR_FREE(str); - if ((str = virXMLPropString(tmpNode, "tso4"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown guest tso4 mode '%s'"), - str); - goto error; - } - def->driver.virtio.guest.tso4 = val; - } - VIR_FREE(str); - if ((str = virXMLPropString(tmpNode, "tso6"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown guest tso6 mode '%s'"), - str); - goto error; - } - def->driver.virtio.guest.tso6 = val; - } - VIR_FREE(str); - if ((str = virXMLPropString(tmpNode, "ecn"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown guest ecn mode '%s'"), - str); - goto error; - } - def->driver.virtio.guest.ecn = val; - } - VIR_FREE(str); - if ((str = virXMLPropString(tmpNode, "ufo"))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown guest ufo mode '%s'"), - str); - goto error; - } - def->driver.virtio.guest.ufo = val; - } + if (virXMLPropOnOff(tmpNode, "csum", &def->driver.virtio.guest.csum) < 0) + goto error; + + if (virXMLPropOnOff(tmpNode, "tso4", &def->driver.virtio.guest.tso4) < 0) + goto error; + + if (virXMLPropOnOff(tmpNode, "tso6", &def->driver.virtio.guest.tso6) < 0) + goto error; + + if (virXMLPropOnOff(tmpNode, "ecn", &def->driver.virtio.guest.ecn) < 0) + goto error; + + if (virXMLPropOnOff(tmpNode, "ufo", &def->driver.virtio.guest.ufo) < 0) + goto error; } def->backend.vhost = g_steal_pointer(&vhost_path); } -- 2.26.2