#include "cgroup.h"
#include "cgroup-util.h"
#include "log.h"
+#include "strv.h"
int cgroup_bonding_realize(CGroupBonding *b) {
int r;
}
/* 1. Determine hierarchy */
- if ((r = cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, 0, ¤t)) < 0) {
+ r = cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, 0, ¤t);
+ if (r < 0) {
log_error("Cannot determine cgroup we are running in: %s", strerror(-r));
goto finish;
}
}
/* 2. Show data */
- if ((r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_hierarchy, NULL, &path)) < 0) {
+ r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_hierarchy, NULL, &path);
+ if (r < 0) {
log_error("Cannot find cgroup mount point: %s", strerror(-r));
goto finish;
}
log_debug("Using cgroup controller " SYSTEMD_CGROUP_CONTROLLER ". File system hierarchy is at %s.", path);
/* 3. Install agent */
- if ((r = cg_install_release_agent(SYSTEMD_CGROUP_CONTROLLER, SYSTEMD_CGROUP_AGENT_PATH)) < 0)
+ r = cg_install_release_agent(SYSTEMD_CGROUP_CONTROLLER, SYSTEMD_CGROUP_AGENT_PATH);
+ if (r < 0)
log_warning("Failed to install release agent, ignoring: %s", strerror(-r));
else if (r > 0)
log_debug("Installed release agent.");
log_debug("Release agent already installed.");
/* 4. Realize the group */
- if ((r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_hierarchy, 0)) < 0) {
+ r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_hierarchy, 0);
+ if (r < 0) {
log_error("Failed to create root cgroup hierarchy: %s", strerror(-r));
goto finish;
}
if (m->pin_cgroupfs_fd >= 0)
close_nointr_nofail(m->pin_cgroupfs_fd);
- if ((m->pin_cgroupfs_fd = open(path, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY|O_NONBLOCK)) < 0) {
+ m->pin_cgroupfs_fd = open(path, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY|O_NONBLOCK);
+ if (r < 0) {
log_error("Failed to open pin file: %m");
r = -errno;
goto finish;
log_debug("Created root group.");
+ cg_shorten_controllers(m->default_controllers);
+
finish:
free(current);
free(path);