[RFC] [PATCH v2 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        |   18 ++++++++++++++++++
 src/util/cgroup.h        |    2 ++
 3 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9cbdbb4..53c35da 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -71,6 +71,7 @@ virCgroupDenyDeviceMajor;
 virCgroupDenyDevicePath;
 virCgroupForDomain;
 virCgroupForDriver;
+virCgroupGetAppRoot;
 virCgroupForVcpu;
 virCgroupFree;
 virCgroupGetBlkioWeight;
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index d6fcd61..ee88aaf 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -846,6 +846,24 @@ int virCgroupForDriver(const char *name ATTRIBUTE_UNUSED,
 
 
 /**
+ * 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:
  *
  * @driver: group for driver owning the domain
diff --git a/src/util/cgroup.h b/src/util/cgroup.h
index caca362..f0e11fe 100644
--- a/src/util/cgroup.h
+++ b/src/util/cgroup.h
@@ -37,6 +37,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]