From: Pavel Hrdina Date: Fri, 19 Feb 2021 18:41:59 +0000 (+0100) Subject: domain_validate: use defines for cpu period and quota limits X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=22cae2ea4bad7e285ba19d536bd475f8b00841f8;p=libvirt.git domain_validate: use defines for cpu period and quota limits Commints and <98a09ca48ed4fc011abf2aa290e02ce1b8f1bb5f> fixed the code to use defines instead of magic numbers but missed this place. Following commit 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 Reviewed-by: Michal Privoznik --- diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index b47ecba86b..b4e09e21fe 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -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)