From 499e3eb6bdca10a5fac9279261e32e64c28273bd Mon Sep 17 00:00:00 2001 Message-Id: <499e3eb6bdca10a5fac9279261e32e64c28273bd@dist-git> From: Pavel Hrdina Date: Thu, 4 Mar 2021 12:57:55 +0100 Subject: [PATCH] domain_validate: use defines for cpu period and quota limits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit 22cae2ea4bad7e285ba19d536bd475f8b00841f8) Conflicts: src/conf/domain_validate.c - not present in downstream, the code is still part of domain_conf.c Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1798463 Signed-off-by: Pavel Hrdina Message-Id: <63a44700876e2bd59f276fcd8395abaff011b4c1.1614858616.git.phrdina@redhat.com> Reviewed-by: Ján Tomko --- src/conf/domain_conf.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 166c3e48d2..9f6cdb0de8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -34,6 +34,7 @@ #include "domain_addr.h" #include "domain_conf.h" #include "snapshot_conf.h" +#include "vircgroup.h" #include "viralloc.h" #include "virxml.h" #include "viruuid.h" @@ -6997,10 +6998,13 @@ virDomainDefLifecycleActionValidate(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) @@ -7008,11 +7012,13 @@ virDomainDefLifecycleActionValidate(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) -- 2.30.0