[CRIU] [PATCH] Enable manage cgroup modes in criu service
Ruslan Kuprieiev
kupruser at gmail.com
Thu Aug 6 02:48:30 PDT 2015
Hi,
Patch looks good to me. But I've also noticed
that we provide no way for a libcriu and rpc users
to get those CG_MODE_* constants other than
by looking directly into criu sources, which isn't
nice. What do you guys think?
Thanks,
Ruslan
On 08/05/2015 09:02 PM, Hui Kang wrote:
> Signed-off-by: Hui Kang <hkang.sunysb at gmail.com>
> ---
> 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 105787e..9bf15ed 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 3c194a1..90f909f 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 3cb0322..169b9e3 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 2f4d0c0..f49325e 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 {
More information about the CRIU
mailing list