mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
vircgroup: extract virCgroupV1GetMemSwapUsage
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:
parent
900c58b7f9
commit
87d9fc5b3b
@ -1693,14 +1693,7 @@ virCgroupGetMemSwapHardLimit(virCgroupPtr group, unsigned long long *kb)
|
|||||||
int
|
int
|
||||||
virCgroupGetMemSwapUsage(virCgroupPtr group, unsigned long long *kb)
|
virCgroupGetMemSwapUsage(virCgroupPtr group, unsigned long long *kb)
|
||||||
{
|
{
|
||||||
long long unsigned int usage_in_bytes;
|
VIR_CGROUP_BACKEND_CALL(group, getMemSwapUsage, -1, kb);
|
||||||
int ret;
|
|
||||||
ret = virCgroupGetValueU64(group,
|
|
||||||
VIR_CGROUP_CONTROLLER_MEMORY,
|
|
||||||
"memory.memsw.usage_in_bytes", &usage_in_bytes);
|
|
||||||
if (ret == 0)
|
|
||||||
*kb = usage_in_bytes >> 10;
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -251,6 +251,10 @@ typedef int
|
|||||||
(*virCgroupGetMemSwapHardLimitCB)(virCgroupPtr group,
|
(*virCgroupGetMemSwapHardLimitCB)(virCgroupPtr group,
|
||||||
unsigned long long *kb);
|
unsigned long long *kb);
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(*virCgroupGetMemSwapUsageCB)(virCgroupPtr group,
|
||||||
|
unsigned long long *kb);
|
||||||
|
|
||||||
struct _virCgroupBackend {
|
struct _virCgroupBackend {
|
||||||
virCgroupBackendType type;
|
virCgroupBackendType type;
|
||||||
|
|
||||||
@ -299,6 +303,7 @@ struct _virCgroupBackend {
|
|||||||
virCgroupGetMemorySoftLimitCB getMemorySoftLimit;
|
virCgroupGetMemorySoftLimitCB getMemorySoftLimit;
|
||||||
virCgroupSetMemSwapHardLimitCB setMemSwapHardLimit;
|
virCgroupSetMemSwapHardLimitCB setMemSwapHardLimit;
|
||||||
virCgroupGetMemSwapHardLimitCB getMemSwapHardLimit;
|
virCgroupGetMemSwapHardLimitCB getMemSwapHardLimit;
|
||||||
|
virCgroupGetMemSwapUsageCB getMemSwapUsage;
|
||||||
};
|
};
|
||||||
typedef struct _virCgroupBackend virCgroupBackend;
|
typedef struct _virCgroupBackend virCgroupBackend;
|
||||||
typedef virCgroupBackend *virCgroupBackendPtr;
|
typedef virCgroupBackend *virCgroupBackendPtr;
|
||||||
|
@ -1655,6 +1655,21 @@ virCgroupV1GetMemSwapHardLimit(virCgroupPtr group,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
virCgroupV1GetMemSwapUsage(virCgroupPtr group,
|
||||||
|
unsigned long long *kb)
|
||||||
|
{
|
||||||
|
long long unsigned int usage_in_bytes;
|
||||||
|
int ret;
|
||||||
|
ret = virCgroupGetValueU64(group,
|
||||||
|
VIR_CGROUP_CONTROLLER_MEMORY,
|
||||||
|
"memory.memsw.usage_in_bytes", &usage_in_bytes);
|
||||||
|
if (ret == 0)
|
||||||
|
*kb = usage_in_bytes >> 10;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
virCgroupBackend virCgroupV1Backend = {
|
virCgroupBackend virCgroupV1Backend = {
|
||||||
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
||||||
|
|
||||||
@ -1701,6 +1716,7 @@ virCgroupBackend virCgroupV1Backend = {
|
|||||||
.getMemorySoftLimit = virCgroupV1GetMemorySoftLimit,
|
.getMemorySoftLimit = virCgroupV1GetMemorySoftLimit,
|
||||||
.setMemSwapHardLimit = virCgroupV1SetMemSwapHardLimit,
|
.setMemSwapHardLimit = virCgroupV1SetMemSwapHardLimit,
|
||||||
.getMemSwapHardLimit = virCgroupV1GetMemSwapHardLimit,
|
.getMemSwapHardLimit = virCgroupV1GetMemSwapHardLimit,
|
||||||
|
.getMemSwapUsage = virCgroupV1GetMemSwapUsage,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user