cgroups: rework cgroup initialization

parent 0e3af26b
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
lxc_log_define(cgroup, lxc); lxc_log_define(cgroup, lxc);
__hidden extern struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf); __hidden extern struct cgroup_ops *cgroup_ops_init(struct lxc_conf *conf);
struct cgroup_ops *cgroup_init(struct lxc_conf *conf) struct cgroup_ops *cgroup_init(struct lxc_conf *conf)
{ {
...@@ -30,7 +30,7 @@ struct cgroup_ops *cgroup_init(struct lxc_conf *conf) ...@@ -30,7 +30,7 @@ struct cgroup_ops *cgroup_init(struct lxc_conf *conf)
if (!conf) if (!conf)
return log_error_errno(NULL, EINVAL, "No valid conf given"); return log_error_errno(NULL, EINVAL, "No valid conf given");
cgroup_ops = cgfsng_ops_init(conf); cgroup_ops = cgroup_ops_init(conf);
if (!cgroup_ops) if (!cgroup_ops)
return log_error_errno(NULL, errno, "Failed to initialize cgroup driver"); return log_error_errno(NULL, errno, "Failed to initialize cgroup driver");
...@@ -47,13 +47,13 @@ struct cgroup_ops *cgroup_init(struct lxc_conf *conf) ...@@ -47,13 +47,13 @@ struct cgroup_ops *cgroup_init(struct lxc_conf *conf)
TRACE("Initialized cgroup driver %s", cgroup_ops->driver); TRACE("Initialized cgroup driver %s", cgroup_ops->driver);
if (cgroup_ops->cgroup_layout == CGROUP_LAYOUT_LEGACY) if (cgroup_ops->cgroup_layout == CGROUP_LAYOUT_LEGACY)
TRACE("Running with legacy cgroup layout"); TRACE("Legacy cgroup layout");
else if (cgroup_ops->cgroup_layout == CGROUP_LAYOUT_HYBRID) else if (cgroup_ops->cgroup_layout == CGROUP_LAYOUT_HYBRID)
TRACE("Running with hybrid cgroup layout"); TRACE("Hybrid cgroup layout");
else if (cgroup_ops->cgroup_layout == CGROUP_LAYOUT_UNIFIED) else if (cgroup_ops->cgroup_layout == CGROUP_LAYOUT_UNIFIED)
TRACE("Running with unified cgroup layout"); TRACE("Unified cgroup layout");
else else
WARN("Running with unknown cgroup layout"); WARN("Unsupported cgroup layout");
return cgroup_ops; return cgroup_ops;
} }
......
...@@ -230,4 +230,11 @@ static inline int cgroup_unified_fd(const struct cgroup_ops *ops) ...@@ -230,4 +230,11 @@ static inline int cgroup_unified_fd(const struct cgroup_ops *ops)
return ops->unified->cgfd_con; return ops->unified->cgfd_con;
} }
#define make_cgroup_path(__hierarchy, __first, ...) \
({ \
const struct hierarchy *__h = __hierarchy; \
must_make_path(DEFAULT_CGROUP_MOUNTPOINT, __h->mountpoint, \
__first, __VA_ARGS__); \
})
#endif /* __LXC_CGROUP_H */ #endif /* __LXC_CGROUP_H */
...@@ -86,7 +86,7 @@ bool test_writeable_v2(char *mountpoint, char *path) ...@@ -86,7 +86,7 @@ bool test_writeable_v2(char *mountpoint, char *path)
return (access(cgroup_threads_file, W_OK) == 0); return (access(cgroup_threads_file, W_OK) == 0);
} }
int unified_cgroup_fd(int fd) bool unified_cgroup_fd(int fd)
{ {
int ret; int ret;
......
...@@ -29,7 +29,7 @@ __hidden extern bool test_writeable_v1(char *mountpoint, char *path); ...@@ -29,7 +29,7 @@ __hidden extern bool test_writeable_v1(char *mountpoint, char *path);
*/ */
__hidden extern bool test_writeable_v2(char *mountpoint, char *path); __hidden extern bool test_writeable_v2(char *mountpoint, char *path);
__hidden extern int unified_cgroup_fd(int fd); __hidden extern bool unified_cgroup_fd(int fd);
static inline bool cgns_supported(void) static inline bool cgns_supported(void)
{ {
......
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