From 900e71cbec452057743f8fcf15e584b0030cf0bb Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Mon, 30 May 2016 18:49:00 +0300 Subject: cg: rpc -- Add bindings for custom cgroup props engine For handling --cgroup-props, --cgroup-props-file and --cgroup-dump-controller from RPC interface. Signed-off-by: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- criu/cr-service.c | 12 ++++++++++++ images/rpc.proto | 4 ++++ lib/c/criu.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ lib/c/criu.h | 3 +++ 4 files changed, 65 insertions(+) diff --git a/criu/cr-service.c b/criu/cr-service.c index 219a98624..0f806f7f8 100644 --- a/criu/cr-service.c +++ b/criu/cr-service.c @@ -28,6 +28,7 @@ #include "net.h" #include "mount.h" #include "cgroup.h" +#include "cgroup-props.h" #include "action-scripts.h" #include "sockets.h" #include "irmap.h" @@ -453,6 +454,17 @@ static int setup_opts_from_req(int sk, CriuOpts *req) opts.manage_cgroups = mode; } + if (req->cgroup_props) + opts.cgroup_props = req->cgroup_props; + + if (req->cgroup_props_file) + opts.cgroup_props_file = req->cgroup_props_file; + + for (i = 0; i < req->n_cgroup_dump_controller; i++) { + if (!cgp_add_dump_controller(req->cgroup_dump_controller[i])) + goto err; + } + if (req->has_auto_ext_mnt) opts.autodetect_ext_mounts = req->auto_ext_mnt; diff --git a/images/rpc.proto b/images/rpc.proto index 9ece4dabb..7377bf83d 100644 --- a/images/rpc.proto +++ b/images/rpc.proto @@ -97,6 +97,10 @@ message criu_opts { repeated string external = 37; optional uint32 empty_ns = 38; repeated join_namespace join_ns = 39; + + optional string cgroup_props = 41; + optional string cgroup_props_file = 42; + repeated string cgroup_dump_controller = 43; } message criu_dump_resp { diff --git a/lib/c/criu.c b/lib/c/criu.c index 52d1b61d6..2e9ad75ac 100644 --- a/lib/c/criu.c +++ b/lib/c/criu.c @@ -700,6 +700,52 @@ err: return -ENOMEM; } +int criu_local_add_cg_props(criu_opts *opts, char *stream) +{ + char *new; + + new = strdup(stream); + if (!new) + return -ENOMEM; + + free(opts->rpc->cgroup_props); + opts->rpc->cgroup_props = new; + return 0; +} + +int criu_local_add_cg_props_file(criu_opts *opts, char *path) +{ + char *new; + + new = strdup(path); + if (!new) + return -ENOMEM; + + free(opts->rpc->cgroup_props_file); + opts->rpc->cgroup_props_file = new; + return 0; +} + +int criu_local_add_cg_dump_controller(criu_opts *opts, char *name) +{ + char **new; + size_t nr; + + nr = opts->n_cgroup_dump_controller + 1; + new = realloc(opts->cgroup_dump_controller, nr * sizeof(char *)); + if (!new) + return -ENOMEM; + + new[opts->n_cgroup_dump_controller] = strdup(name); + if (!new[opts->n_cgroup_dump_controller]) + return -ENOMEM; + + opts->n_cgroup_dump_controller = nr; + opts->cgroup_dump_controller = new; + + return 0; +} + int criu_add_skip_mnt(char *mnt) { return criu_local_add_skip_mnt(global_opts, mnt); diff --git a/lib/c/criu.h b/lib/c/criu.h index 0898be024..1085cd3de 100644 --- a/lib/c/criu.h +++ b/lib/c/criu.h @@ -191,6 +191,9 @@ int criu_local_add_enable_fs(criu_opts *opts, char *fs); int criu_local_add_skip_mnt(criu_opts *opts, char *mnt); void criu_local_set_ghost_limit(criu_opts *opts, unsigned int limit); int criu_local_add_irmap_path(criu_opts *opts, char *path); +int criu_local_add_cg_props(criu_opts *opts, char *stream); +int criu_local_add_cg_props_file(criu_opts *opts, char *path); +int criu_local_add_cg_dump_controller(criu_opts *opts, char *name); void criu_local_set_notify_cb(criu_opts *opts, int (*cb)(char *action, criu_notify_arg_t na)); -- cgit v1.2.3