Commit 900e71cb authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

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: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 92486c90
......@@ -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;
......
......@@ -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 {
......
......@@ -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);
......
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment