Commit 36b86299 by Daniel Lezcano Committed by Daniel Lezcano

encapsulate the ns_cgroup

Create a single API to create a cgroup which will switch to the old ns_cgroup automatically. Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent b234e44f
...@@ -142,6 +142,16 @@ int lxc_unlink_nsgroup(const char *name) ...@@ -142,6 +142,16 @@ int lxc_unlink_nsgroup(const char *name)
return ret; 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) int lxc_cgroup_path_get(char **path, const char *name)
{ {
char cgroup[MAXPATHLEN]; char cgroup[MAXPATHLEN];
......
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
#define MAXPRIOLEN 24 #define MAXPRIOLEN 24
struct lxc_handler; struct lxc_handler;
int lxc_rename_nsgroup(const char *name, pid_t pid); int lxc_cgroup_create(const char *name, pid_t pid);
int lxc_unlink_nsgroup(const char *name); int lxc_cgroup_destroy(const char *name);
int lxc_cgroup_path_get(char **path, const char *name); int lxc_cgroup_path_get(char **path, const char *name);
int lxc_cgroup_nrtasks(const char *name); int lxc_cgroup_nrtasks(const char *name);
#endif #endif
...@@ -214,7 +214,7 @@ int main(int argc, char *argv[]) ...@@ -214,7 +214,7 @@ int main(int argc, char *argv[])
ERROR("pid_name: failed to allocate memory"); ERROR("pid_name: failed to allocate memory");
return -1; return -1;
} }
lxc_unlink_nsgroup(pid_name); lxc_cgroup_destroy(pid_name);
free(pid_name); free(pid_name);
return lxc_error_set_and_log(pid, status); return lxc_error_set_and_log(pid, status);
......
...@@ -506,7 +506,7 @@ int lxc_spawn(struct lxc_handler *handler) ...@@ -506,7 +506,7 @@ int lxc_spawn(struct lxc_handler *handler)
if (lxc_sync_wait_child(handler, LXC_SYNC_CONFIGURE)) if (lxc_sync_wait_child(handler, LXC_SYNC_CONFIGURE))
failed_before_rename = 1; failed_before_rename = 1;
if (lxc_rename_nsgroup(name, handler->pid)) if (lxc_cgroup_create(name, handler->pid))
goto out_delete_net; goto out_delete_net;
if (failed_before_rename) if (failed_before_rename)
...@@ -585,7 +585,7 @@ int __lxc_start(const char *name, struct lxc_conf *conf, ...@@ -585,7 +585,7 @@ int __lxc_start(const char *name, struct lxc_conf *conf,
out_fini: out_fini:
LXC_TTY_DEL_HANDLER(SIGQUIT); LXC_TTY_DEL_HANDLER(SIGQUIT);
LXC_TTY_DEL_HANDLER(SIGINT); LXC_TTY_DEL_HANDLER(SIGINT);
lxc_unlink_nsgroup(name); lxc_cgroup_destroy(name);
lxc_fini(name, handler); lxc_fini(name, handler);
return err; return err;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment