[PATCH v6 4/6] add interface virCgroupGetAppRoot

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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 5dda1ec..0a07c25 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -84,6 +84,7 @@ virCgroupDenyDeviceMajor;
 virCgroupDenyDevicePath;
 virCgroupForDomain;
 virCgroupForDriver;
+virCgroupGetAppRoot;
 virCgroupForEmulator;
 virCgroupForVcpu;
 virCgroupFree;
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index 4aae70d..9777ad5 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 0c11eb1..e26f65f 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]