[CRIU] [PATCH] rpc: change some "required" fields to "optional" and rename rpc.proto to criu-rpc.proto
Ruslan Kuprieiev
kupruser at gmail.com
Sat Sep 14 13:43:34 EDT 2013
Hi!
The most of fields are to be changed to "optional", because they are
optional in fact.
Also, rename rpc.proto to criu-rpc.proto, so user will not have to mess
with renaming.
Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
-------------- next part --------------
diff --git a/cr-service.c b/cr-service.c
index 79ba032..b1f4bdf 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -86,9 +86,6 @@ static int setup_dump_from_req(CriuDumpReq *req)
cr_service_client->pid = ids.pid;
cr_service_client->uid = ids.uid;
- if (req->pid == 0)
- req->pid = ids.pid;
-
if (fstat(cr_service_client->sk_fd, &st)) {
pr_perror("Can't get socket stat");
return -1;
@@ -120,14 +117,28 @@ static int setup_dump_from_req(CriuDumpReq *req)
}
/* checking dump flags from client */
- if (req->leave_running)
+ if (req->has_leave_running && req->leave_running)
opts.final_state = TASK_ALIVE;
- opts.ext_unix_sk = req->ext_unix_sk;
- opts.tcp_established_ok = req->tcp_established;
- opts.evasive_devices = req->evasive_devices;
- opts.shell_job = req->shell_job;
- opts.handle_file_locks = req->file_locks;
+ if (!req->has_pid) {
+ req->has_pid = true;
+ req->pid = ids.pid;
+ }
+
+ if (req->has_ext_unix_sk)
+ opts.ext_unix_sk = req->ext_unix_sk;
+
+ if (req->has_tcp_established)
+ opts.tcp_established_ok = req->tcp_established;
+
+ if (req->has_evasive_devices)
+ opts.evasive_devices = req->evasive_devices;
+
+ if (req->has_shell_job)
+ opts.shell_job = req->shell_job;
+
+ if (req->has_file_locks)
+ opts.handle_file_locks = req->file_locks;
return 0;
}
@@ -149,7 +160,7 @@ static int dump_using_req(CriuDumpReq *req)
resp.success = true;
exit:
- if (req->leave_running) {
+ if (req->has_leave_running && req->leave_running) {
if (send_criu_dump_resp(cr_service_client->sk_fd,
&resp) == -1) {
pr_perror("Can't send response");
diff --git a/include/cr-service.h b/include/cr-service.h
index fd5e3e6..b64b260 100644
--- a/include/cr-service.h
+++ b/include/cr-service.h
@@ -1,7 +1,7 @@
#ifndef __CR_SERVICE_H__
#define __CR_SERVICE_H__
-#include "protobuf/rpc.pb-c.h"
+#include "protobuf/criu-rpc.pb-c.h"
#define CR_DEFAULT_SERVICE_ADDRESS "/tmp/criu_service.socket"
#define MAX_MSG_SIZE 1024
diff --git a/protobuf/Makefile b/protobuf/Makefile
index 9a90087..15ca1df 100644
--- a/protobuf/Makefile
+++ b/protobuf/Makefile
@@ -56,7 +56,7 @@ proto-obj-y += file-lock.o
proto-obj-y += rlimit.o
proto-obj-y += pagemap.o
proto-obj-y += siginfo.o
-proto-obj-y += rpc.o
+proto-obj-y += criu-rpc.o
proto := $(proto-obj-y:.o=)
proto-c := $(proto-obj-y:.o=.pb-c.c)
diff --git a/protobuf/criu-rpc.proto b/protobuf/criu-rpc.proto
new file mode 100644
index 0000000..66966a3
--- /dev/null
+++ b/protobuf/criu-rpc.proto
@@ -0,0 +1,29 @@
+message criu_dump_req {
+ optional int32 pid = 1; //if not set, will dump requesting process
+ optional bool leave_running = 2;
+ optional bool ext_unix_sk = 3;
+ optional bool tcp_established = 4;
+ optional bool evasive_devices = 5;
+ optional bool shell_job = 6;
+ optional bool file_locks = 7;
+ required int32 images_dir_fd = 8;
+ optional int32 log_level = 9 [default = 2];
+}
+
+message criu_dump_resp {
+ required bool success = 1;
+ optional bool restored = 2;
+}
+
+message criu_msg {
+ enum Type {
+ EMPTY = 0;
+ DUMPREQ = 1;
+ DUMPRESP = 2;
+ }
+
+ required Type type = 1;
+
+ optional criu_dump_req dump_req = 2;
+ optional criu_dump_resp dump_resp = 3;
+}
diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto
deleted file mode 100644
index 864e008..0000000
--- a/protobuf/rpc.proto
+++ /dev/null
@@ -1,29 +0,0 @@
-message criu_dump_req {
- required int32 pid = 1; //if not set, will dump requesting process
- required bool leave_running = 2;
- required bool ext_unix_sk = 3;
- required bool tcp_established = 4;
- required bool evasive_devices = 5;
- required bool shell_job = 6;
- required bool file_locks = 7;
- required int32 images_dir_fd = 8;
- required int32 log_level = 9 [default = 2];
-}
-
-message criu_dump_resp {
- required bool success = 1;
- required bool restored = 2;
-}
-
-message criu_msg {
- enum Type {
- EMPTY = 0;
- DUMPREQ = 1;
- DUMPRESP = 2;
- }
-
- required Type type = 1;
-
- optional criu_dump_req dump_req = 2;
- optional criu_dump_resp dump_resp = 3;
-}
diff --git a/sk-unix.c b/sk-unix.c
index 268e574..2213417 100644
--- a/sk-unix.c
+++ b/sk-unix.c
@@ -753,8 +753,9 @@ static int open_unixsk_standalone(struct unix_sk_info *ui)
int sks[2];
CriuDumpResp resp = CRIU_DUMP_RESP__INIT;
- resp.success = true;
- resp.restored = true;
+ resp.success = true;
+ resp.has_restored = true;
+ resp.restored = true;
if (socketpair(PF_UNIX, ui->ue->type, 0, sks)) {
pr_perror("Can't create socketpair");
More information about the CRIU
mailing list