[PATCH 5/5] virCPUDefParseXML: Parse uint using virXPathUInt
Michal Privoznik
mprivozn at redhat.com
Fri May 22 14:14:15 UTC 2020
Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
src/conf/cpu_conf.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 07404c6fb0..2991ab8204 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -527,39 +527,33 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
}
if (virXPathNode("./topology[1]", ctxt)) {
- unsigned long ul;
-
- if (virXPathULong("string(./topology[1]/@sockets)", ctxt, &ul) < 0) {
+ if (virXPathUInt("string(./topology[1]/@sockets)", ctxt, &def->sockets) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing 'sockets' attribute in CPU topology"));
goto cleanup;
}
- def->sockets = (unsigned int) ul;
if (virXPathNode("./topology[1]/@dies", ctxt)) {
- if (virXPathULong("string(./topology[1]/@dies)", ctxt, &ul) < 0) {
+ if (virXPathUInt("string(./topology[1]/@dies)", ctxt, &def->dies) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Malformed 'dies' attribute in CPU topology"));
goto cleanup;
}
- def->dies = (unsigned int) ul;
} else {
def->dies = 1;
}
- if (virXPathULong("string(./topology[1]/@cores)", ctxt, &ul) < 0) {
+ if (virXPathUInt("string(./topology[1]/@cores)", ctxt, &def->cores) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing 'cores' attribute in CPU topology"));
goto cleanup;
}
- def->cores = (unsigned int) ul;
- if (virXPathULong("string(./topology[1]/@threads)", ctxt, &ul) < 0) {
+ if (virXPathUInt("string(./topology[1]/@threads)", ctxt, &def->threads) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing 'threads' attribute in CPU topology"));
goto cleanup;
}
- def->threads = (unsigned int) ul;
if (!def->sockets || !def->cores || !def->threads || !def->dies) {
virReportError(VIR_ERR_XML_ERROR, "%s",
--
2.26.2
More information about the libvir-list
mailing list