Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
src/conf/domain_conf.c | 69 ++++++++++++++++++------------------------
1 file changed, 29 insertions(+), 40 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2af3ec6ec3..69f25c30a8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9844,9 +9844,7 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
{
g_autoptr(virDomainControllerDef) def = NULL;
int type = 0;
- xmlNodePtr cur = NULL;
- bool processedModel = false;
- bool processedTarget = false;
+ xmlNodePtr driver = NULL;
int numaNode = -1;
int ports = -1;
VIR_XPATH_NODE_AUTORESTORE(ctxt)
@@ -9903,45 +9901,36 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
def->idx = idxVal;
}
- cur = node->children;
- while (cur != NULL) {
- if (cur->type == XML_ELEMENT_NODE) {
- if (virXMLNodeNameEqual(cur, "driver")) {
- queues = virXMLPropString(cur, "queues");
- cmd_per_lun = virXMLPropString(cur, "cmd_per_lun");
- max_sectors = virXMLPropString(cur, "max_sectors");
- ioeventfd = virXMLPropString(cur, "ioeventfd");
- iothread = virXMLPropString(cur, "iothread");
+ if ((driver = virXPathNode("./driver", ctxt)) &&
+ (virDomainVirtioOptionsParseXML(driver, &def->virtio) < 0))
+ return NULL;
- if (virDomainVirtioOptionsParseXML(cur, &def->virtio) < 0)
- return NULL;
- } else if (virXMLNodeNameEqual(cur, "model")) {
- if (processedModel) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("Multiple <model> elements in "
- "controller definition not allowed"));
- return NULL;
- }
- modelName = virXMLPropString(cur, "name");
- processedModel = true;
- } else if (virXMLNodeNameEqual(cur, "target")) {
- if (processedTarget) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("Multiple <target> elements in "
- "controller definition not allowed"));
- return NULL;
- }
- chassisNr = virXMLPropString(cur, "chassisNr");
- chassis = virXMLPropString(cur, "chassis");
- port = virXMLPropString(cur, "port");
- busNr = virXMLPropString(cur, "busNr");
- hotplug = virXMLPropString(cur, "hotplug");
- targetIndex = virXMLPropString(cur, "index");
- processedTarget = true;
- }
- }
- cur = cur->next;
+ queues = virXPathString("string(./driver/@queues)", ctxt);
+ cmd_per_lun = virXPathString("string(./driver/@cmd_per_lun)", ctxt);
+ max_sectors = virXPathString("string(./driver/@max_sectors)", ctxt);
+ ioeventfd = virXPathString("string(./driver/@ioeventfd)", ctxt);
+ iothread = virXPathString("string(./driver/@iothread)", ctxt);
+
+ if (virXPathBoolean("boolean(count(./model) > 1)", ctxt)) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("Multiple <model> elements in "
+ "controller definition not allowed"));
+ return NULL;
+ }
+ modelName = virXPathString("string(./model/@name)", ctxt);
+
+ if (virXPathBoolean("boolean(count(./target) > 1)", ctxt)) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("Multiple <target> elements in "
+ "controller definition not allowed"));
+ return NULL;
}
+ chassisNr = virXPathString("string(./target/@chassisNr)", ctxt);
+ chassis = virXPathString("string(./target/@chassis)", ctxt);
+ port = virXPathString("string(./target/@port)", ctxt);
+ busNr = virXPathString("string(./target/@busNr)", ctxt);
+ hotplug = virXPathString("string(./target/@hotplug)", ctxt);
+ targetIndex = virXPathString("string(./target/@targetIndex)", ctxt);
/* node is parsed differently from target attributes because
* someone thought it should be a subelement instead...
--
2.30.2