mirror of
git://github.com/lxc/lxc
synced 2025-09-05 16:39:52 +00:00
criu: mark cgroups methods specific to criu
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
@@ -2018,8 +2018,8 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
|
||||
}
|
||||
|
||||
/* Only root needs to escape to the cgroup of its init. */
|
||||
__cgfsng_ops static bool cgfsng_escape(const struct cgroup_ops *ops,
|
||||
struct lxc_conf *conf)
|
||||
__cgfsng_ops static bool cgfsng_criu_escape(const struct cgroup_ops *ops,
|
||||
struct lxc_conf *conf)
|
||||
{
|
||||
if (!ops)
|
||||
return ret_set_errno(false, ENOENT);
|
||||
@@ -2049,7 +2049,7 @@ __cgfsng_ops static bool cgfsng_escape(const struct cgroup_ops *ops,
|
||||
return true;
|
||||
}
|
||||
|
||||
__cgfsng_ops static int cgfsng_num_hierarchies(struct cgroup_ops *ops)
|
||||
__cgfsng_ops static int cgfsng_criu_num_hierarchies(struct cgroup_ops *ops)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@@ -2065,8 +2065,8 @@ __cgfsng_ops static int cgfsng_num_hierarchies(struct cgroup_ops *ops)
|
||||
return i;
|
||||
}
|
||||
|
||||
__cgfsng_ops static bool cgfsng_get_hierarchies(struct cgroup_ops *ops, int n,
|
||||
char ***out)
|
||||
__cgfsng_ops static bool cgfsng_criu_get_hierarchies(struct cgroup_ops *ops,
|
||||
int n, char ***out)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -3516,9 +3516,6 @@ struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf)
|
||||
cgfsng_ops->payload_create = cgfsng_payload_create;
|
||||
cgfsng_ops->payload_enter = cgfsng_payload_enter;
|
||||
cgfsng_ops->payload_finalize = cgfsng_payload_finalize;
|
||||
cgfsng_ops->escape = cgfsng_escape;
|
||||
cgfsng_ops->num_hierarchies = cgfsng_num_hierarchies;
|
||||
cgfsng_ops->get_hierarchies = cgfsng_get_hierarchies;
|
||||
cgfsng_ops->get_cgroup = cgfsng_get_cgroup;
|
||||
cgfsng_ops->get = cgfsng_get;
|
||||
cgfsng_ops->set = cgfsng_set;
|
||||
@@ -3534,6 +3531,10 @@ struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf)
|
||||
cgfsng_ops->devices_activate = cgfsng_devices_activate;
|
||||
cgfsng_ops->get_limiting_cgroup = cgfsng_get_limiting_cgroup;
|
||||
|
||||
cgfsng_ops->criu_escape = cgfsng_criu_escape;
|
||||
cgfsng_ops->criu_num_hierarchies = cgfsng_criu_num_hierarchies;
|
||||
cgfsng_ops->criu_get_hierarchies = cgfsng_criu_get_hierarchies;
|
||||
|
||||
return move_ptr(cgfsng_ops);
|
||||
}
|
||||
|
||||
|
@@ -157,9 +157,9 @@ struct cgroup_ops {
|
||||
bool (*payload_create)(struct cgroup_ops *ops, struct lxc_handler *handler);
|
||||
bool (*payload_enter)(struct cgroup_ops *ops, struct lxc_handler *handler);
|
||||
const char *(*get_cgroup)(struct cgroup_ops *ops, const char *controller);
|
||||
bool (*escape)(const struct cgroup_ops *ops, struct lxc_conf *conf);
|
||||
int (*num_hierarchies)(struct cgroup_ops *ops);
|
||||
bool (*get_hierarchies)(struct cgroup_ops *ops, int n, char ***out);
|
||||
bool (*criu_escape)(const struct cgroup_ops *ops, struct lxc_conf *conf);
|
||||
int (*criu_num_hierarchies)(struct cgroup_ops *ops);
|
||||
bool (*criu_get_hierarchies)(struct cgroup_ops *ops, int n, char ***out);
|
||||
int (*set)(struct cgroup_ops *ops, const char *filename,
|
||||
const char *value, const char *name, const char *lxcpath);
|
||||
int (*get)(struct cgroup_ops *ops, const char *filename, char *value,
|
||||
|
@@ -163,7 +163,7 @@ static void exec_criu(struct cgroup_ops *cgroup_ops, struct lxc_conf *conf,
|
||||
* /actual/ root cgroup so that lxcfs thinks criu has enough rights to
|
||||
* see all cgroups.
|
||||
*/
|
||||
if (!cgroup_ops->escape(cgroup_ops, conf)) {
|
||||
if (!cgroup_ops->criu_escape(cgroup_ops, conf)) {
|
||||
ERROR("failed to escape cgroups");
|
||||
return;
|
||||
}
|
||||
@@ -221,8 +221,8 @@ static void exec_criu(struct cgroup_ops *cgroup_ops, struct lxc_conf *conf,
|
||||
return;
|
||||
}
|
||||
|
||||
if (cgroup_ops->num_hierarchies(cgroup_ops) > 0)
|
||||
static_args += 2 * cgroup_ops->num_hierarchies(cgroup_ops);
|
||||
if (cgroup_ops->criu_num_hierarchies(cgroup_ops) > 0)
|
||||
static_args += 2 * cgroup_ops->criu_num_hierarchies(cgroup_ops);
|
||||
|
||||
if (opts->user->verbose)
|
||||
static_args++;
|
||||
@@ -279,11 +279,11 @@ static void exec_criu(struct cgroup_ops *cgroup_ops, struct lxc_conf *conf,
|
||||
DECLARE_ARG("-o");
|
||||
DECLARE_ARG(log);
|
||||
|
||||
for (i = 0; i < cgroup_ops->num_hierarchies(cgroup_ops); i++) {
|
||||
for (i = 0; i < cgroup_ops->criu_num_hierarchies(cgroup_ops); i++) {
|
||||
char **controllers = NULL, *fullname;
|
||||
char *path, *tmp;
|
||||
|
||||
if (!cgroup_ops->get_hierarchies(cgroup_ops, i, &controllers)) {
|
||||
if (!cgroup_ops->criu_get_hierarchies(cgroup_ops, i, &controllers)) {
|
||||
ERROR("failed to get hierarchy %d", i);
|
||||
goto err;
|
||||
}
|
||||
|
Reference in New Issue
Block a user