mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
vircgroup: extract virCgroupV1GetMemoryUsage
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
64bfbd7ceb
commit
e92f8bad66
@ -1633,14 +1633,7 @@ virCgroupGetMemoryStat(virCgroupPtr group,
|
||||
int
|
||||
virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb)
|
||||
{
|
||||
long long unsigned int usage_in_bytes;
|
||||
int ret;
|
||||
ret = virCgroupGetValueU64(group,
|
||||
VIR_CGROUP_CONTROLLER_MEMORY,
|
||||
"memory.usage_in_bytes", &usage_in_bytes);
|
||||
if (ret == 0)
|
||||
*kb = (unsigned long) usage_in_bytes >> 10;
|
||||
return ret;
|
||||
VIR_CGROUP_BACKEND_CALL(group, getMemoryUsage, -1, kb);
|
||||
}
|
||||
|
||||
|
||||
|
@ -223,6 +223,10 @@ typedef int
|
||||
unsigned long long *inactiveFile,
|
||||
unsigned long long *unevictable);
|
||||
|
||||
typedef int
|
||||
(*virCgroupGetMemoryUsageCB)(virCgroupPtr group,
|
||||
unsigned long *kb);
|
||||
|
||||
struct _virCgroupBackend {
|
||||
virCgroupBackendType type;
|
||||
|
||||
@ -264,6 +268,7 @@ struct _virCgroupBackend {
|
||||
|
||||
virCgroupSetMemoryCB setMemory;
|
||||
virCgroupGetMemoryStatCB getMemoryStat;
|
||||
virCgroupGetMemoryUsageCB getMemoryUsage;
|
||||
};
|
||||
typedef struct _virCgroupBackend virCgroupBackend;
|
||||
typedef virCgroupBackend *virCgroupBackendPtr;
|
||||
|
@ -1478,6 +1478,21 @@ virCgroupV1GetMemoryStat(virCgroupPtr group,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virCgroupV1GetMemoryUsage(virCgroupPtr group,
|
||||
unsigned long *kb)
|
||||
{
|
||||
long long unsigned int usage_in_bytes;
|
||||
int ret;
|
||||
ret = virCgroupGetValueU64(group,
|
||||
VIR_CGROUP_CONTROLLER_MEMORY,
|
||||
"memory.usage_in_bytes", &usage_in_bytes);
|
||||
if (ret == 0)
|
||||
*kb = (unsigned long) usage_in_bytes >> 10;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
virCgroupBackend virCgroupV1Backend = {
|
||||
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
||||
|
||||
@ -1517,6 +1532,7 @@ virCgroupBackend virCgroupV1Backend = {
|
||||
|
||||
.setMemory = virCgroupV1SetMemory,
|
||||
.getMemoryStat = virCgroupV1GetMemoryStat,
|
||||
.getMemoryUsage = virCgroupV1GetMemoryUsage,
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user