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

vircgroup: extract virCgroupV1GetMemoryUsage

Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 64bfbd7c
......@@ -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,
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册