Commit e7aa295e by dlezcano

Setup the control group

From: Daniel Lezcano <dlezcano@fr.ibm.com> Setup the control group when executing the container. Remove the dead code. Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent b7c9b199
...@@ -96,50 +96,6 @@ int lxc_unlink_nsgroup(const char *name) ...@@ -96,50 +96,6 @@ int lxc_unlink_nsgroup(const char *name)
return unlink(nsgroup); return unlink(nsgroup);
} }
int lxc_cgroup_copy(const char *name, const char *subsystem)
{
char destination[MAXPATHLEN];
char source[MAXPATHLEN];
char buffer[1024];
int nbbytes, fd_source, fd_destination, ret = -1;
snprintf(source, MAXPATHLEN, LXCPATH "/%s/cgroup/%s", name, subsystem);
if (access(source, F_OK))
return 0;
fd_source = open(source, O_RDONLY);
if (fd_source < 0) {
lxc_log_syserror("failed to open '%s'", source);
return -1;
}
snprintf(destination, MAXPATHLEN, LXCPATH "/%s/nsgroup/%s", name, subsystem);
fd_destination = open(destination, O_WRONLY);
if (fd_destination < 0) {
lxc_log_syserror("failed to open '%s'", destination);
goto out;
}
nbbytes = read(fd_source, buffer, sizeof(buffer));
if (nbbytes < 0) {
lxc_log_syserror("failed to read '%s'", source);
goto out;
}
if (write(fd_destination, buffer, nbbytes) < 0) {
lxc_log_syserror("failed to write to '%s'", destination);
goto out;
}
ret = 0;
out:
close(fd_source);
close(fd_destination);
return ret;
}
int lxc_cgroup_set(const char *name, const char *subsystem, const char *value) int lxc_cgroup_set(const char *name, const char *subsystem, const char *value)
{ {
int fd, ret = -1;; int fd, ret = -1;;
......
...@@ -28,6 +28,5 @@ ...@@ -28,6 +28,5 @@
int lxc_get_cgroup_mount(const char *mtab, char *mnt); int lxc_get_cgroup_mount(const char *mtab, char *mnt);
int lxc_link_nsgroup(const char *name, pid_t pid); int lxc_link_nsgroup(const char *name, pid_t pid);
int lxc_unlink_nsgroup(const char *name); int lxc_unlink_nsgroup(const char *name);
int lxc_cgroup_copy(const char *name, const char *subsystem);
#endif #endif
...@@ -666,6 +666,8 @@ static int setup_rootfs(const char *name) ...@@ -666,6 +666,8 @@ static int setup_rootfs(const char *name)
static int setup_cgroup_cb(void* buffer, void *data) static int setup_cgroup_cb(void* buffer, void *data)
{ {
char *key = buffer, *value; char *key = buffer, *value;
char *name = data;
int ret;
value = strchr(key, '='); value = strchr(key, '=');
if (!value) if (!value)
...@@ -674,10 +676,11 @@ static int setup_cgroup_cb(void* buffer, void *data) ...@@ -674,10 +676,11 @@ static int setup_cgroup_cb(void* buffer, void *data)
*value = '\0'; *value = '\0';
value += 1; value += 1;
printf("key: %s\n", key); ret = lxc_cgroup_set(name, key, value);
printf("value: %s\n", value); if (ret)
lxc_log_syserror("failed to set cgroup '%s' = '%s' for '%s'",
return 0; key, value, name);
return ret;
} }
static int setup_convert_cgroup_cb(const char *name, const char *directory, static int setup_convert_cgroup_cb(const char *name, const char *directory,
...@@ -749,7 +752,7 @@ static int setup_cgroup(const char *name) ...@@ -749,7 +752,7 @@ static int setup_cgroup(const char *name)
} }
return file_for_each_line(filename, setup_cgroup_cb, return file_for_each_line(filename, setup_cgroup_cb,
line, MAXPATHLEN, filename); line, MAXPATHLEN, (void *)name);
} }
static int setup_mount(const char *name) static int setup_mount(const char *name)
......
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