[CRIU] [PATCH 7/5] rpc: add deduplication

Tikhomirov Pavel snorcht at gmail.com
Fri Feb 21 06:42:49 PST 2014


add dedup request and auto-dedup option in criu_opts

Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
---
 cr-service.c       | 35 +++++++++++++++++++++++++++++++++++
 protobuf/rpc.proto | 10 ++++++----
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/cr-service.c b/cr-service.c
index 22f32cf..4008e92 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -124,6 +124,16 @@ int send_criu_restore_resp(int socket_fd, bool success, int pid)
 	return send_criu_msg(socket_fd, &msg);
 }
 
+int send_criu_dedup_resp(int socket_fd, bool success)
+{
+	CriuResp msg = CRIU_RESP__INIT;
+
+	msg.type = CRIU_REQ_TYPE__DEDUP;
+	msg.success = success;
+
+	return send_criu_msg(socket_fd, &msg);
+}
+
 int send_criu_rpc_script(char *script, int fd)
 {
 	int ret;
@@ -259,6 +269,9 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
 	if (req->has_link_remap)
 		opts.link_remap_ok = req->link_remap;
 
+	if (req->has_auto_dedup)
+		opts.auto_dedup = req->auto_dedup;
+
 	if (req->ps) {
 		opts.use_page_server = true;
 		opts.addr = req->ps->address;
@@ -343,6 +356,26 @@ exit:
 	return success ? 0 : 1;
 }
 
+static int dedup_using_req(int sk, CriuOpts *req)
+{
+	bool success = false;
+
+	if (setup_opts_from_req(sk, req))
+		goto exit;
+
+	if (cr_dedup())
+		goto exit;
+
+	success = true;
+exit:
+	if (send_criu_dedup_resp(sk, success) == -1) {
+		pr_perror("Can't send response");
+		success = false;
+	}
+
+	return success ? 0 : 1;
+}
+
 static int check(int sk)
 {
 	CriuResp resp = CRIU_RESP__INIT;
@@ -477,6 +510,8 @@ static int cr_service_work(int sk)
 		return pre_dump_loop(sk, msg);
 	case CRIU_REQ_TYPE__PAGE_SERVER:
 		return start_page_server_req(sk, msg->opts);
+	case CRIU_REQ_TYPE__DEDUP:
+		return dedup_using_req(sk, msg->opts);
 
 	default:
 		send_criu_err(sk, "Invalid req");
diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto
index 6a04b6b..554741c 100644
--- a/protobuf/rpc.proto
+++ b/protobuf/rpc.proto
@@ -29,10 +29,11 @@ message criu_opts {
 	optional string			root		= 13;
 	optional string			parent_img	= 14;
 	optional bool			track_mem	= 15;
+	optional bool			auto_dedup	= 16;
 
-	optional int32			work_dir_fd	= 16;
-	optional bool			link_remap	= 17;
-	repeated criu_veth_pair		veths		= 18;
+	optional int32			work_dir_fd	= 17;
+	optional bool			link_remap	= 18;
+	repeated criu_veth_pair		veths		= 19;
 }
 
 message criu_dump_resp {
@@ -55,8 +56,9 @@ enum criu_req_type {
 	CHECK		= 3;
 	PRE_DUMP	= 4;
 	PAGE_SERVER	= 5;
+	DEDUP		= 6;
 
-	NOTIFY		= 6;
+	NOTIFY		= 7;
 }
 
 /*
-- 
1.8.3.2



More information about the CRIU mailing list