Commit 5da57aee by Tycho Andersen Committed by Stéphane Graber

c/r: teach criu about cgmanager's socket

CRIU needs to be told when something is bind mounted into the container from the outside as cgmanager's socket is. Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 340d5b74
...@@ -2403,4 +2403,5 @@ static struct cgroup_ops cgfs_ops = { ...@@ -2403,4 +2403,5 @@ static struct cgroup_ops cgfs_ops = {
.chown = NULL, .chown = NULL,
.mount_cgroup = cgroupfs_mount_cgroup, .mount_cgroup = cgroupfs_mount_cgroup,
.nrtasks = cgfs_nrtasks, .nrtasks = cgfs_nrtasks,
.driver = CGFS,
}; };
...@@ -1397,5 +1397,6 @@ static struct cgroup_ops cgmanager_ops = { ...@@ -1397,5 +1397,6 @@ static struct cgroup_ops cgmanager_ops = {
.mount_cgroup = cgm_mount_cgroup, .mount_cgroup = cgm_mount_cgroup,
.nrtasks = cgm_get_nrtasks, .nrtasks = cgm_get_nrtasks,
.disconnect = NULL, .disconnect = NULL,
.driver = CGMANAGER,
}; };
#endif #endif
...@@ -189,3 +189,8 @@ void cgroup_disconnect(void) ...@@ -189,3 +189,8 @@ void cgroup_disconnect(void)
if (ops && ops->disconnect) if (ops && ops->disconnect)
ops->disconnect(); ops->disconnect();
} }
cgroup_driver_t cgroup_driver(void)
{
return ops->driver;
}
...@@ -32,6 +32,11 @@ struct lxc_handler; ...@@ -32,6 +32,11 @@ struct lxc_handler;
struct lxc_conf; struct lxc_conf;
struct lxc_list; struct lxc_list;
typedef enum {
CGFS,
CGMANAGER,
} cgroup_driver_t;
struct cgroup_ops { struct cgroup_ops {
const char *name; const char *name;
...@@ -51,6 +56,7 @@ struct cgroup_ops { ...@@ -51,6 +56,7 @@ struct cgroup_ops {
bool (*mount_cgroup)(void *hdata, const char *root, int type); bool (*mount_cgroup)(void *hdata, const char *root, int type);
int (*nrtasks)(void *hdata); int (*nrtasks)(void *hdata);
void (*disconnect)(void); void (*disconnect)(void);
cgroup_driver_t driver;
}; };
extern bool cgroup_attach(const char *name, const char *lxcpath, pid_t pid); extern bool cgroup_attach(const char *name, const char *lxcpath, pid_t pid);
...@@ -72,5 +78,6 @@ extern const char *cgroup_get_cgroup(struct lxc_handler *handler, const char *su ...@@ -72,5 +78,6 @@ extern const char *cgroup_get_cgroup(struct lxc_handler *handler, const char *su
extern const char *cgroup_canonical_path(struct lxc_handler *handler); extern const char *cgroup_canonical_path(struct lxc_handler *handler);
extern bool cgroup_unfreeze(struct lxc_handler *handler); extern bool cgroup_unfreeze(struct lxc_handler *handler);
extern void cgroup_disconnect(void); extern void cgroup_disconnect(void);
extern cgroup_driver_t cgroup_driver(void);
#endif #endif
...@@ -3733,6 +3733,11 @@ static void exec_criu(struct criu_opts *opts) ...@@ -3733,6 +3733,11 @@ static void exec_criu(struct criu_opts *opts)
return; return;
} }
// We need to tell criu where cgmanager's socket is bind mounted from
// if it exists since it's external.
if (cgroup_driver() == CGMANAGER)
static_args+=2;
argv = malloc(static_args * sizeof(*argv)); argv = malloc(static_args * sizeof(*argv));
if (!argv) if (!argv)
return; return;
...@@ -3775,6 +3780,11 @@ static void exec_criu(struct criu_opts *opts) ...@@ -3775,6 +3780,11 @@ static void exec_criu(struct criu_opts *opts)
if (strcmp(opts->action, "dump") == 0) { if (strcmp(opts->action, "dump") == 0) {
char pid[32]; char pid[32];
if (cgroup_driver() == CGMANAGER) {
DECLARE_ARG("--ext-mount-map");
DECLARE_ARG("/sys/fs/cgroup/cgmanager:cgmanager");
}
if (sprintf(pid, "%d", lxcapi_init_pid(opts->c)) < 0) if (sprintf(pid, "%d", lxcapi_init_pid(opts->c)) < 0)
goto err; goto err;
...@@ -3783,6 +3793,12 @@ static void exec_criu(struct criu_opts *opts) ...@@ -3783,6 +3793,12 @@ static void exec_criu(struct criu_opts *opts)
if (!opts->stop) if (!opts->stop)
DECLARE_ARG("--leave-running"); DECLARE_ARG("--leave-running");
} else if (strcmp(opts->action, "restore") == 0) { } else if (strcmp(opts->action, "restore") == 0) {
if (cgroup_driver() == CGMANAGER) {
DECLARE_ARG("--ext-mount-map");
DECLARE_ARG("cgmanager:/sys/fs/cgroup/cgmanager");
}
DECLARE_ARG("--root"); DECLARE_ARG("--root");
DECLARE_ARG(opts->c->lxc_conf->rootfs.mount); DECLARE_ARG(opts->c->lxc_conf->rootfs.mount);
DECLARE_ARG("--restore-detached"); DECLARE_ARG("--restore-detached");
......
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