提交 857aac1f 编写于 作者: P Pavel Hrdina

vircgroup: extract virCgroupV1(Set|Get)CpuShares

Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 fd9a0368
......@@ -2201,18 +2201,14 @@ virCgroupGetDomainTotalCpuStats(virCgroupPtr group,
int
virCgroupSetCpuShares(virCgroupPtr group, unsigned long long shares)
{
return virCgroupSetValueU64(group,
VIR_CGROUP_CONTROLLER_CPU,
"cpu.shares", shares);
VIR_CGROUP_BACKEND_CALL(group, setCpuShares, -1, shares);
}
int
virCgroupGetCpuShares(virCgroupPtr group, unsigned long long *shares)
{
return virCgroupGetValueU64(group,
VIR_CGROUP_CONTROLLER_CPU,
"cpu.shares", shares);
VIR_CGROUP_BACKEND_CALL(group, getCpuShares, -1, shares);
}
......
......@@ -276,6 +276,14 @@ typedef int
typedef int
(*virCgroupDenyAllDevicesCB)(virCgroupPtr group);
typedef int
(*virCgroupSetCpuSharesCB)(virCgroupPtr group,
unsigned long long shares);
typedef int
(*virCgroupGetCpuSharesCB)(virCgroupPtr group,
unsigned long long *shares);
struct _virCgroupBackend {
virCgroupBackendType type;
......@@ -330,6 +338,9 @@ struct _virCgroupBackend {
virCgroupDenyDeviceCB denyDevice;
virCgroupAllowAllDevicesCB allowAllDevices;
virCgroupDenyAllDevicesCB denyAllDevices;
virCgroupSetCpuSharesCB setCpuShares;
virCgroupGetCpuSharesCB getCpuShares;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
......
......@@ -1765,6 +1765,26 @@ virCgroupV1DenyAllDevices(virCgroupPtr group)
}
static int
virCgroupV1SetCpuShares(virCgroupPtr group,
unsigned long long shares)
{
return virCgroupSetValueU64(group,
VIR_CGROUP_CONTROLLER_CPU,
"cpu.shares", shares);
}
static int
virCgroupV1GetCpuShares(virCgroupPtr group,
unsigned long long *shares)
{
return virCgroupGetValueU64(group,
VIR_CGROUP_CONTROLLER_CPU,
"cpu.shares", shares);
}
virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1,
......@@ -1817,6 +1837,9 @@ virCgroupBackend virCgroupV1Backend = {
.denyDevice = virCgroupV1DenyDevice,
.allowAllDevices = virCgroupV1AllowAllDevices,
.denyAllDevices = virCgroupV1DenyAllDevices,
.setCpuShares = virCgroupV1SetCpuShares,
.getCpuShares = virCgroupV1GetCpuShares,
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册