logind: remove redundant entries from logind's default controller lists too
This commit is contained in:
parent
b69d29ce04
commit
b59e246565
4
TODO
4
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: remove /sys and /dev configurability
|
||||||
|
|
||||||
* udev: find a way to tell udev to not cancel firmware requests when running in initramfs
|
* 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
|
* drop cap bounding set in readahead and other services
|
||||||
|
|
||||||
External:
|
External:
|
||||||
|
|
|
@ -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:
|
finish:
|
||||||
free(current);
|
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) {
|
int cgroup_bonding_get(Manager *m, const char *cgroup, CGroupBonding **bonding) {
|
||||||
CGroupBonding *b;
|
CGroupBonding *b;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
|
@ -85,7 +85,6 @@ pid_t cgroup_bonding_search_main_pid_list(CGroupBonding *b);
|
||||||
|
|
||||||
int manager_setup_cgroup(Manager *m);
|
int manager_setup_cgroup(Manager *m);
|
||||||
void manager_shutdown_cgroup(Manager *m, bool delete);
|
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_bonding_get(Manager *m, const char *cgroup, CGroupBonding **bonding);
|
||||||
int cgroup_notify_empty(Manager *m, const char *group);
|
int cgroup_notify_empty(Manager *m, const char *group);
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
#include "exit-status.h"
|
#include "exit-status.h"
|
||||||
#include "virt.h"
|
#include "virt.h"
|
||||||
#include "watchdog.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 */
|
/* As soon as 16 units are in our GC queue, make sure to run a gc sweep */
|
||||||
#define GC_QUEUE_ENTRIES_MAX 16
|
#define GC_QUEUE_ENTRIES_MAX 16
|
||||||
|
@ -3172,7 +3173,7 @@ int manager_set_default_controllers(Manager *m, char **controllers) {
|
||||||
strv_free(m->default_controllers);
|
strv_free(m->default_controllers);
|
||||||
m->default_controllers = l;
|
m->default_controllers = l;
|
||||||
|
|
||||||
manager_shorten_default_controllers(m);
|
cg_shorten_controllers(m->default_controllers);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1205,6 +1205,9 @@ int manager_startup(Manager *m) {
|
||||||
assert(m);
|
assert(m);
|
||||||
assert(m->epoll_fd <= 0);
|
assert(m->epoll_fd <= 0);
|
||||||
|
|
||||||
|
cg_shorten_controllers(m->reset_controllers);
|
||||||
|
cg_shorten_controllers(m->controllers);
|
||||||
|
|
||||||
m->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
|
m->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
|
||||||
if (m->epoll_fd < 0)
|
if (m->epoll_fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "set.h"
|
#include "set.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "strv.h"
|
||||||
|
|
||||||
int cg_enumerate_processes(const char *controller, const char *path, FILE **_f) {
|
int cg_enumerate_processes(const char *controller, const char *path, FILE **_f) {
|
||||||
char *fs;
|
char *fs;
|
||||||
|
@ -1100,3 +1101,35 @@ int cg_get_user_path(char **path) {
|
||||||
*path = p;
|
*path = p;
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue