render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
8c03ec
From 499e3eb6bdca10a5fac9279261e32e64c28273bd Mon Sep 17 00:00:00 2001
8c03ec
Message-Id: <499e3eb6bdca10a5fac9279261e32e64c28273bd@dist-git>
8c03ec
From: Pavel Hrdina <phrdina@redhat.com>
8c03ec
Date: Thu, 4 Mar 2021 12:57:55 +0100
8c03ec
Subject: [PATCH] domain_validate: use defines for cpu period and quota limits
8c03ec
MIME-Version: 1.0
8c03ec
Content-Type: text/plain; charset=UTF-8
8c03ec
Content-Transfer-Encoding: 8bit
8c03ec
8c03ec
Commints <bc760f4d7c4f964fadcb2a73e126b0053e7a9b06> and
8c03ec
<98a09ca48ed4fc011abf2aa290e02ce1b8f1bb5f> fixed the code to use
8c03ec
defines instead of magic numbers but missed this place.
8c03ec
8c03ec
Following commit <ed1ba69f5a8132f8c1e73d2a1f142d70de0b564a> changed
8c03ec
the cpu quota limit to reflect what kernel actually allows so using
8c03ec
the defines fixes XML validations as well.
8c03ec
8c03ec
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8c03ec
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
8c03ec
(cherry picked from commit 22cae2ea4bad7e285ba19d536bd475f8b00841f8)
8c03ec
8c03ec
Conflicts:
8c03ec
    src/conf/domain_validate.c
8c03ec
        - not present in downstream, the code is still part of
8c03ec
          domain_conf.c
8c03ec
8c03ec
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1798463
8c03ec
8c03ec
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8c03ec
Message-Id: <63a44700876e2bd59f276fcd8395abaff011b4c1.1614858616.git.phrdina@redhat.com>
8c03ec
Reviewed-by: Ján Tomko <jtomko@redhat.com>
8c03ec
---
8c03ec
 src/conf/domain_conf.c | 20 +++++++++++++-------
8c03ec
 1 file changed, 13 insertions(+), 7 deletions(-)
8c03ec
8c03ec
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
8c03ec
index 166c3e48d2..9f6cdb0de8 100644
8c03ec
--- a/src/conf/domain_conf.c
8c03ec
+++ b/src/conf/domain_conf.c
8c03ec
@@ -34,6 +34,7 @@
8c03ec
 #include "domain_addr.h"
8c03ec
 #include "domain_conf.h"
8c03ec
 #include "snapshot_conf.h"
8c03ec
+#include "vircgroup.h"
8c03ec
 #include "viralloc.h"
8c03ec
 #include "virxml.h"
8c03ec
 #include "viruuid.h"
8c03ec
@@ -6997,10 +6998,13 @@ virDomainDefLifecycleActionValidate(const virDomainDef *def)
8c03ec
 #define CPUTUNE_VALIDATE_PERIOD(name) \
8c03ec
     do { \
8c03ec
         if (def->cputune.name > 0 && \
8c03ec
-            (def->cputune.name < 1000 || def->cputune.name > 1000000)) { \
8c03ec
+            (def->cputune.name < VIR_CGROUP_CPU_PERIOD_MIN || \
8c03ec
+             def->cputune.name > VIR_CGROUP_CPU_PERIOD_MAX)) { \
8c03ec
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \
8c03ec
-                           _("Value of cputune '%s' must be in range " \
8c03ec
-                           "[1000, 1000000]"), #name); \
8c03ec
+                           _("Value of cputune '%s' must be in range [%llu, %llu]"), \
8c03ec
+                           #name, \
8c03ec
+                           VIR_CGROUP_CPU_PERIOD_MIN, \
8c03ec
+                           VIR_CGROUP_CPU_PERIOD_MAX); \
8c03ec
             return -1; \
8c03ec
         } \
8c03ec
     } while (0)
8c03ec
@@ -7008,11 +7012,13 @@ virDomainDefLifecycleActionValidate(const virDomainDef *def)
8c03ec
 #define CPUTUNE_VALIDATE_QUOTA(name) \
8c03ec
     do { \
8c03ec
         if (def->cputune.name > 0 && \
8c03ec
-            (def->cputune.name < 1000 || \
8c03ec
-            def->cputune.name > 18446744073709551LL)) { \
8c03ec
+            (def->cputune.name < VIR_CGROUP_CPU_QUOTA_MIN || \
8c03ec
+            def->cputune.name > VIR_CGROUP_CPU_QUOTA_MAX)) { \
8c03ec
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \
8c03ec
-                           _("Value of cputune '%s' must be in range " \
8c03ec
-                           "[1000, 18446744073709551]"), #name); \
8c03ec
+                           _("Value of cputune '%s' must be in range [%llu, %llu]"), \
8c03ec
+                           #name, \
8c03ec
+                           VIR_CGROUP_CPU_QUOTA_MIN, \
8c03ec
+                           VIR_CGROUP_CPU_QUOTA_MAX); \
8c03ec
             return -1; \
8c03ec
         } \
8c03ec
     } while (0)
8c03ec
-- 
8c03ec
2.30.0
8c03ec