]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainTimerCatchupDef: Change members to 'unsigned long long'
authorPeter Krempa <pkrempa@redhat.com>
Wed, 5 Oct 2022 13:47:49 +0000 (15:47 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 2 Nov 2022 08:20:58 +0000 (09:20 +0100)
The struct used 'unsigned long' variables which we try to avoid due to
being different size on different architectures.

Convert the struct and use virXMLPropULongLong instead of virXPathULong
when parsing the XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h

index cdf05e8fae204fbe3394c43e3f34fce4c2a5a77a..ee9eb6bcc4921565903e21a2f634e7eae85fa4c1 100644 (file)
@@ -10610,33 +10610,17 @@ virDomainTimerDefParseXML(xmlNodePtr node,
 
     catchup = virXPathNode("./catchup", ctxt);
     if (catchup != NULL) {
-        ret = virXPathULong("string(./catchup/@threshold)", ctxt,
-                            &def->catchup.threshold);
-        if (ret == -1) {
-            def->catchup.threshold = 0;
-        } else if (ret < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           "%s", _("invalid catchup threshold"));
+        if (virXMLPropULongLong(catchup, "threshold", 10, VIR_XML_PROP_NONE,
+                                &def->catchup.threshold) < 0)
             goto error;
-        }
 
-        ret = virXPathULong("string(./catchup/@slew)", ctxt, &def->catchup.slew);
-        if (ret == -1) {
-            def->catchup.slew = 0;
-        } else if (ret < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           "%s", _("invalid catchup slew"));
+        if (virXMLPropULongLong(catchup, "slew", 10, VIR_XML_PROP_NONE,
+                                &def->catchup.slew) < 0)
             goto error;
-        }
 
-        ret = virXPathULong("string(./catchup/@limit)", ctxt, &def->catchup.limit);
-        if (ret == -1) {
-            def->catchup.limit = 0;
-        } else if (ret < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           "%s", _("invalid catchup limit"));
+        if (virXMLPropULongLong(catchup, "limit", 10, VIR_XML_PROP_NONE,
+                                &def->catchup.limit) < 0)
             goto error;
-        }
     }
 
     return def;
@@ -24896,11 +24880,11 @@ virDomainTimerDefFormat(virBuffer *buf,
     }
 
     if (def->catchup.threshold > 0)
-        virBufferAsprintf(&catchupAttr, " threshold='%lu'", def->catchup.threshold);
+        virBufferAsprintf(&catchupAttr, " threshold='%llu'", def->catchup.threshold);
     if (def->catchup.slew > 0)
-        virBufferAsprintf(&catchupAttr, " slew='%lu'", def->catchup.slew);
+        virBufferAsprintf(&catchupAttr, " slew='%llu'", def->catchup.slew);
     if (def->catchup.limit > 0)
-        virBufferAsprintf(&catchupAttr, " limit='%lu'", def->catchup.limit);
+        virBufferAsprintf(&catchupAttr, " limit='%llu'", def->catchup.limit);
 
     virXMLFormatElement(&timerChld, "catchup", &catchupAttr, NULL);
     virXMLFormatElement(buf, "timer", &timerAttr, &timerChld);
index 8f8a54bc41f1aaa5ca88e8d740ceeec78e851c56..ba411bfa0241c8ad2ee1bcb6e0c940e0491c7e41 100644 (file)
@@ -2466,9 +2466,9 @@ struct _virDomainThreadSchedParam {
 };
 
 struct _virDomainTimerCatchupDef {
-    unsigned long threshold;
-    unsigned long slew;
-    unsigned long limit;
+    unsigned long long threshold;
+    unsigned long long slew;
+    unsigned long long limit;
 };
 
 struct _virDomainTimerDef {