提交 8cf6eb46 编写于 作者: P Pavel Hrdina

conf: use virXMLPropString for network parsing

XPath is good for random search of elements, not for accessing
attributes of one node.
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 dee01fc5
...@@ -9793,6 +9793,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, ...@@ -9793,6 +9793,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
virDomainNetDefPtr def; virDomainNetDefPtr def;
virDomainHostdevDefPtr hostdev; virDomainHostdevDefPtr hostdev;
xmlNodePtr cur; xmlNodePtr cur;
xmlNodePtr tmpNode;
char *macaddr = NULL; char *macaddr = NULL;
char *type = NULL; char *type = NULL;
char *network = NULL; char *network = NULL;
...@@ -9952,8 +9953,10 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, ...@@ -9952,8 +9953,10 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
if (!localaddr && def->type == VIR_DOMAIN_NET_TYPE_UDP) { if (!localaddr && def->type == VIR_DOMAIN_NET_TYPE_UDP) {
xmlNodePtr tmpnode = ctxt->node; xmlNodePtr tmpnode = ctxt->node;
ctxt->node = cur; ctxt->node = cur;
localaddr = virXPathString("string(./local/@address)", ctxt); if ((tmpNode = virXPathNode("./local", ctxt))) {
localport = virXPathString("string(./local/@port)", ctxt); localaddr = virXMLPropString(tmpNode, "address");
localport = virXMLPropString(tmpNode, "port");
}
ctxt->node = tmpnode; ctxt->node = tmpnode;
} }
} else if (!ifname && } else if (!ifname &&
...@@ -10399,124 +10402,130 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, ...@@ -10399,124 +10402,130 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
} }
def->driver.virtio.tx_queue_size = q; def->driver.virtio.tx_queue_size = q;
} }
if ((str = virXPathString("string(./driver/host/@csum)", ctxt))) {
if ((val = virTristateSwitchTypeFromString(str)) <= 0) { if ((tmpNode = virXPathNode("./driver/host", ctxt))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, if ((str = virXMLPropString(tmpNode, "csum"))) {
_("unknown host csum mode '%s'"), if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
str); virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
goto error; _("unknown host csum mode '%s'"),
str);
goto error;
}
def->driver.virtio.host.csum = val;
} }
def->driver.virtio.host.csum = val; VIR_FREE(str);
} if ((str = virXMLPropString(tmpNode, "gso"))) {
VIR_FREE(str); if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
if ((str = virXPathString("string(./driver/host/@gso)", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
if ((val = virTristateSwitchTypeFromString(str)) <= 0) { _("unknown host gso mode '%s'"),
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, str);
_("unknown host gso mode '%s'"), goto error;
str); }
goto error; def->driver.virtio.host.gso = val;
} }
def->driver.virtio.host.gso = val; VIR_FREE(str);
} if ((str = virXMLPropString(tmpNode, "tso4"))) {
VIR_FREE(str); if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
if ((str = virXPathString("string(./driver/host/@tso4)", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
if ((val = virTristateSwitchTypeFromString(str)) <= 0) { _("unknown host tso4 mode '%s'"),
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, str);
_("unknown host tso4 mode '%s'"), goto error;
str); }
goto error; def->driver.virtio.host.tso4 = val;
} }
def->driver.virtio.host.tso4 = val; VIR_FREE(str);
} if ((str = virXMLPropString(tmpNode, "tso6"))) {
VIR_FREE(str); if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
if ((str = virXPathString("string(./driver/host/@tso6)", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
if ((val = virTristateSwitchTypeFromString(str)) <= 0) { _("unknown host tso6 mode '%s'"),
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, str);
_("unknown host tso6 mode '%s'"), goto error;
str); }
goto error; def->driver.virtio.host.tso6 = val;
} }
def->driver.virtio.host.tso6 = val; VIR_FREE(str);
} if ((str = virXMLPropString(tmpNode, "ecn"))) {
VIR_FREE(str); if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
if ((str = virXPathString("string(./driver/host/@ecn)", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
if ((val = virTristateSwitchTypeFromString(str)) <= 0) { _("unknown host ecn mode '%s'"),
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, str);
_("unknown host ecn mode '%s'"), goto error;
str); }
goto error; def->driver.virtio.host.ecn = val;
} }
def->driver.virtio.host.ecn = val; VIR_FREE(str);
} if ((str = virXMLPropString(tmpNode, "ufo"))) {
VIR_FREE(str); if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
if ((str = virXPathString("string(./driver/host/@ufo)", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
if ((val = virTristateSwitchTypeFromString(str)) <= 0) { _("unknown host ufo mode '%s'"),
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, str);
_("unknown host ufo mode '%s'"), goto error;
str); }
goto error; def->driver.virtio.host.ufo = val;
} }
def->driver.virtio.host.ufo = val; VIR_FREE(str);
} if ((str = virXMLPropString(tmpNode, "mrg_rxbuf"))) {
VIR_FREE(str); if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
if ((str = virXPathString("string(./driver/host/@mrg_rxbuf)", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
if ((val = virTristateSwitchTypeFromString(str)) <= 0) { _("unknown host mrg_rxbuf mode '%s'"),
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, str);
_("unknown host mrg_rxbuf mode '%s'"), goto error;
str); }
goto error; def->driver.virtio.host.mrg_rxbuf = val;
} }
def->driver.virtio.host.mrg_rxbuf = val; VIR_FREE(str);
} }
VIR_FREE(str);
if ((str = virXPathString("string(./driver/guest/@csum)", ctxt))) { if ((tmpNode = virXPathNode("./driver/guest", ctxt))) {
if ((val = virTristateSwitchTypeFromString(str)) <= 0) { if ((str = virXMLPropString(tmpNode, "csum"))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
_("unknown guest csum mode '%s'"), virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
str); _("unknown guest csum mode '%s'"),
goto error; str);
goto error;
}
def->driver.virtio.guest.csum = val;
} }
def->driver.virtio.guest.csum = val; VIR_FREE(str);
} if ((str = virXMLPropString(tmpNode, "tso4"))) {
VIR_FREE(str); if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
if ((str = virXPathString("string(./driver/guest/@tso4)", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
if ((val = virTristateSwitchTypeFromString(str)) <= 0) { _("unknown guest tso4 mode '%s'"),
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, str);
_("unknown guest tso4 mode '%s'"), goto error;
str); }
goto error; def->driver.virtio.guest.tso4 = val;
} }
def->driver.virtio.guest.tso4 = val; VIR_FREE(str);
} if ((str = virXMLPropString(tmpNode, "tso6"))) {
VIR_FREE(str); if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
if ((str = virXPathString("string(./driver/guest/@tso6)", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
if ((val = virTristateSwitchTypeFromString(str)) <= 0) { _("unknown guest tso6 mode '%s'"),
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, str);
_("unknown guest tso6 mode '%s'"), goto error;
str); }
goto error; def->driver.virtio.guest.tso6 = val;
} }
def->driver.virtio.guest.tso6 = val; VIR_FREE(str);
} if ((str = virXMLPropString(tmpNode, "ecn"))) {
VIR_FREE(str); if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
if ((str = virXPathString("string(./driver/guest/@ecn)", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
if ((val = virTristateSwitchTypeFromString(str)) <= 0) { _("unknown guest ecn mode '%s'"),
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, str);
_("unknown guest ecn mode '%s'"), goto error;
str); }
goto error; def->driver.virtio.guest.ecn = val;
} }
def->driver.virtio.guest.ecn = val; VIR_FREE(str);
} if ((str = virXMLPropString(tmpNode, "ufo"))) {
VIR_FREE(str); if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
if ((str = virXPathString("string(./driver/guest/@ufo)", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
if ((val = virTristateSwitchTypeFromString(str)) <= 0) { _("unknown guest ufo mode '%s'"),
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, str);
_("unknown guest ufo mode '%s'"), goto error;
str); }
goto error; def->driver.virtio.guest.ufo = val;
} }
def->driver.virtio.guest.ufo = val;
} }
def->backend.vhost = vhost_path; def->backend.vhost = vhost_path;
vhost_path = NULL; vhost_path = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册