mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virDomainControllerDefParseXML: Parse 'index' by virXMLPropInt
'index' is parsed to fit into a signed int but not have negative values. virXMLPropInt can do that internally. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
2486284c8c
commit
e55888d075
@ -8132,7 +8132,6 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
|
||||
int ports;
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
int rc;
|
||||
g_autofree char *idx = NULL;
|
||||
g_autofree char *model = NULL;
|
||||
|
||||
ctxt->node = node;
|
||||
@ -8152,16 +8151,9 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
|
||||
}
|
||||
}
|
||||
|
||||
idx = virXMLPropString(node, "index");
|
||||
if (idx) {
|
||||
unsigned int idxVal;
|
||||
if (virStrToLong_ui(idx, NULL, 10, &idxVal) < 0 || idxVal > INT_MAX) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Cannot parse controller index %s"), idx);
|
||||
return NULL;
|
||||
}
|
||||
def->idx = idxVal;
|
||||
}
|
||||
if (virXMLPropInt(node, "index", 10, VIR_XML_PROP_NONNEGATIVE,
|
||||
&def->idx, def->idx) < 0)
|
||||
return NULL;
|
||||
|
||||
if ((driver = virXPathNode("./driver", ctxt))) {
|
||||
if (virXMLPropUInt(driver, "queues", 10, VIR_XML_PROP_NONE,
|
||||
|
@ -1 +1 @@
|
||||
internal error: Cannot parse controller index -1
|
||||
XML error: Invalid value for attribute 'index' in element 'controller': '-1'. Expected non-negative value
|
||||
|
Loading…
x
Reference in New Issue
Block a user