提交 c840448e 编写于 作者: P Pavel Hrdina

vircgroup: extract virCgroupV1(Set|Get)CpuCfsPeriod

Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 857aac1f
......@@ -2223,19 +2223,7 @@ virCgroupGetCpuShares(virCgroupPtr group, unsigned long long *shares)
int
virCgroupSetCpuCfsPeriod(virCgroupPtr group, unsigned long long cfs_period)
{
/* The cfs_period should be greater or equal than 1ms, and less or equal
* than 1s.
*/
if (cfs_period < 1000 || cfs_period > 1000000) {
virReportError(VIR_ERR_INVALID_ARG,
_("cfs_period '%llu' must be in range (1000, 1000000)"),
cfs_period);
return -1;
}
return virCgroupSetValueU64(group,
VIR_CGROUP_CONTROLLER_CPU,
"cpu.cfs_period_us", cfs_period);
VIR_CGROUP_BACKEND_CALL(group, setCpuCfsPeriod, -1, cfs_period);
}
......@@ -2250,9 +2238,7 @@ virCgroupSetCpuCfsPeriod(virCgroupPtr group, unsigned long long cfs_period)
int
virCgroupGetCpuCfsPeriod(virCgroupPtr group, unsigned long long *cfs_period)
{
return virCgroupGetValueU64(group,
VIR_CGROUP_CONTROLLER_CPU,
"cpu.cfs_period_us", cfs_period);
VIR_CGROUP_BACKEND_CALL(group, getCpuCfsPeriod, -1, cfs_period);
}
......
......@@ -284,6 +284,14 @@ typedef int
(*virCgroupGetCpuSharesCB)(virCgroupPtr group,
unsigned long long *shares);
typedef int
(*virCgroupSetCpuCfsPeriodCB)(virCgroupPtr group,
unsigned long long cfs_period);
typedef int
(*virCgroupGetCpuCfsPeriodCB)(virCgroupPtr group,
unsigned long long *cfs_period);
struct _virCgroupBackend {
virCgroupBackendType type;
......@@ -341,6 +349,8 @@ struct _virCgroupBackend {
virCgroupSetCpuSharesCB setCpuShares;
virCgroupGetCpuSharesCB getCpuShares;
virCgroupSetCpuCfsPeriodCB setCpuCfsPeriod;
virCgroupGetCpuCfsPeriodCB getCpuCfsPeriod;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
......
......@@ -1785,6 +1785,36 @@ virCgroupV1GetCpuShares(virCgroupPtr group,
}
static int
virCgroupV1SetCpuCfsPeriod(virCgroupPtr group,
unsigned long long cfs_period)
{
/* The cfs_period should be greater or equal than 1ms, and less or equal
* than 1s.
*/
if (cfs_period < 1000 || cfs_period > 1000000) {
virReportError(VIR_ERR_INVALID_ARG,
_("cfs_period '%llu' must be in range (1000, 1000000)"),
cfs_period);
return -1;
}
return virCgroupSetValueU64(group,
VIR_CGROUP_CONTROLLER_CPU,
"cpu.cfs_period_us", cfs_period);
}
static int
virCgroupV1GetCpuCfsPeriod(virCgroupPtr group,
unsigned long long *cfs_period)
{
return virCgroupGetValueU64(group,
VIR_CGROUP_CONTROLLER_CPU,
"cpu.cfs_period_us", cfs_period);
}
virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1,
......@@ -1840,6 +1870,8 @@ virCgroupBackend virCgroupV1Backend = {
.setCpuShares = virCgroupV1SetCpuShares,
.getCpuShares = virCgroupV1GetCpuShares,
.setCpuCfsPeriod = virCgroupV1SetCpuCfsPeriod,
.getCpuCfsPeriod = virCgroupV1GetCpuCfsPeriod,
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册