render / rpms / libvirt

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