]> git.proxmox.com Git - mirror_lxc.git/commitdiff
Setup the control group
authordlezcano <dlezcano>
Mon, 17 Nov 2008 13:55:01 +0000 (13:55 +0000)
committerdlezcano <dlezcano>
Mon, 17 Nov 2008 13:55:01 +0000 (13:55 +0000)
From: Daniel Lezcano <dlezcano@fr.ibm.com>

Setup the control group when executing the container.
Remove the dead code.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/cgroup.c
src/lxc/cgroup.h
src/lxc/lxc_conf.c

index ddd74b9ae2ddc5e7c39141d1ed24715434e5b832..fc0a22200a80c933df50c8f5519fe1d7b021ae73 100644 (file)
@@ -96,50 +96,6 @@ int lxc_unlink_nsgroup(const char *name)
        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 fd, ret = -1;;
index 2aeb37b970c843b805bc931a52934fbfafd9cfb3..36029a2aad0312c8e2bd797999b45dfcb0089ca3 100644 (file)
@@ -28,6 +28,5 @@
 int lxc_get_cgroup_mount(const char *mtab, char *mnt);
 int lxc_link_nsgroup(const char *name, pid_t pid);
 int lxc_unlink_nsgroup(const char *name);
-int lxc_cgroup_copy(const char *name, const char *subsystem);
 
 #endif
index 523dc7b629accd95f37b5afa0698c567f21d8d34..1955623524ddc80e721e0f1c803feeaabed5c8b5 100644 (file)
@@ -666,6 +666,8 @@ static int setup_rootfs(const char *name)
 static int setup_cgroup_cb(void* buffer, void *data)
 {
        char *key = buffer, *value;
+       char *name = data;
+       int ret;
 
        value = strchr(key, '=');
        if (!value)
@@ -674,10 +676,11 @@ static int setup_cgroup_cb(void* buffer, void *data)
        *value = '\0';
        value += 1;
 
-       printf("key: %s\n", key);
-       printf("value: %s\n", value);
-
-       return 0;
+       ret = lxc_cgroup_set(name, key, value);
+       if (ret)
+               lxc_log_syserror("failed to set cgroup '%s' = '%s' for '%s'",
+                                key, value, name);
+       return ret;
 }
 
 static int setup_convert_cgroup_cb(const char *name, const char *directory, 
@@ -749,7 +752,7 @@ static int setup_cgroup(const char *name)
        }
        
        return file_for_each_line(filename, setup_cgroup_cb, 
-                                 line, MAXPATHLEN, filename);
+                                 line, MAXPATHLEN, (void *)name);
 }
 
 static int setup_mount(const char *name)