mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-31 05:57:16 +00:00
vircgroupv2: fix cpu.weight limits check
The cgroup v2 cpu.weight limits are different than cgroup v1 cpu.shares limits. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
57ecc37f15
commit
cf3414a85b
@ -235,6 +235,8 @@ int virCgroupGetCpuShares(virCgroup *group, unsigned long long *shares);
|
|||||||
/* Based on kernel code ((1ULL << MAX_BW_BITS) - 1) where MAX_BW_BITS is
|
/* Based on kernel code ((1ULL << MAX_BW_BITS) - 1) where MAX_BW_BITS is
|
||||||
* (64 - BW_SHIFT) and BW_SHIFT is 20 */
|
* (64 - BW_SHIFT) and BW_SHIFT is 20 */
|
||||||
#define VIR_CGROUP_CPU_QUOTA_MAX 17592186044415LL
|
#define VIR_CGROUP_CPU_QUOTA_MAX 17592186044415LL
|
||||||
|
#define VIR_CGROUPV2_WEIGHT_MIN 1LL
|
||||||
|
#define VIR_CGROUPV2_WEIGHT_MAX 10000LL
|
||||||
|
|
||||||
int virCgroupSetCpuCfsPeriod(virCgroup *group, unsigned long long cfs_period);
|
int virCgroupSetCpuCfsPeriod(virCgroup *group, unsigned long long cfs_period);
|
||||||
int virCgroupGetCpuCfsPeriod(virCgroup *group, unsigned long long *cfs_period);
|
int virCgroupGetCpuCfsPeriod(virCgroup *group, unsigned long long *cfs_period);
|
||||||
|
@ -1499,13 +1499,13 @@ static int
|
|||||||
virCgroupV2SetCpuShares(virCgroup *group,
|
virCgroupV2SetCpuShares(virCgroup *group,
|
||||||
unsigned long long shares)
|
unsigned long long shares)
|
||||||
{
|
{
|
||||||
if (shares < VIR_CGROUP_CPU_SHARES_MIN ||
|
if (shares < VIR_CGROUPV2_WEIGHT_MIN ||
|
||||||
shares > VIR_CGROUP_CPU_SHARES_MAX) {
|
shares > VIR_CGROUPV2_WEIGHT_MAX) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("shares '%llu' must be in range [%llu, %llu]"),
|
_("shares '%llu' must be in range [%llu, %llu]"),
|
||||||
shares,
|
shares,
|
||||||
VIR_CGROUP_CPU_SHARES_MIN,
|
VIR_CGROUPV2_WEIGHT_MIN,
|
||||||
VIR_CGROUP_CPU_SHARES_MAX);
|
VIR_CGROUPV2_WEIGHT_MAX);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user