mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
conf: use virXMLPropString for network parsing
XPath is good for random search of elements, not for accessing attributes of one node. Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
dee01fc5a0
commit
8cf6eb4612
@ -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,
|
|||||||
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,7 +10402,9 @@ 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 ((tmpNode = virXPathNode("./driver/host", ctxt))) {
|
||||||
|
if ((str = virXMLPropString(tmpNode, "csum"))) {
|
||||||
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown host csum mode '%s'"),
|
_("unknown host csum mode '%s'"),
|
||||||
@ -10409,7 +10414,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
def->driver.virtio.host.csum = val;
|
def->driver.virtio.host.csum = val;
|
||||||
}
|
}
|
||||||
VIR_FREE(str);
|
VIR_FREE(str);
|
||||||
if ((str = virXPathString("string(./driver/host/@gso)", ctxt))) {
|
if ((str = virXMLPropString(tmpNode, "gso"))) {
|
||||||
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown host gso mode '%s'"),
|
_("unknown host gso mode '%s'"),
|
||||||
@ -10419,7 +10424,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
def->driver.virtio.host.gso = val;
|
def->driver.virtio.host.gso = val;
|
||||||
}
|
}
|
||||||
VIR_FREE(str);
|
VIR_FREE(str);
|
||||||
if ((str = virXPathString("string(./driver/host/@tso4)", ctxt))) {
|
if ((str = virXMLPropString(tmpNode, "tso4"))) {
|
||||||
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown host tso4 mode '%s'"),
|
_("unknown host tso4 mode '%s'"),
|
||||||
@ -10429,7 +10434,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
def->driver.virtio.host.tso4 = val;
|
def->driver.virtio.host.tso4 = val;
|
||||||
}
|
}
|
||||||
VIR_FREE(str);
|
VIR_FREE(str);
|
||||||
if ((str = virXPathString("string(./driver/host/@tso6)", ctxt))) {
|
if ((str = virXMLPropString(tmpNode, "tso6"))) {
|
||||||
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown host tso6 mode '%s'"),
|
_("unknown host tso6 mode '%s'"),
|
||||||
@ -10439,7 +10444,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
def->driver.virtio.host.tso6 = val;
|
def->driver.virtio.host.tso6 = val;
|
||||||
}
|
}
|
||||||
VIR_FREE(str);
|
VIR_FREE(str);
|
||||||
if ((str = virXPathString("string(./driver/host/@ecn)", ctxt))) {
|
if ((str = virXMLPropString(tmpNode, "ecn"))) {
|
||||||
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown host ecn mode '%s'"),
|
_("unknown host ecn mode '%s'"),
|
||||||
@ -10449,7 +10454,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
def->driver.virtio.host.ecn = val;
|
def->driver.virtio.host.ecn = val;
|
||||||
}
|
}
|
||||||
VIR_FREE(str);
|
VIR_FREE(str);
|
||||||
if ((str = virXPathString("string(./driver/host/@ufo)", ctxt))) {
|
if ((str = virXMLPropString(tmpNode, "ufo"))) {
|
||||||
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown host ufo mode '%s'"),
|
_("unknown host ufo mode '%s'"),
|
||||||
@ -10459,7 +10464,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
def->driver.virtio.host.ufo = val;
|
def->driver.virtio.host.ufo = val;
|
||||||
}
|
}
|
||||||
VIR_FREE(str);
|
VIR_FREE(str);
|
||||||
if ((str = virXPathString("string(./driver/host/@mrg_rxbuf)", ctxt))) {
|
if ((str = virXMLPropString(tmpNode, "mrg_rxbuf"))) {
|
||||||
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown host mrg_rxbuf mode '%s'"),
|
_("unknown host mrg_rxbuf mode '%s'"),
|
||||||
@ -10469,7 +10474,10 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
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 ((str = virXMLPropString(tmpNode, "csum"))) {
|
||||||
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown guest csum mode '%s'"),
|
_("unknown guest csum mode '%s'"),
|
||||||
@ -10479,7 +10487,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
def->driver.virtio.guest.csum = val;
|
def->driver.virtio.guest.csum = val;
|
||||||
}
|
}
|
||||||
VIR_FREE(str);
|
VIR_FREE(str);
|
||||||
if ((str = virXPathString("string(./driver/guest/@tso4)", ctxt))) {
|
if ((str = virXMLPropString(tmpNode, "tso4"))) {
|
||||||
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown guest tso4 mode '%s'"),
|
_("unknown guest tso4 mode '%s'"),
|
||||||
@ -10489,7 +10497,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
def->driver.virtio.guest.tso4 = val;
|
def->driver.virtio.guest.tso4 = val;
|
||||||
}
|
}
|
||||||
VIR_FREE(str);
|
VIR_FREE(str);
|
||||||
if ((str = virXPathString("string(./driver/guest/@tso6)", ctxt))) {
|
if ((str = virXMLPropString(tmpNode, "tso6"))) {
|
||||||
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown guest tso6 mode '%s'"),
|
_("unknown guest tso6 mode '%s'"),
|
||||||
@ -10499,7 +10507,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
def->driver.virtio.guest.tso6 = val;
|
def->driver.virtio.guest.tso6 = val;
|
||||||
}
|
}
|
||||||
VIR_FREE(str);
|
VIR_FREE(str);
|
||||||
if ((str = virXPathString("string(./driver/guest/@ecn)", ctxt))) {
|
if ((str = virXMLPropString(tmpNode, "ecn"))) {
|
||||||
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown guest ecn mode '%s'"),
|
_("unknown guest ecn mode '%s'"),
|
||||||
@ -10509,7 +10517,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
def->driver.virtio.guest.ecn = val;
|
def->driver.virtio.guest.ecn = val;
|
||||||
}
|
}
|
||||||
VIR_FREE(str);
|
VIR_FREE(str);
|
||||||
if ((str = virXPathString("string(./driver/guest/@ufo)", ctxt))) {
|
if ((str = virXMLPropString(tmpNode, "ufo"))) {
|
||||||
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown guest ufo mode '%s'"),
|
_("unknown guest ufo mode '%s'"),
|
||||||
@ -10518,6 +10526,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
}
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user