cgroups: improve cgroup mounting

parent 937a3af9
...@@ -1931,16 +1931,23 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops, ...@@ -1931,16 +1931,23 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
return log_error_errno(-errno, errno, "Failed to open %d(%s)", return log_error_errno(-errno, errno, "Failed to open %d(%s)",
rootfs->dfd_mnt, DEFAULT_CGROUP_MOUNTPOINT_RELATIVE); rootfs->dfd_mnt, DEFAULT_CGROUP_MOUNTPOINT_RELATIVE);
if (in_cgroup_ns && wants_force_mount) { /*
/* * If cgroup namespaces are supported but the container will
* If cgroup namespaces are supported but the container * not have CAP_SYS_ADMIN after it has started we need to mount
* will not have CAP_SYS_ADMIN after it has started we * the cgroups manually.
* need to mount the cgroups manually. */
*/ if (in_cgroup_ns && wants_force_mount)
return cg_mount_in_cgroup_namespace(type, ops->unified, rootfs, dfd_mnt_cgroupfs, "") == 0; ret = cg_mount_in_cgroup_namespace(type, ops->unified, rootfs, dfd_mnt_cgroupfs, "");
} else
ret = cg_mount_cgroup_full(type, ops->unified, rootfs, dfd_mnt_cgroupfs, "");
if (ret < 0)
return syserrno(false, "Failed to%s mount cgroup filesystem%s",
wants_force_mount ? " force mount" : "",
in_cgroup_ns ? " in cgroup namespace" : "");
return cg_mount_cgroup_full(type, ops->unified, rootfs, dfd_mnt_cgroupfs, "") == 0; return log_trace(true, "%s cgroup filesystem%s",
wants_force_mount ? "Force mounted" : "Mounted",
in_cgroup_ns ? " in cgroup namespace" : "");
} }
/* /*
......
...@@ -494,6 +494,13 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \ ...@@ -494,6 +494,13 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
__internal_ret__; \ __internal_ret__; \
}) })
#define syserrno(__ret__, format, ...) \
({ \
typeof(__ret__) __internal_ret__ = (__ret__); \
SYSERROR(format, ##__VA_ARGS__); \
__internal_ret__; \
})
#define log_error(__ret__, format, ...) \ #define log_error(__ret__, format, ...) \
({ \ ({ \
typeof(__ret__) __internal_ret__ = (__ret__); \ typeof(__ret__) __internal_ret__ = (__ret__); \
......
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