mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virDomainNumaDefParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
de057e2cc3
commit
9563732306
@ -954,26 +954,23 @@ virDomainNumaDefParseXML(virDomainNuma *def,
|
|||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
int rc;
|
int rc;
|
||||||
unsigned int cur_cell = i;
|
unsigned int cur_cell;
|
||||||
|
|
||||||
|
if ((rc = virXMLPropUInt(nodes[i], "id", 10, VIR_XML_PROP_NONE,
|
||||||
|
&cur_cell)) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (rc == 0)
|
||||||
|
cur_cell = i;
|
||||||
|
|
||||||
/* cells are in order of parsing or explicitly numbered */
|
/* cells are in order of parsing or explicitly numbered */
|
||||||
if ((tmp = virXMLPropString(nodes[i], "id"))) {
|
if (cur_cell >= n) {
|
||||||
if (virStrToLong_uip(tmp, NULL, 10, &cur_cell) < 0) {
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
_("Exactly one 'cell' element per guest "
|
||||||
_("Invalid 'id' attribute in NUMA cell: '%s'"),
|
"NUMA cell allowed, non-contiguous ranges or "
|
||||||
tmp);
|
"ranges not starting from 0 are not allowed"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (cur_cell >= n) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
||||||
_("Exactly one 'cell' element per guest "
|
|
||||||
"NUMA cell allowed, non-contiguous ranges or "
|
|
||||||
"ranges not starting from 0 are not allowed"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
VIR_FREE(tmp);
|
|
||||||
|
|
||||||
if (def->mem_nodes[cur_cell].mem) {
|
if (def->mem_nodes[cur_cell].mem) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
@ -1013,29 +1010,15 @@ virDomainNumaDefParseXML(virDomainNuma *def,
|
|||||||
&def->mem_nodes[cur_cell].mem, true, false) < 0)
|
&def->mem_nodes[cur_cell].mem, true, false) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((tmp = virXMLPropString(nodes[i], "memAccess"))) {
|
if (virXMLPropEnum(nodes[i], "memAccess",
|
||||||
if ((rc = virDomainMemoryAccessTypeFromString(tmp)) <= 0) {
|
virDomainMemoryAccessTypeFromString,
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
VIR_XML_PROP_NONZERO,
|
||||||
_("Invalid 'memAccess' attribute value '%s'"),
|
&def->mem_nodes[cur_cell].memAccess) < 0)
|
||||||
tmp);
|
goto cleanup;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
def->mem_nodes[cur_cell].memAccess = rc;
|
if (virXMLPropTristateBool(nodes[i], "discard", VIR_XML_PROP_NONE,
|
||||||
VIR_FREE(tmp);
|
&def->mem_nodes[cur_cell].discard) < 0)
|
||||||
}
|
goto cleanup;
|
||||||
|
|
||||||
if ((tmp = virXMLPropString(nodes[i], "discard"))) {
|
|
||||||
if ((rc = virTristateBoolTypeFromString(tmp)) <= 0) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("Invalid 'discard' attribute value '%s'"),
|
|
||||||
tmp);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
def->mem_nodes[cur_cell].discard = rc;
|
|
||||||
VIR_FREE(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Parse NUMA distances info */
|
/* Parse NUMA distances info */
|
||||||
if (virDomainNumaDefNodeDistanceParseXML(def, ctxt, cur_cell) < 0)
|
if (virDomainNumaDefNodeDistanceParseXML(def, ctxt, cur_cell) < 0)
|
||||||
@ -1057,24 +1040,15 @@ virDomainNumaDefParseXML(virDomainNuma *def,
|
|||||||
unsigned int initiator;
|
unsigned int initiator;
|
||||||
unsigned int target;
|
unsigned int target;
|
||||||
unsigned int cache = 0;
|
unsigned int cache = 0;
|
||||||
int accessType;
|
virDomainMemoryLatency accessType;
|
||||||
unsigned long long value;
|
unsigned long long value;
|
||||||
|
|
||||||
if (virXMLNodeNameEqual(nodes[i], "latency")) {
|
if (virXMLNodeNameEqual(nodes[i], "latency")) {
|
||||||
type = VIR_DOMAIN_NUMA_INTERCONNECT_TYPE_LATENCY;
|
type = VIR_DOMAIN_NUMA_INTERCONNECT_TYPE_LATENCY;
|
||||||
|
|
||||||
if (!(tmp = virXMLPropString(nodes[i], "value"))) {
|
if (virXMLPropULongLong(nodes[i], "value", 10,
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
VIR_XML_PROP_REQUIRED, &value) < 0)
|
||||||
_("Missing 'value' attribute in NUMA interconnects"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virStrToLong_ullp(tmp, NULL, 10, &value) < 0) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
||||||
_("Invalid 'value' attribute in NUMA interconnects"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
VIR_FREE(tmp);
|
|
||||||
} else if (virXMLNodeNameEqual(nodes[i], "bandwidth")) {
|
} else if (virXMLNodeNameEqual(nodes[i], "bandwidth")) {
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
type = VIR_DOMAIN_NUMA_INTERCONNECT_TYPE_BANDWIDTH;
|
type = VIR_DOMAIN_NUMA_INTERCONNECT_TYPE_BANDWIDTH;
|
||||||
@ -1088,56 +1062,22 @@ virDomainNumaDefParseXML(virDomainNuma *def,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(tmp = virXMLPropString(nodes[i], "initiator"))) {
|
if (virXMLPropUInt(nodes[i], "initiator", 10, VIR_XML_PROP_REQUIRED,
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
&initiator) < 0)
|
||||||
_("Missing 'initiator' attribute in NUMA interconnects"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virStrToLong_uip(tmp, NULL, 10, &initiator) < 0) {
|
if (virXMLPropUInt(nodes[i], "target", 10, VIR_XML_PROP_REQUIRED,
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
&target) < 0)
|
||||||
_("Invalid 'initiator' attribute in NUMA interconnects"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
VIR_FREE(tmp);
|
|
||||||
|
|
||||||
if (!(tmp = virXMLPropString(nodes[i], "target"))) {
|
if (virXMLPropUInt(nodes[i], "cache", 10, VIR_XML_PROP_NONE,
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
&cache) < 0)
|
||||||
_("Missing 'target' attribute in NUMA interconnects"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virStrToLong_uip(tmp, NULL, 10, &target) < 0) {
|
if (virXMLPropEnum(nodes[i], "type", virDomainMemoryLatencyTypeFromString,
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO,
|
||||||
_("Invalid 'target' attribute in NUMA interconnects"));
|
&accessType) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
VIR_FREE(tmp);
|
|
||||||
|
|
||||||
|
|
||||||
/* cache attribute is optional */
|
|
||||||
if ((tmp = virXMLPropString(nodes[i], "cache"))) {
|
|
||||||
if (virStrToLong_uip(tmp, NULL, 10, &cache) < 0 ||
|
|
||||||
cache == 0) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
||||||
_("Invalid 'cache' attribute in NUMA interconnects"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
VIR_FREE(tmp);
|
|
||||||
|
|
||||||
if (!(tmp = virXMLPropString(nodes[i], "type"))) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
||||||
_("Missing 'type' attribute in NUMA interconnects"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((accessType = virDomainMemoryLatencyTypeFromString(tmp)) <= 0) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
||||||
_("Invalid 'type' attribute in NUMA interconnects"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
VIR_FREE(tmp);
|
|
||||||
|
|
||||||
def->interconnects[i] = (virDomainNumaInterconnect) {type, initiator, target,
|
def->interconnects[i] = (virDomainNumaInterconnect) {type, initiator, target,
|
||||||
cache, accessType, value};
|
cache, accessType, value};
|
||||||
|
@ -1 +1 @@
|
|||||||
unsupported configuration: Invalid 'memAccess' attribute value 'invalid'
|
XML error: Invalid value for attribute 'memAccess' in element 'cell': 'invalid'.
|
||||||
|
Loading…
Reference in New Issue
Block a user