chiark / gitweb /
logind: remove redundant entries from logind's default controller lists too
authorLennart Poettering <lennart@poettering.net>
Mon, 16 Apr 2012 17:14:11 +0000 (19:14 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 16 Apr 2012 17:15:00 +0000 (19:15 +0200)
TODO
src/core/cgroup.c
src/core/cgroup.h
src/core/manager.c
src/login/logind.c
src/shared/cgroup-util.c
src/shared/cgroup-util.h

diff --git a/TODO b/TODO
index dd38fc8dee98251af6cb0b78233572eb11012a58..292ee21708c5d759d7d3c6fc7a45adb36e7c89e2 100644 (file)
--- a/TODO
+++ b/TODO
@@ -17,8 +17,6 @@ Features:
 
 * suspend/hibernate/hybrid support, auto-suspend logic with idle hint
 
 
 * suspend/hibernate/hybrid support, auto-suspend logic with idle hint
 
-* filter default cgroups in logind too
-
 * udev: remove /sys and /dev configurability
 
 * udev: find a way to tell udev to not cancel firmware requests when running in initramfs
 * udev: remove /sys and /dev configurability
 
 * udev: find a way to tell udev to not cancel firmware requests when running in initramfs
@@ -286,8 +284,6 @@ Features:
 
 * add systemctl switch to dump transaction without executing it
 
 
 * add systemctl switch to dump transaction without executing it
 
-* suspend, resume support?
-
 * drop cap bounding set in readahead and other services
 
 External:
 * drop cap bounding set in readahead and other services
 
 External:
index b1e22e0ac3e48c49e08b69deade23a66c5031cf3..e07d1ed3c96d2a803c0d49d6fa4147251e936a10 100644 (file)
@@ -373,7 +373,7 @@ int manager_setup_cgroup(Manager *m) {
 
         log_debug("Created root group.");
 
 
         log_debug("Created root group.");
 
-        manager_shorten_default_controllers(m);
+        cg_shorten_controllers(m->default_controllers);
 
 finish:
         free(current);
 
 finish:
         free(current);
@@ -397,35 +397,6 @@ void manager_shutdown_cgroup(Manager *m, bool delete) {
         m->cgroup_hierarchy = NULL;
 }
 
         m->cgroup_hierarchy = NULL;
 }
 
-void manager_shorten_default_controllers(Manager *m) {
-        char **f, **t;
-
-        strv_uniq(m->default_controllers);
-
-        if (!m->default_controllers)
-                return;
-
-        for (f = m->default_controllers, t = m->default_controllers; *f; f++) {
-
-                if (!streq(*f, "systemd") && !streq(*f, "name=systemd")) {
-                        char *cc;
-
-                        cc = alloca(sizeof("/sys/fs/cgroup/") + strlen(*f));
-                        strcpy(stpcpy(cc, "/sys/fs/cgroup/"), *f);
-
-                        if (access(cc, F_OK) >= 0) {
-                                *(t++) = *f;
-                                continue;
-                        }
-                }
-
-                log_debug("Controller %s not available or redundant, removing from default controllers list.", *f);
-                free(*f);
-        }
-
-        *t = NULL;
-}
-
 int cgroup_bonding_get(Manager *m, const char *cgroup, CGroupBonding **bonding) {
         CGroupBonding *b;
         char *p;
 int cgroup_bonding_get(Manager *m, const char *cgroup, CGroupBonding **bonding) {
         CGroupBonding *b;
         char *p;
index dd2e6a4aee87be2c984e2e36436738ba987aab19..95f09e00195f69dd700544f36c928cb026d4624a 100644 (file)
@@ -85,7 +85,6 @@ pid_t cgroup_bonding_search_main_pid_list(CGroupBonding *b);
 
 int manager_setup_cgroup(Manager *m);
 void manager_shutdown_cgroup(Manager *m, bool delete);
 
 int manager_setup_cgroup(Manager *m);
 void manager_shutdown_cgroup(Manager *m, bool delete);
-void manager_shorten_default_controllers(Manager *m);
 
 int cgroup_bonding_get(Manager *m, const char *cgroup, CGroupBonding **bonding);
 int cgroup_notify_empty(Manager *m, const char *group);
 
 int cgroup_bonding_get(Manager *m, const char *cgroup, CGroupBonding **bonding);
 int cgroup_notify_empty(Manager *m, const char *group);
index 44690525ea556422b0e4abaa2e23e7f54528d19b..1446c01ea56f8e19be33c71f651e7218e1fe7490 100644 (file)
@@ -63,6 +63,7 @@
 #include "exit-status.h"
 #include "virt.h"
 #include "watchdog.h"
 #include "exit-status.h"
 #include "virt.h"
 #include "watchdog.h"
+#include "cgroup-util.h"
 
 /* As soon as 16 units are in our GC queue, make sure to run a gc sweep */
 #define GC_QUEUE_ENTRIES_MAX 16
 
 /* As soon as 16 units are in our GC queue, make sure to run a gc sweep */
 #define GC_QUEUE_ENTRIES_MAX 16
@@ -3172,7 +3173,7 @@ int manager_set_default_controllers(Manager *m, char **controllers) {
         strv_free(m->default_controllers);
         m->default_controllers = l;
 
         strv_free(m->default_controllers);
         m->default_controllers = l;
 
-        manager_shorten_default_controllers(m);
+        cg_shorten_controllers(m->default_controllers);
 
         return 0;
 }
 
         return 0;
 }
index 11697528731df3586478967933ad9b2ba384f7c0..6b7012ec73f3704cf330288c3877409600e1eaf6 100644 (file)
@@ -1205,6 +1205,9 @@ int manager_startup(Manager *m) {
         assert(m);
         assert(m->epoll_fd <= 0);
 
         assert(m);
         assert(m->epoll_fd <= 0);
 
+        cg_shorten_controllers(m->reset_controllers);
+        cg_shorten_controllers(m->controllers);
+
         m->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
         if (m->epoll_fd < 0)
                 return -errno;
         m->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
         if (m->epoll_fd < 0)
                 return -errno;
index 8ceb382820d8e9adea51df7199b79567442b43c4..3cb41c7c5fc55576d4fc8ad33ba77c366a6f48f4 100644 (file)
@@ -34,6 +34,7 @@
 #include "set.h"
 #include "macro.h"
 #include "util.h"
 #include "set.h"
 #include "macro.h"
 #include "util.h"
+#include "strv.h"
 
 int cg_enumerate_processes(const char *controller, const char *path, FILE **_f) {
         char *fs;
 
 int cg_enumerate_processes(const char *controller, const char *path, FILE **_f) {
         char *fs;
@@ -1100,3 +1101,35 @@ int cg_get_user_path(char **path) {
         *path = p;
         return 0;
 }
         *path = p;
         return 0;
 }
+
+char **cg_shorten_controllers(char **controllers) {
+        char **f, **t;
+
+        controllers = strv_uniq(controllers);
+
+        if (!controllers)
+                return controllers;
+
+        for (f = controllers, t = controllers; *f; f++) {
+                char *cc;
+
+                if (streq(*f, "systemd") || streq(*f, SYSTEMD_CGROUP_CONTROLLER)) {
+                        free(*f);
+                        continue;
+                }
+
+                cc = alloca(sizeof("/sys/fs/cgroup/") + strlen(*f));
+                strcpy(stpcpy(cc, "/sys/fs/cgroup/"), *f);
+
+                if (access(cc, F_OK) < 0) {
+                        log_debug("Controller %s is not available, removing from controllers list.", *f);
+                        free(*f);
+                        continue;
+                }
+
+                *(t++) = *f;
+        }
+
+        *t = NULL;
+        return controllers;
+}
index cc0ce54521fe834dc30cce08014f4d12b941f73d..bb156fc25911e8321f438854863d5c7a32e90047 100644 (file)
@@ -70,4 +70,6 @@ int cg_is_empty_recursive(const char *controller, const char *path, bool ignore_
 
 int cg_get_user_path(char **path);
 
 
 int cg_get_user_path(char **path);
 
+char **cg_shorten_controllers(char **controllers);
+
 #endif
 #endif