[CRIU] [PATCH] rpc: rename criu_dump_req to criu_opts

Ruslan Kuprieiev kupruser at gmail.com
Wed Oct 2 07:42:13 PDT 2013


Hi!

Lets rename CriuDumpReq to CriuOpts, for the sake of readability and to 
avoid coping code for restore mechanism, as CriuDumpReq and 
CriuRestoreResp would have almost the same fields. Also, it would be 
easier to introduce other types of requests.

Signed-off-by: Ruslan Kuprieiev <kurpuser at gmail.com>
-------------- next part --------------
---
diff --git a/cr-service.c b/cr-service.c
index d1286c3..3c41658 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -75,7 +75,7 @@ int send_criu_dump_resp(int socket_fd, bool success, bool restored)
 	return send_criu_msg(socket_fd, &msg);
 }
 
-static int setup_dump_from_req(int sk, CriuDumpReq *req)
+static int setup_dump_from_req(int sk, CriuOpts *req)
 {
 	struct ucred ids;
 	struct stat st;
@@ -146,7 +146,7 @@ static int setup_dump_from_req(int sk, CriuDumpReq *req)
 	return 0;
 }
 
-static int dump_using_req(int sk, CriuDumpReq *req)
+static int dump_using_req(int sk, CriuOpts *req)
 {
 	bool success = false;
 
@@ -183,7 +183,7 @@ static int cr_service_work(int sk)
 
 	switch (msg->type) {
 	case CRIU_REQ_TYPE__DUMP:
-		return dump_using_req(sk, msg->dump);
+		return dump_using_req(sk, msg->opts);
 
 	default: {
 		CriuResp resp = CRIU_RESP__INIT;
diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto
index a07b05f..3fe07e0 100644
--- a/protobuf/rpc.proto
+++ b/protobuf/rpc.proto
@@ -1,6 +1,6 @@
-message criu_dump_req {
+message criu_opts {
 	required int32 images_dir_fd	= 1;
-	optional int32 pid		= 2; //if not set, will dump requesting process
+	optional int32 pid		= 2; //if not set on dump, will dump requesting process
 
 	optional bool leave_running	= 3;
 	optional bool ext_unix_sk	= 4;
@@ -28,7 +28,7 @@ enum criu_req_type {
 message criu_req {
 	required criu_req_type type	= 1;
 
-	optional criu_dump_req dump	= 2;
+	optional criu_opts opts	= 2;
 }
 
 /*
diff --git a/test/rpc/test.c b/test/rpc/test.c
index e52bdde..46cabc1 100644
--- a/test/rpc/test.c
+++ b/test/rpc/test.c
@@ -83,24 +83,24 @@ int main()
 	 * Allocate CriuDumpReq.
 	 */
 	req.type			= CRIU_REQ_TYPE__DUMP;
-	req.dump			= malloc(sizeof(CriuDumpReq));
-	if (!req.dump) {
+	req.opts			= malloc(sizeof(CriuOpts));
+	if (!req.opts) {
 			perror("Can't allocate memory for dump request");
 			return -1;
 	}
 
-	criu_dump_req__init(req.dump);
+	criu_opts__init(req.opts);
 
 	/*
 	 * Set dump options.
 	 * Checkout more in protobuf/rpc.proto.
 	 */
-	req.dump->has_leave_running	= true;
-	req.dump->leave_running		= true;
-	req.dump->images_dir_fd		= dir_fd;
-	req.dump->has_shell_job		= true;
-	req.dump->shell_job		= true;
-	req.dump->log_level		= 4;
+	req.opts->has_leave_running	= true;
+	req.opts->leave_running		= true;
+	req.opts->images_dir_fd		= dir_fd;
+	req.opts->has_shell_job		= true;
+	req.opts->shell_job		= true;
+	req.opts->log_level		= 4;
 
 	/*
 	 * Connect to service socket
diff --git a/test/rpc/test.py b/test/rpc/test.py
index 46c6834..dcae3d1 100755
--- a/test/rpc/test.py
+++ b/test/rpc/test.py
@@ -14,13 +14,13 @@ s.connect('criu_service.socket')
 # and set dump options. Checkout more options in protobuf/rpc.proto
 req			= rpc.criu_req()
 req.type		= rpc.DUMP
-req.dump.leave_running	= True
-req.dump.shell_job	= True
+req.opts.leave_running	= True
+req.opts.shell_job	= True
 
 if not os.path.exists('imgs_py'):
 	os.makedirs('imgs_py')
 
-req.dump.images_dir_fd	= os.open('imgs_py', os.O_DIRECTORY)
+req.opts.images_dir_fd	= os.open('imgs_py', os.O_DIRECTORY)
 
 # Send request
 s.send(req.SerializeToString())


More information about the CRIU mailing list