]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
c/r: teach criu about cgmanager's socket
authorTycho Andersen <tycho.andersen@canonical.com>
Thu, 26 Mar 2015 15:52:32 +0000 (15:52 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 6 Apr 2015 16:12:10 +0000 (12:12 -0400)
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 <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/cgfs.c
src/lxc/cgmanager.c
src/lxc/cgroup.c
src/lxc/cgroup.h
src/lxc/lxccontainer.c

index 20325fa3c669a335f44d4e37963977aee2869c23..11a5925df82a0f4110d46fd261be3126f6edec17 100644 (file)
@@ -2403,4 +2403,5 @@ static struct cgroup_ops cgfs_ops = {
        .chown = NULL,
        .mount_cgroup = cgroupfs_mount_cgroup,
        .nrtasks = cgfs_nrtasks,
+       .driver = CGFS,
 };
index 2eeed62c8fe604d85bf720ea6f38c5e33bb1d119..fe8913e41c078690421e71a84338c0ba67bebc18 100644 (file)
@@ -1397,5 +1397,6 @@ static struct cgroup_ops cgmanager_ops = {
        .mount_cgroup = cgm_mount_cgroup,
        .nrtasks = cgm_get_nrtasks,
        .disconnect = NULL,
+       .driver = CGMANAGER,
 };
 #endif
index a413832c38b8389a463726e1f0576bf3db5b7503..2362ad8b393cc6a25f872f35857cf32c02418072 100644 (file)
@@ -189,3 +189,8 @@ void cgroup_disconnect(void)
        if (ops && ops->disconnect)
                ops->disconnect();
 }
+
+cgroup_driver_t cgroup_driver(void)
+{
+       return ops->driver;
+}
index 281f40423609008e2830f42f0d48f1494c927778..670693991755cc18af0ae0dfb7f602b966a793f9 100644 (file)
@@ -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
index 1eadc6373ecae32855d9c247455b94e68dea030a..8d7fad4fe4f6bb8bab37633240b32ac8e892759b 100644 (file)
@@ -3736,6 +3736,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;
@@ -3778,6 +3783,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;
 
@@ -3786,6 +3796,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");