From 3d1e8c688347a1b0ed062197eb4e640f85f75660 Mon Sep 17 00:00:00 2001 From: Hui Kang Date: Wed, 5 Aug 2015 21:02:00 +0300 Subject: [PATCH] Enable manage cgroup modes in criu service Signed-off-by: Hui Kang Looks-good-to: Ruslan Kuprieiev Signed-off-by: Pavel Emelyanov --- cr-service.c | 4 ++++ lib/criu.c | 11 +++++++++++ lib/criu.h | 2 ++ protobuf/rpc.proto | 4 +++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cr-service.c b/cr-service.c index 105787ec2..9bf15edc1 100644 --- a/cr-service.c +++ b/cr-service.c @@ -400,6 +400,10 @@ static int setup_opts_from_req(int sk, CriuOpts *req) if (req->has_manage_cgroups) opts.manage_cgroups = req->manage_cgroups ? CG_MODE_SOFT : CG_MODE_IGNORE; + /* Override the manage_cgroup if mode is set explicitly */ + if (req->has_manage_cgroups_mode) { + opts.manage_cgroups = req->manage_cgroups_mode; + if (req->has_auto_ext_mnt) opts.autodetect_ext_mounts = req->auto_ext_mnt; diff --git a/lib/criu.c b/lib/criu.c index 3c194a182..90f909faf 100644 --- a/lib/criu.c +++ b/lib/criu.c @@ -375,6 +375,17 @@ void criu_set_manage_cgroups(bool manage) criu_local_set_manage_cgroups(global_opts, manage); } +void criu_local_set_manage_cgroups_mode(criu_opts *opts, unsigned int mode) +{ + opts->rpc->has_manage_cgroups_mode = true; + opts->rpc->manage_cgroups_mode = mode; +} + +void criu_set_manage_cgroups_mode(unsigned int mode) +{ + criu_local_set_manage_cgroups_mode(global_opts, mode); +} + void criu_local_set_auto_ext_mnt(criu_opts *opts, bool val) { opts->rpc->has_auto_ext_mnt = true; diff --git a/lib/criu.h b/lib/criu.h index 3cb03227b..169b9e36a 100644 --- a/lib/criu.h +++ b/lib/criu.h @@ -67,6 +67,7 @@ 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_manage_cgroups(bool manage); +void criu_set_manage_cgroups_mode(unsigned int mode); void criu_set_auto_ext_mnt(bool val); void criu_set_ext_sharing(bool val); void criu_set_ext_masters(bool val); @@ -166,6 +167,7 @@ void criu_local_set_log_file(criu_opts *opts, char *log_file); void criu_local_set_cpu_cap(criu_opts *opts, unsigned int cap); void criu_local_set_root(criu_opts *opts, char *root); void criu_local_set_manage_cgroups(criu_opts *opts, bool manage); +void criu_local_set_manage_cgroups_mode(criu_opts *opts, unsigned int mode); void criu_local_set_auto_ext_mnt(criu_opts *opts, bool val); void criu_local_set_ext_sharing(criu_opts *opts, bool val); void criu_local_set_ext_masters(criu_opts *opts, bool val); diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto index 2f4d0c072..f49325e27 100644 --- a/protobuf/rpc.proto +++ b/protobuf/rpc.proto @@ -60,7 +60,7 @@ message criu_opts { repeated string exec_cmd = 22; repeated ext_mount_map ext_mnt = 23; - optional bool manage_cgroups = 24; + optional bool manage_cgroups = 24; /* backward compatibility */ repeated cgroup_root cg_root = 25; optional bool rst_sibling = 26; /* swrk only */ @@ -74,6 +74,8 @@ message criu_opts { repeated string enable_fs = 32; repeated unix_sk unix_sk_ino = 33; + + optional uint32 manage_cgroups_mode = 34; } message criu_dump_resp {