render / rpms / libvirt

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