79b470
From 92b7a56b1a23d1cf39e810a58a6d7d0b1f500e69 Mon Sep 17 00:00:00 2001
79b470
Message-Id: <92b7a56b1a23d1cf39e810a58a6d7d0b1f500e69@dist-git>
79b470
From: Pavel Hrdina <phrdina@redhat.com>
79b470
Date: Thu, 21 Jan 2021 10:24:06 -0300
79b470
Subject: [PATCH] vircgroup: fix cpu quota maximum limit
79b470
79b470
Kernel commit <d505b8af58912ae1e1a211fabc9995b19bd40828> added proper
79b470
check for cpu quota maximum limit to prevent internal overflow.
79b470
79b470
Even though this change is not present in all kernels it makes sense
79b470
to enforce the same limit in libvirt.
79b470
79b470
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1750315
79b470
79b470
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
79b470
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
79b470
(cherry picked from commit ed1ba69f5a8132f8c1e73d2a1f142d70de0b564a)
79b470
79b470
https://bugzilla.redhat.com/1915733
79b470
79b470
Signed-off-by: Daniel Henrique Barboza <dbarboza@redhat.com>
79b470
Message-Id: <20210121132406.337681-5-dbarboza@redhat.com>
79b470
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
79b470
---
79b470
 src/util/vircgroup.h | 4 +++-
79b470
 1 file changed, 3 insertions(+), 1 deletion(-)
79b470
79b470
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
79b470
index 83fa74840f..1c6edea0be 100644
79b470
--- a/src/util/vircgroup.h
79b470
+++ b/src/util/vircgroup.h
79b470
@@ -246,7 +246,9 @@ int virCgroupGetCpuShares(virCgroupPtr group, unsigned long long *shares);
79b470
 #define VIR_CGROUP_CPU_PERIOD_MIN 1000LL
79b470
 #define VIR_CGROUP_CPU_PERIOD_MAX 1000000LL
79b470
 #define VIR_CGROUP_CPU_QUOTA_MIN 1000LL
79b470
-#define VIR_CGROUP_CPU_QUOTA_MAX 18446744073709551LL
79b470
+/* Based on kernel code ((1ULL << MAX_BW_BITS) - 1) where MAX_BW_BITS is
79b470
+ * (64 - BW_SHIFT) and BW_SHIFT is 20 */
79b470
+#define VIR_CGROUP_CPU_QUOTA_MAX 17592186044415LL
79b470
 
79b470
 int virCgroupSetCpuCfsPeriod(virCgroupPtr group, unsigned long long cfs_period);
79b470
 int virCgroupGetCpuCfsPeriod(virCgroupPtr group, unsigned long long *cfs_period);
79b470
-- 
79b470
2.30.0
79b470