]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: qemuDomainObjPrivateXMLParseVcpu refactor
authorKirill Shchetiniuk <kshcheti@redhat.com>
Tue, 22 Jul 2025 15:12:05 +0000 (17:12 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 23 Jul 2025 10:22:02 +0000 (12:22 +0200)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_domain.c

index 54eda9e12fd47c5469123d7e72816ca3e274645e..d580c3165370c124fd33e3568a2456e6a0034a56 100644 (file)
@@ -2812,28 +2812,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_NONE, &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;