From: Kirill Shchetiniuk <kshcheti(a)redhat.com>
Refactored the qemuDomainObjPrivateXMLParseVcpu function to use the
appropriate virXMLPropUInt function to parse unsigned integers,
avoiding unccessery string parsing operations.
Signed-off-by: Kirill Shchetiniuk <kshcheti(a)redhat.com>
---
src/qemu/qemu_domain.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 2d62bcc62b..2b505fbddb 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2811,28 +2811,18 @@ qemuDomainObjPrivateXMLParseVcpu(xmlNodePtr node,
virDomainDef *def)
{
virDomainVcpuDef *vcpu;
- g_autofree char *idstr = NULL;
- g_autofree char *pidstr = NULL;
unsigned int tmp;
- idstr = virXMLPropString(node, "id");
-
- if (idstr &&
- (virStrToLong_uip(idstr, NULL, 10, &idx) < 0)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot parse vcpu index '%1$s'"), idstr);
+ if (virXMLPropUInt(node, "id", 10, VIR_XML_PROP_REQUIRED, &idx) <
0)
return -1;
- }
+
if (!(vcpu = virDomainDefGetVcpu(def, idx))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid vcpu index '%1$u'"), idx);
return -1;
}
- if (!(pidstr = virXMLPropString(node, "pid")))
- return -1;
-
- if (virStrToLong_uip(pidstr, NULL, 10, &tmp) < 0)
+ if (virXMLPropUInt(node, "pid", 10, VIR_XML_PROP_REQUIRED, &tmp) <
0)
return -1;
QEMU_DOMAIN_VCPU_PRIVATE(vcpu)->tid = tmp;
--
2.49.0