vircgroup: extract virCgroupV1(Set|Get)CpuShares

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2018-09-05 20:11:38 +02:00
parent fd9a0368b9
commit 857aac1f55
3 changed files with 36 additions and 6 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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,
};