Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/conf/domain_conf.c | 180 +++++++++++------------------------------
1 file changed, 49 insertions(+), 131 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7e17ded2a1..97eb1b6f8a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10719,7 +10719,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;
@@ -10729,7 +10728,6 @@ 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;
const char *prefix = xmlopt ? xmlopt->config.netPrefix : NULL;
@@ -10749,16 +10747,9 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
def->type = VIR_DOMAIN_NET_TYPE_USER;
}
- if ((trustGuestRxFilters = virXMLPropString(node, "trustGuestRxFilters")))
{
- int value;
- if ((value = virTristateBoolTypeFromString(trustGuestRxFilters)) <= 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown trustGuestRxFilters value
'%s'"),
- trustGuestRxFilters);
- goto error;
- }
- def->trustGuestRxFilters = value;
- }
+ if (virXMLPropTristateBool(node, "trustGuestRxFilters", false,
+ &def->trustGuestRxFilters) < 0)
+ goto error;
cur = node->children;
while (cur != NULL) {
@@ -11328,128 +11319,55 @@ 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 (virXMLPropTristateSwitch(tmpNode, "csum", false,
+ &def->driver.virtio.host.csum) < 0)
+ goto error;
+
+ if (virXMLPropTristateSwitch(tmpNode, "gso", false,
+ &def->driver.virtio.host.gso) < 0)
+ goto error;
+
+ if (virXMLPropTristateSwitch(tmpNode, "tso4", false,
+ &def->driver.virtio.host.tso4) < 0)
+ goto error;
+
+ if (virXMLPropTristateSwitch(tmpNode, "tso6", false,
+ &def->driver.virtio.host.tso6) < 0)
+ goto error;
+
+ if (virXMLPropTristateSwitch(tmpNode, "ecn", false,
+ &def->driver.virtio.host.ecn) < 0)
+ goto error;
+
+ if (virXMLPropTristateSwitch(tmpNode, "ufo", false,
+ &def->driver.virtio.host.ufo) < 0)
+ goto error;
+
+ if (virXMLPropTristateSwitch(tmpNode, "mrg_rxbuf", false,
+ &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 (virXMLPropTristateSwitch(tmpNode, "csum", false,
+ &def->driver.virtio.guest.csum) < 0)
+ goto error;
+
+ if (virXMLPropTristateSwitch(tmpNode, "tso4", false,
+ &def->driver.virtio.guest.tso4) < 0)
+ goto error;
+
+ if (virXMLPropTristateSwitch(tmpNode, "tso6", false,
+ &def->driver.virtio.guest.tso6) < 0)
+ goto error;
+
+ if (virXMLPropTristateSwitch(tmpNode, "ecn", false,
+ &def->driver.virtio.guest.ecn) < 0)
+ goto error;
+
+ if (virXMLPropTristateSwitch(tmpNode, "ufo", false,
+ &def->driver.virtio.guest.ufo) < 0)
+ goto error;
}
def->backend.vhost = g_steal_pointer(&vhost_path);
}
--
2.26.2