Monday, 10 September
2012
Mon, 10 Sep
'12
9:54 p.m.
because libvirt_lxc's cgroup mountpoint is what it shown
in /proc/self/cgroup.
we can get container's cgroup through virCgroupNew("/", &group),
add interface virCgroupGetAppRoot to help container to
get it's cgroup.
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
src/libvirt_private.syms | 1 +
src/util/cgroup.c | 15 +++++++++++++++
src/util/cgroup.h | 2 ++
3 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 666bec2..33375df 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -72,6 +72,7 @@ virCgroupDenyDeviceMajor;
virCgroupDenyDevicePath;
virCgroupForDomain;
virCgroupForDriver;
+virCgroupGetAppRoot;
virCgroupForEmulator;
virCgroupForVcpu;
virCgroupFree;
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index b702f53..d2c6120 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -965,6 +965,21 @@ int virCgroupForDriver(const char *name ATTRIBUTE_UNUSED,
}
#endif
+/**
+* virCgroupGetAppRoot:
+*
+* @group: Pointer to returned virCgroupPtr
+*
+* Returns 0 on success
+*/
+int virCgroupGetAppRoot(virCgroupPtr *group)
+{
+#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
+ return virCgroupNew("/", group);
+#else
+ return -ENXIO;
+#endif
+}
/**
* virCgroupForDomain:
diff --git a/src/util/cgroup.h b/src/util/cgroup.h
index 3d7ddbb..9f28a5a 100644
--- a/src/util/cgroup.h
+++ b/src/util/cgroup.h
@@ -47,6 +47,8 @@ int virCgroupForDriver(const char *name,
int privileged,
int create);
+int virCgroupGetAppRoot(virCgroupPtr *group);
+
int virCgroupForDomain(virCgroupPtr driver,
const char *name,
virCgroupPtr *group,
--
1.7.7.6