[CRIU] [PATCH 8/7] Added --pre-dump-mode to libcriu

Abhishek Dubey dubeyabhishek777 at gmail.com
Tue Aug 27 13:25:31 MSK 2019


Signed-off-by: Abhishek Dubey <dubeyabhishek777 at gmail.com>
---
 criu/cr-service.c | 13 +++++++++++++
 images/rpc.proto  |  6 ++++++
 lib/c/criu.c      | 15 +++++++++++++++
 lib/c/criu.h      |  7 +++++++
 4 files changed, 41 insertions(+)

diff --git a/criu/cr-service.c b/criu/cr-service.c
index 0938db0..4a853a9 100644
--- a/criu/cr-service.c
+++ b/criu/cr-service.c
@@ -473,6 +473,19 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
 		opts.lazy_pages = req->lazy_pages;
 	}
 
+	if (req->has_pre_dump_mode) {
+		switch (req->pre_dump_mode) {
+			case CRIU_PRE_DUMP_MODE__SPLICE:
+				opts.pre_dump_mode = PRE_DUMP_SPLICE;
+				break;
+			case CRIU_PRE_DUMP_MODE__READ:
+				opts.pre_dump_mode = PRE_DUMP_READ;
+				break;
+			default:
+				goto err;
+		}
+	}
+
 	if (req->ps) {
 		opts.port = (short)req->ps->port;
 
diff --git a/images/rpc.proto b/images/rpc.proto
index 15e677a..29804b5 100644
--- a/images/rpc.proto
+++ b/images/rpc.proto
@@ -47,6 +47,11 @@ enum criu_cg_mode {
 	DEFAULT = 6;
 };
 
+enum criu_pre_dump_mode {
+	SPLICE = 	1;
+	READ =		2;
+};
+
 message criu_opts {
 	required int32			images_dir_fd	= 1;
 	optional int32			pid		= 2; /* if not set on dump, will dump requesting process */
@@ -120,6 +125,7 @@ message criu_opts {
 	optional string			tls_key			= 57;
 	optional bool			tls			= 58;
 	optional bool			tls_no_cn_verify	= 59;
+	optional criu_pre_dump_mode	pre_dump_mode		= 60 [default = SPLICE];
 /*	optional bool			check_mounts		= 128;	*/
 }
 
diff --git a/lib/c/criu.c b/lib/c/criu.c
index 17d5c39..4748df5 100644
--- a/lib/c/criu.c
+++ b/lib/c/criu.c
@@ -336,6 +336,21 @@ int criu_set_parent_images(const char *path)
 	return criu_local_set_parent_images(global_opts, path);
 }
 
+int criu_local_set_pre_dump_mode(criu_opts *opts, enum criu_pre_dump_mode mode)
+{
+	opts->rpc->has_pre_dump_mode = true;
+	if (mode == CRIU_PRE_DUMP_SPLICE || mode == CRIU_PRE_DUMP_READ) {
+		opts->rpc->pre_dump_mode = mode;
+		return 0;
+	}
+	return -1;
+}
+
+int criu_set_pre_dump_mode(enum criu_pre_dump_mode mode)
+{
+	return criu_local_set_pre_dump_mode(global_opts, mode);
+}
+
 void criu_local_set_track_mem(criu_opts *opts, bool track_mem)
 {
 	opts->rpc->has_track_mem = true;
diff --git a/lib/c/criu.h b/lib/c/criu.h
index 76f3547..c8e97e2 100644
--- a/lib/c/criu.h
+++ b/lib/c/criu.h
@@ -43,6 +43,11 @@ enum criu_cg_mode {
 	CRIU_CG_MODE_DEFAULT,
 };
 
+enum criu_pre_dump_mode {
+	CRIU_PRE_DUMP_SPLICE =	1,
+	CRIU_PRE_DUMP_READ =	2
+};
+
 int criu_set_service_address(const char *path);
 void criu_set_service_fd(int fd);
 int criu_set_service_binary(const char *path);
@@ -95,6 +100,7 @@ int criu_add_irmap_path(const char *path);
 int criu_add_inherit_fd(int fd, const char *key);
 int criu_add_external(const char *key);
 int criu_set_page_server_address_port(const char *address, int port);
+int criu_set_pre_dump_mode(enum criu_pre_dump_mode mode);
 
 /*
  * The criu_notify_arg_t na argument is an opaque
@@ -210,6 +216,7 @@ int criu_local_add_cg_dump_controller(criu_opts *opts, const char *name);
 int criu_local_add_inherit_fd(criu_opts *opts, int fd, const char *key);
 int criu_local_add_external(criu_opts *opts, const char *key);
 int criu_local_set_page_server_address_port(criu_opts *opts, const char *address, int port);
+int criu_local_set_pre_dump_mode(criu_opts *opts, enum criu_pre_dump_mode mode);
 
 void criu_local_set_notify_cb(criu_opts *opts, int (*cb)(char *action, criu_notify_arg_t na));
 
-- 
2.7.4



More information about the CRIU mailing list