1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

conf: use virXMLPropString for IOMMU def 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:
Pavel Hrdina 2017-08-15 15:52:38 +02:00
parent 58bf9d1d37
commit dee01fc5a0

View File

@ -14429,6 +14429,7 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
{ {
virDomainIOMMUDefPtr iommu = NULL, ret = NULL; virDomainIOMMUDefPtr iommu = NULL, ret = NULL;
xmlNodePtr save = ctxt->node; xmlNodePtr save = ctxt->node;
xmlNodePtr driver;
char *tmp = NULL; char *tmp = NULL;
int val; int val;
@ -14450,8 +14451,9 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
iommu->model = val; iommu->model = val;
if ((driver = virXPathNode("./driver", ctxt))) {
VIR_FREE(tmp); VIR_FREE(tmp);
if ((tmp = virXPathString("string(./driver/@intremap)", ctxt))) { if ((tmp = virXMLPropString(driver, "intremap"))) {
if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_XML_ERROR, _("unknown intremap value: %s"), tmp); virReportError(VIR_ERR_XML_ERROR, _("unknown intremap value: %s"), tmp);
goto cleanup; goto cleanup;
@ -14460,7 +14462,7 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
} }
VIR_FREE(tmp); VIR_FREE(tmp);
if ((tmp = virXPathString("string(./driver/@caching_mode)", ctxt))) { if ((tmp = virXMLPropString(driver, "caching_mode"))) {
if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_XML_ERROR, _("unknown caching_mode value: %s"), tmp); virReportError(VIR_ERR_XML_ERROR, _("unknown caching_mode value: %s"), tmp);
goto cleanup; goto cleanup;
@ -14468,7 +14470,7 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
iommu->caching_mode = val; iommu->caching_mode = val;
} }
VIR_FREE(tmp); VIR_FREE(tmp);
if ((tmp = virXPathString("string(./driver/@iotlb)", ctxt))) { if ((tmp = virXMLPropString(driver, "iotlb"))) {
if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_XML_ERROR, _("unknown iotlb value: %s"), tmp); virReportError(VIR_ERR_XML_ERROR, _("unknown iotlb value: %s"), tmp);
goto cleanup; goto cleanup;
@ -14477,13 +14479,14 @@ virDomainIOMMUDefParseXML(xmlNodePtr node,
} }
VIR_FREE(tmp); VIR_FREE(tmp);
if ((tmp = virXPathString("string(./driver/@eim)", ctxt))) { if ((tmp = virXMLPropString(driver, "eim"))) {
if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { if ((val = virTristateSwitchTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_XML_ERROR, _("unknown eim value: %s"), tmp); virReportError(VIR_ERR_XML_ERROR, _("unknown eim value: %s"), tmp);
goto cleanup; goto cleanup;
} }
iommu->eim = val; iommu->eim = val;
} }
}
ret = iommu; ret = iommu;
iommu = NULL; iommu = NULL;