[lxc-devel] [PATCH] c/r: teach criu about cgmanager's socket
Tycho Andersen
tycho.andersen at canonical.com
Thu Mar 26 15:52:32 UTC 2015
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 at canonical.com>
---
src/lxc/cgfs.c | 1 +
src/lxc/cgmanager.c | 1 +
src/lxc/cgroup.c | 5 +++++
src/lxc/cgroup.h | 7 +++++++
src/lxc/lxccontainer.c | 16 ++++++++++++++++
5 files changed, 30 insertions(+)
diff --git a/src/lxc/cgfs.c b/src/lxc/cgfs.c
index 20325fa..11a5925 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 0932d96..080e382 100644
--- a/src/lxc/cgmanager.c
+++ b/src/lxc/cgmanager.c
@@ -1396,5 +1396,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 a413832..2362ad8 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 281f404..6706939 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 c3369cd..d84543f 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -3548,6 +3548,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;
@@ -3590,6 +3595,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;
@@ -3598,6 +3608,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");
--
2.1.0
More information about the lxc-devel
mailing list