From: Tycho Andersen Date: Thu, 26 Mar 2015 15:52:32 +0000 (+0000) Subject: c/r: teach criu about cgmanager's socket X-Git-Tag: lxc-1.1.2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5da57aeeb40d95ce1d0681dbd55bc5fa350411fe;p=thirdparty%2Flxc.git 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: Tycho Andersen Acked-by: Serge E. Hallyn --- diff --git a/src/lxc/cgfs.c b/src/lxc/cgfs.c index 20325fa3c..11a5925df 100644 --- a/src/lxc/cgfs.c +++ b/src/lxc/cgfs.c @@ -2403,4 +2403,5 @@ static struct cgroup_ops cgfs_ops = { .chown = NULL, .mount_cgroup = cgroupfs_mount_cgroup, .nrtasks = cgfs_nrtasks, + .driver = CGFS, }; diff --git a/src/lxc/cgmanager.c b/src/lxc/cgmanager.c index 2eeed62c8..fe8913e41 100644 --- a/src/lxc/cgmanager.c +++ b/src/lxc/cgmanager.c @@ -1397,5 +1397,6 @@ static struct cgroup_ops cgmanager_ops = { .mount_cgroup = cgm_mount_cgroup, .nrtasks = cgm_get_nrtasks, .disconnect = NULL, + .driver = CGMANAGER, }; #endif diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c index a413832c3..2362ad8b3 100644 --- a/src/lxc/cgroup.c +++ b/src/lxc/cgroup.c @@ -189,3 +189,8 @@ void cgroup_disconnect(void) if (ops && ops->disconnect) ops->disconnect(); } + +cgroup_driver_t cgroup_driver(void) +{ + return ops->driver; +} diff --git a/src/lxc/cgroup.h b/src/lxc/cgroup.h index 281f40423..670693991 100644 --- a/src/lxc/cgroup.h +++ b/src/lxc/cgroup.h @@ -32,6 +32,11 @@ struct lxc_handler; struct lxc_conf; struct lxc_list; +typedef enum { + CGFS, + CGMANAGER, +} cgroup_driver_t; + struct cgroup_ops { const char *name; @@ -51,6 +56,7 @@ struct cgroup_ops { bool (*mount_cgroup)(void *hdata, const char *root, int type); int (*nrtasks)(void *hdata); void (*disconnect)(void); + cgroup_driver_t driver; }; 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 extern const char *cgroup_canonical_path(struct lxc_handler *handler); extern bool cgroup_unfreeze(struct lxc_handler *handler); extern void cgroup_disconnect(void); +extern cgroup_driver_t cgroup_driver(void); #endif diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 5d95ca4c7..fdd0d58a7 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -3733,6 +3733,11 @@ static void exec_criu(struct criu_opts *opts) 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)); if (!argv) return; @@ -3775,6 +3780,11 @@ static void exec_criu(struct criu_opts *opts) if (strcmp(opts->action, "dump") == 0) { 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) goto err; @@ -3783,6 +3793,12 @@ static void exec_criu(struct criu_opts *opts) if (!opts->stop) DECLARE_ARG("--leave-running"); } 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(opts->c->lxc_conf->rootfs.mount); DECLARE_ARG("--restore-detached");