Create a single API to create a cgroup which will switch to the old
ns_cgroup automatically.

Signed-off-by: Daniel Lezcano <daniel.lezc...@free.fr>
---
 src/lxc/cgroup.c      |   10 ++++++++++
 src/lxc/cgroup.h      |    4 ++--
 src/lxc/lxc_unshare.c |    2 +-
 src/lxc/start.c       |    4 ++--
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c
index 350d439..4b54906 100644
--- a/src/lxc/cgroup.c
+++ b/src/lxc/cgroup.c
@@ -142,6 +142,16 @@ int lxc_unlink_nsgroup(const char *name)
        return ret;
 }
 
+int lxc_cgroup_create(const char *name, pid_t pid)
+{
+       return lxc_rename_nsgroup(name, pid);
+}
+
+int lxc_cgroup_destroy(const char *name)
+{
+       return lxc_unlink_nsgroup(name);
+}
+
 int lxc_cgroup_path_get(char **path, const char *name)
 {
        char cgroup[MAXPATHLEN];
diff --git a/src/lxc/cgroup.h b/src/lxc/cgroup.h
index 905686e..8607fa8 100644
--- a/src/lxc/cgroup.h
+++ b/src/lxc/cgroup.h
@@ -26,8 +26,8 @@
 #define MAXPRIOLEN 24
 
 struct lxc_handler;
-int lxc_rename_nsgroup(const char *name, pid_t pid);
-int lxc_unlink_nsgroup(const char *name);
+int lxc_cgroup_create(const char *name, pid_t pid);
+int lxc_cgroup_destroy(const char *name);
 int lxc_cgroup_path_get(char **path, const char *name);
 int lxc_cgroup_nrtasks(const char *name);
 #endif
diff --git a/src/lxc/lxc_unshare.c b/src/lxc/lxc_unshare.c
index 62349eb..a82490e 100644
--- a/src/lxc/lxc_unshare.c
+++ b/src/lxc/lxc_unshare.c
@@ -214,7 +214,7 @@ int main(int argc, char *argv[])
                ERROR("pid_name: failed to allocate memory");
                return -1;
        }
-       lxc_unlink_nsgroup(pid_name);
+       lxc_cgroup_destroy(pid_name);
        free(pid_name);
 
        return  lxc_error_set_and_log(pid, status);
diff --git a/src/lxc/start.c b/src/lxc/start.c
index 7e17cc5..b8ceff6 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -506,7 +506,7 @@ int lxc_spawn(struct lxc_handler *handler)
        if (lxc_sync_wait_child(handler, LXC_SYNC_CONFIGURE))
                failed_before_rename = 1;
 
-       if (lxc_rename_nsgroup(name, handler->pid))
+       if (lxc_cgroup_create(name, handler->pid))
                goto out_delete_net;
 
        if (failed_before_rename)
@@ -585,7 +585,7 @@ int __lxc_start(const char *name, struct lxc_conf *conf,
 out_fini:
        LXC_TTY_DEL_HANDLER(SIGQUIT);
        LXC_TTY_DEL_HANDLER(SIGINT);
-       lxc_unlink_nsgroup(name);
+       lxc_cgroup_destroy(name);
        lxc_fini(name, handler);
        return err;
 
-- 
1.7.0.4


------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel

Reply via email to