mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
LXC implement memory control APIs
The patch implements the missing memory control APIs for lxc, i.e., domainGetMaxMemory, domainSetMaxMemory, domainSetMemory, and improves domainGetInfo to return proper amount of used memory via cgroup. * src/libvirt_private.syms: Export virCgroupGetMemoryUsage and add missing virCgroupSetMemory * src/lxc/lxc_driver.c: Implement missing memory functions * src/util/cgroup.c, src/util/cgroup.h: Add the function to get used memory
This commit is contained in:
committed by
Daniel Veillard
parent
709c37e932
commit
3a05dc09ec
@@ -701,6 +701,26 @@ int virCgroupSetMemory(virCgroupPtr group, unsigned long kb)
|
||||
kb << 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* virCgroupGetMemoryUsage:
|
||||
*
|
||||
* @group: The cgroup to change memory for
|
||||
* @kb: Pointer to returned used memory in kilobytes
|
||||
*
|
||||
* Returns: 0 on success
|
||||
*/
|
||||
int virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb)
|
||||
{
|
||||
uint64_t 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* virCgroupDenyAllDevices:
|
||||
*
|
||||
|
||||
@@ -41,6 +41,7 @@ int virCgroupForDomain(virCgroupPtr driver,
|
||||
int virCgroupAddTask(virCgroupPtr group, pid_t pid);
|
||||
|
||||
int virCgroupSetMemory(virCgroupPtr group, unsigned long kb);
|
||||
int virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb);
|
||||
|
||||
int virCgroupDenyAllDevices(virCgroupPtr group);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user