mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
vircgroupv2: use defines for cpu period and quota limits
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
bc760f4d7c
commit
98a09ca48e
@ -1482,12 +1482,12 @@ virCgroupV2SetCpuCfsPeriod(virCgroupPtr group,
|
|||||||
g_autofree char *str = NULL;
|
g_autofree char *str = NULL;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
/* The cfs_period should be greater or equal than 1ms, and less or equal
|
if (cfs_period < VIR_CGROUP_CPU_PERIOD_MIN ||
|
||||||
* than 1s.
|
cfs_period > VIR_CGROUP_CPU_PERIOD_MAX) {
|
||||||
*/
|
|
||||||
if (cfs_period < 1000 || cfs_period > 1000000) {
|
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("cfs_period '%llu' must be in range (1000, 1000000)"),
|
_("cfs_period '%llu' must be in range (%llu, %llu)"),
|
||||||
|
VIR_CGROUP_CPU_PERIOD_MIN,
|
||||||
|
VIR_CGROUP_CPU_PERIOD_MAX,
|
||||||
cfs_period);
|
cfs_period);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1543,17 +1543,18 @@ static int
|
|||||||
virCgroupV2SetCpuCfsQuota(virCgroupPtr group,
|
virCgroupV2SetCpuCfsQuota(virCgroupPtr group,
|
||||||
long long cfs_quota)
|
long long cfs_quota)
|
||||||
{
|
{
|
||||||
/* The cfs_quota should be greater or equal than 1ms */
|
|
||||||
if (cfs_quota >= 0 &&
|
if (cfs_quota >= 0 &&
|
||||||
(cfs_quota < 1000 ||
|
(cfs_quota < VIR_CGROUP_CPU_QUOTA_MIN ||
|
||||||
cfs_quota > ULLONG_MAX / 1000)) {
|
cfs_quota > VIR_CGROUP_CPU_QUOTA_MAX)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("cfs_quota '%lld' must be in range (1000, %llu)"),
|
_("cfs_quota '%lld' must be in range (%llu, %llu)"),
|
||||||
cfs_quota, ULLONG_MAX / 1000);
|
cfs_quota,
|
||||||
|
VIR_CGROUP_CPU_QUOTA_MIN,
|
||||||
|
VIR_CGROUP_CPU_QUOTA_MAX);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfs_quota == ULLONG_MAX / 1000) {
|
if (cfs_quota == VIR_CGROUP_CPU_QUOTA_MAX) {
|
||||||
return virCgroupSetValueStr(group,
|
return virCgroupSetValueStr(group,
|
||||||
VIR_CGROUP_CONTROLLER_CPU,
|
VIR_CGROUP_CONTROLLER_CPU,
|
||||||
"cpu.max", "max");
|
"cpu.max", "max");
|
||||||
@ -1578,7 +1579,7 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (STREQLEN(str, "max", 3)) {
|
if (STREQLEN(str, "max", 3)) {
|
||||||
*cfs_quota = ULLONG_MAX / 1000;
|
*cfs_quota = VIR_CGROUP_CPU_QUOTA_MAX;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user