[CRIU] [PATCH 2/3] devmap: Add rpc interface
Cyrill Gorcunov
gorcunov at openvz.org
Tue Nov 24 02:12:19 PST 2015
https://jira.sw.ru/PSBM-41357
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
cr-service.c | 14 ++++++++++++++
lib/criu.c | 26 ++++++++++++++++++++++++++
lib/criu.h | 2 ++
protobuf/rpc.proto | 7 +++++++
4 files changed, 49 insertions(+)
diff --git a/cr-service.c b/cr-service.c
index cca4ca56fa00..65238e30cfed 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -465,6 +465,20 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
}
}
+ if (req->n_devmap) {
+ size_t i, j;
+
+ opts.devmap = xmalloc(sizeof(*opts.devmap) * req->n_devmap * 2);
+ if (!opts.devmap)
+ goto err;
+
+ opts.nr_devmap = req->n_devmap * 2;
+ for (i = 0, j = 0; i < req->n_devmap; i++, j += 2) {
+ opts.devmap[j + 0] = req->devmap[i]->from;
+ opts.devmap[j + 1] = req->devmap[i]->to;
+ }
+ }
+
return 0;
err:
diff --git a/lib/criu.c b/lib/criu.c
index 52d1b61d6371..ae083dd2e560 100644
--- a/lib/criu.c
+++ b/lib/criu.c
@@ -700,6 +700,27 @@ err:
return -ENOMEM;
}
+int criu_local_add_devmap_entry(criu_opts *opts, unsigned int from, unsigned int to)
+{
+ int nr;
+ DevmapEntry **m;
+
+ if (!opts)
+ return -EINVAL;
+
+ nr = opts->rpc->n_devmap + 1;
+ m = realloc(opts->rpc->devmap, nr * sizeof(*m));
+ if (!m)
+ return -ENOMEM;
+
+ m[nr - 1]->from = from;
+ m[nr - 1]->to = to;
+
+ opts->rpc->n_devmap = nr;
+ opts->rpc->devmap = m;
+ return 0;
+}
+
int criu_add_skip_mnt(char *mnt)
{
return criu_local_add_skip_mnt(global_opts, mnt);
@@ -721,6 +742,11 @@ int criu_add_irmap_path(char *path)
return criu_local_add_irmap_path(global_opts, path);
}
+int criu_add_devmap_entry(unsigned int from, unsigned int to)
+{
+ return criu_local_add_devmap_entry(global_opts, from, to);
+}
+
static CriuResp *recv_resp(int socket_fd)
{
unsigned char *buf = NULL;
diff --git a/lib/criu.h b/lib/criu.h
index 0898be024f63..44e40b463518 100644
--- a/lib/criu.h
+++ b/lib/criu.h
@@ -89,6 +89,7 @@ int criu_add_enable_fs(char *fs);
int criu_add_skip_mnt(char *mnt);
void criu_set_ghost_limit(unsigned int limit);
int criu_add_irmap_path(char *path);
+int criu_add_devmap_entry(unsigned int from, unsigned int to);
/*
* The criu_notify_arg_t na argument is an opaque
@@ -191,6 +192,7 @@ 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_devmap_entry(criu_opts *opts, unsigned int from, unsigned int to);
void criu_local_set_notify_cb(criu_opts *opts, int (*cb)(char *action, criu_notify_arg_t na));
diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto
index 30235a0a0d7f..60467539ee55 100644
--- a/protobuf/rpc.proto
+++ b/protobuf/rpc.proto
@@ -29,6 +29,11 @@ message unix_sk {
required uint32 inode = 1;
};
+message devmap_entry {
+ required uint32 from = 1;
+ required uint32 to = 2;
+};
+
enum criu_cg_mode {
IGNORE = 0;
NONE = 1;
@@ -88,6 +93,8 @@ message criu_opts {
optional criu_cg_mode manage_cgroups_mode = 34;
optional uint32 ghost_limit = 35 [default = 0x100000];
repeated string irmap_scan_paths = 36;
+
+ repeated devmap_entry devmap = 37;
}
message criu_dump_resp {
--
2.5.0
More information about the CRIU
mailing list