]> xenbits.xensource.com Git - libvirt.git/commitdiff
domain_validate: use defines for cpu period and quota limits
authorPavel Hrdina <phrdina@redhat.com>
Fri, 19 Feb 2021 18:41:59 +0000 (19:41 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 22 Feb 2021 13:03:04 +0000 (14:03 +0100)
Commints <bc760f4d7c4f964fadcb2a73e126b0053e7a9b06> and
<98a09ca48ed4fc011abf2aa290e02ce1b8f1bb5f> fixed the code to use
defines instead of magic numbers but missed this place.

Following commit <ed1ba69f5a8132f8c1e73d2a1f142d70de0b564a> changed
the cpu quota limit to reflect what kernel actually allows so using
the defines fixes XML validations as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_validate.c

index b47ecba86b41ba087a70bf0717701ca7e4196017..b4e09e21feb8b05505781899bc50472fee860655 100644 (file)
@@ -23,6 +23,7 @@
 #include "domain_validate.h"
 #include "domain_conf.h"
 #include "snapshot_conf.h"
+#include "vircgroup.h"
 #include "virconftypes.h"
 #include "virlog.h"
 #include "virutil.h"
@@ -1200,10 +1201,13 @@ virDomainDefOSValidate(const virDomainDef *def,
 #define CPUTUNE_VALIDATE_PERIOD(name) \
     do { \
         if (def->cputune.name > 0 && \
-            (def->cputune.name < 1000 || def->cputune.name > 1000000)) { \
+            (def->cputune.name < VIR_CGROUP_CPU_PERIOD_MIN || \
+             def->cputune.name > VIR_CGROUP_CPU_PERIOD_MAX)) { \
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \
-                           _("Value of cputune '%s' must be in range " \
-                           "[1000, 1000000]"), #name); \
+                           _("Value of cputune '%s' must be in range [%llu, %llu]"), \
+                           #name, \
+                           VIR_CGROUP_CPU_PERIOD_MIN, \
+                           VIR_CGROUP_CPU_PERIOD_MAX); \
             return -1; \
         } \
     } while (0)
@@ -1211,11 +1215,13 @@ virDomainDefOSValidate(const virDomainDef *def,
 #define CPUTUNE_VALIDATE_QUOTA(name) \
     do { \
         if (def->cputune.name > 0 && \
-            (def->cputune.name < 1000 || \
-            def->cputune.name > 18446744073709551LL)) { \
+            (def->cputune.name < VIR_CGROUP_CPU_QUOTA_MIN || \
+             def->cputune.name > VIR_CGROUP_CPU_QUOTA_MAX)) { \
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \
-                           _("Value of cputune '%s' must be in range " \
-                           "[1000, 18446744073709551]"), #name); \
+                           _("Value of cputune '%s' must be in range [%llu, %llu]"), \
+                           #name, \
+                           VIR_CGROUP_CPU_QUOTA_MIN, \
+                           VIR_CGROUP_CPU_QUOTA_MAX); \
             return -1; \
         } \
     } while (0)