[CRIU] [PATCH] opts: add --no-restore-cgroup option

Tycho Andersen tycho.andersen at canonical.com
Mon Aug 4 07:59:01 PDT 2014


Hi Cyrill,

On Mon, Aug 04, 2014 at 06:39:52PM +0400, Cyrill Gorcunov wrote:
> On Mon, Aug 04, 2014 at 09:37:10AM -0500, Tycho Andersen wrote:
> > Hi Cyrill,
> > 
> > On Mon, Aug 04, 2014 at 06:32:07PM +0400, Cyrill Gorcunov wrote:
> > > Somehow unclean from changelog why we need this option at all?
> > 
> > Pavel had mentioned off-list that this was a release blocker (e.g. if
> > people were doing their own restore or whatever), and that a patch
> > with an option would be appreciated.
> 
> I see. Write appropriate changelog then, because otherwise it's
> hard to imagine why we need it.

Below is the patch with an updated changelog.

Tycho




Users may already be restoring their own cgroups; now that criu does this,
those users may want to turn criu's version off until/unless they migrate.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 cgroup.c             | 4 +++-
 cr-service.c         | 3 +++
 crtools.c            | 5 +++++
 include/cr_options.h | 1 +
 lib/criu.c           | 6 ++++++
 lib/criu.h           | 1 +
 protobuf/rpc.proto   | 1 +
 7 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/cgroup.c b/cgroup.c
index 06311e4..bc66432 100644
--- a/cgroup.c
+++ b/cgroup.c
@@ -10,6 +10,7 @@
 #include "list.h"
 #include "xmalloc.h"
 #include "cgroup.h"
+#include "cr_options.h"
 #include "pstree.h"
 #include "proc_parse.h"
 #include "util.h"
@@ -771,7 +772,8 @@ static int prepare_cgroup_sfd(CgroupEntry *ce)
 			goto err;
 		}
 
-		if (prepare_cgroup_dirs(paux, off + name_off, ctrl->dirs, ctrl->n_dirs))
+		if (opts.restore_cgroups &&
+		    prepare_cgroup_dirs(paux, off + name_off, ctrl->dirs, ctrl->n_dirs))
 			goto err;
 
 	}
diff --git a/cr-service.c b/cr-service.c
index 64ce751..a1ebd62 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -303,6 +303,9 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
 	if (req->has_cpu_cap)
 		opts.cpu_cap = req->cpu_cap;
 
+	if (req->has_restore_cgroups)
+		opts.restore_cgroups = req->restore_cgroups;
+
 	return 0;
 }
 
diff --git a/crtools.c b/crtools.c
index b662fff..6856f4a 100644
--- a/crtools.c
+++ b/crtools.c
@@ -49,6 +49,7 @@ void init_opts(void)
 	INIT_LIST_HEAD(&opts.ext_mounts);
 
 	opts.cpu_cap = CPU_CAP_ALL;
+	opts.restore_cgroups = true;
 }
 
 static int parse_ns_string(const char *ptr)
@@ -167,6 +168,7 @@ int main(int argc, char *argv[])
 		{ "force-irmap", no_argument, 0, 58},
 		{ "ext-mount-map", required_argument, 0, 'M'},
 		{ "exec-cmd", no_argument, 0, 59},
+		{ "no-restore-cgroups", no_argument, 0, 60},
 		{ },
 	};
 
@@ -352,6 +354,9 @@ int main(int argc, char *argv[])
 		case 59:
 			has_exec_cmd = true;
 			break;
+		case 60:
+			opts.restore_cgroups = false;
+			break;
 		case 'M':
 			{
 				char *aux;
diff --git a/include/cr_options.h b/include/cr_options.h
index 55ca70b..0a2406f 100644
--- a/include/cr_options.h
+++ b/include/cr_options.h
@@ -51,6 +51,7 @@ struct cr_options {
 	unsigned int		cpu_cap;
 	bool			force_irmap;
 	char			**exec_cmd;
+	bool			restore_cgroups;
 };
 
 extern struct cr_options opts;
diff --git a/lib/criu.c b/lib/criu.c
index ca6c6aa..ac6abc7 100644
--- a/lib/criu.c
+++ b/lib/criu.c
@@ -152,6 +152,12 @@ void criu_set_root(char *root)
 	opts->root = strdup(root);
 }
 
+void criu_set_restore_cgroups(bool restore)
+{
+	opts->has_restore_cgroups = true;
+	opts->restore_cgroups = restore;
+}
+
 void criu_set_log_file(char *log_file)
 {
 	opts->log_file = strdup(log_file);
diff --git a/lib/criu.h b/lib/criu.h
index 18faaef..7d81029 100644
--- a/lib/criu.h
+++ b/lib/criu.h
@@ -47,6 +47,7 @@ void criu_set_log_level(int log_level);
 void criu_set_log_file(char *log_file);
 void criu_set_cpu_cap(unsigned int cap);
 void criu_set_root(char *root);
+void criu_set_restore_cgroups(bool restore);
 int criu_set_exec_cmd(int argc, char *argv[]);
 int criu_add_ext_mount(char *key, char *val);
 int criu_add_veth_pair(char *in, char *out);
diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto
index e50d97c..ed2e3e4 100644
--- a/protobuf/rpc.proto
+++ b/protobuf/rpc.proto
@@ -45,6 +45,7 @@ message criu_opts {
 	repeated string			exec_cmd	= 22;
 
 	repeated ext_mount_map		ext_mnt		= 23;
+	optional bool			restore_cgroups = 24;
 }
 
 message criu_dump_resp {
-- 
1.9.1



More information about the CRIU mailing list