[CRIU] [PATCH 2/3] rpc: add target_pid option

Ruslan Kuprieiev rkuprieiev at cloudlinux.com
Mon Feb 27 03:39:52 PST 2017


Same as --pid in CLI, but to avoid confusion(which is
really strong in this case) it's named as target_pid.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev at cloudlinux.com>
---
 criu/cr-service.c |  3 +++
 images/rpc.proto  |  1 +
 lib/c/criu.c      | 11 +++++++++++
 lib/c/criu.h      |  2 ++
 4 files changed, 17 insertions(+)

diff --git a/criu/cr-service.c b/criu/cr-service.c
index 169d637..8b4f5a9 100644
--- a/criu/cr-service.c
+++ b/criu/cr-service.c
@@ -531,6 +531,9 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
 			goto err;
 	}
 
+	if (req->has_target_pid)
+		opts.pid = req->target_pid;
+
 	if (req->orphan_pts_master)
 		opts.orphan_pts_master = true;
 
diff --git a/images/rpc.proto b/images/rpc.proto
index f924b73..e8666de 100644
--- a/images/rpc.proto
+++ b/images/rpc.proto
@@ -111,6 +111,7 @@ message criu_opts {
 	optional bool			lazy_pages		= 48;
 	optional int32			status_fd		= 49;
 	optional bool			orphan_pts_master	= 50;
+	optional int32			target_pid		= 51; /* same as --pid in CLI */
 }
 
 message criu_dump_resp {
diff --git a/lib/c/criu.c b/lib/c/criu.c
index 08806c6..9d94dbc 100644
--- a/lib/c/criu.c
+++ b/lib/c/criu.c
@@ -880,6 +880,17 @@ int criu_add_external(char *key)
 	return criu_local_add_external(global_opts, key);
 }
 
+void criu_local_set_target_pid(criu_opts *opts, int target_pid)
+{
+	opts->rpc->has_target_pid	= true;
+	opts->rpc->target_pid		= target_pid;
+}
+
+void criu_set_target_pid(int target_pid)
+{
+	criu_local_set_target_pid(global_opts, target_pid);
+}
+
 static CriuResp *recv_resp(int socket_fd)
 {
 	unsigned char *buf = NULL;
diff --git a/lib/c/criu.h b/lib/c/criu.h
index 5d0b5b6..8573bac 100644
--- a/lib/c/criu.h
+++ b/lib/c/criu.h
@@ -95,6 +95,7 @@ void criu_set_ghost_limit(unsigned int limit);
 int criu_add_irmap_path(char *path);
 int criu_add_inherit_fd(int fd, char *key);
 int criu_add_external(char *key);
+void criu_set_target_pid(int target_pid);
 
 /*
  * The criu_notify_arg_t na argument is an opaque
@@ -206,6 +207,7 @@ int criu_local_add_cg_props_file(criu_opts *opts, char *path);
 int criu_local_add_cg_dump_controller(criu_opts *opts, char *name);
 int criu_local_add_inherit_fd(criu_opts *opts, int fd, char *key);
 int criu_local_add_external(criu_opts *opts, char *key);
+void criu_local_set_target_pid(criu_opts *opts, int target_pid);
 
 void criu_local_set_notify_cb(criu_opts *opts, int (*cb)(char *action, criu_notify_arg_t na));
 
-- 
2.9.3



More information about the CRIU mailing list