| Line 4: |
Line 4: |
| | Well described here: [[Self_dump]]. | | Well described here: [[Self_dump]]. |
| | | | |
| − | == Protocol Buffers == | + | == CRIU request == |
| − | See protobuf/criu-rpc.proto.
| + | criu_req is used to wrap requests to provide compatibility with an older versions of rpc. |
| − | There are three types of structures for now: | + | Any request must be wrapped into criu_req to send to criu. |
| − | === Dump request === | + | |
| − | criu_dump_req is used to store dump options from client. | + | <pre> |
| | + | message criu_req { |
| | + | required criu_req_type type = 1; |
| | + | |
| | + | optional criu_dump_req dump = 2; |
| | + | } |
| | + | </pre> |
| | + | |
| | + | There is only 1 request/response type for now. |
| | + | <pre>enum criu_req_type { |
| | + | EMPTY = 0; |
| | + | DUMP = 1; |
| | + | } |
| | + | </pre> |
| | + | === CRIU dump request === |
| | + | criu_dump_req is used to store dump options. |
| | <pre>message criu_dump_req { | | <pre>message criu_dump_req { |
| − | optional int32 pid = 1; | + | required int32 images_dir_fd = 1; |
| − | optional bool leave_running = 2; | + | optional int32 pid = 2; |
| − | optional bool ext_unix_sk = 3; | + | |
| − | optional bool tcp_established = 4; | + | optional bool leave_running = 3; |
| − | optional bool evasive_devices = 5; | + | optional bool ext_unix_sk = 4; |
| − | optional bool shell_job = 6; | + | optional bool tcp_established = 5; |
| − | optional bool file_locks = 7; | + | optional bool evasive_devices = 6; |
| − | required int32 images_dir_fd = 8;
| + | optional bool shell_job = 7; |
| | + | optional bool file_locks = 8; |
| | optional int32 log_level = 9 [default = 2]; | | optional int32 log_level = 9 [default = 2]; |
| | }</pre> | | }</pre> |
| Line 30: |
Line 46: |
| | For other options description, please run "criu -h". | | For other options description, please run "criu -h". |
| | | | |
| − | === Dump response === | + | == CRIU response == |
| | + | criu_resp is a wrapper for responses. It consists of success bool field, response type field and response, that depends on sent request type. |
| | + | <pre>message criu_resp { |
| | + | required criu_req_type type = 1; |
| | + | required bool success = 2; |
| | + | |
| | + | optional criu_dump_resp dump = 3; |
| | + | } |
| | + | </pre> |
| | + | === CRIU dump response === |
| | criu_dump_resp is used to store response from CRIU. | | criu_dump_resp is used to store response from CRIU. |
| | <pre> | | <pre> |
| | message criu_dump_resp { | | message criu_dump_resp { |
| − | required bool success = 1;
| + | optional bool restored = 1; |
| − | optional bool restored = 2; | |
| | } | | } |
| | </pre> | | </pre> |
| | | | |
| | Field "restored" is set to "true" if process was restored. | | Field "restored" is set to "true" if process was restored. |
| − |
| |
| − | === CRIU msg ===
| |
| − | criu_msg is a wrapper for other two structures to pass them through the socket.
| |
| − | <pre>
| |
| − | 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;
| |
| − | }
| |
| − | </pre>
| |
| | | | |
| | == Server == | | == Server == |
| − | On a server side, CRIU creates SOCK_SEQPACKET Unix socket and listens for connections on it. After receiving criu_msg, CRIU processes it and do what is requested and sends response back. | + | On a server side, CRIU creates SOCK_SEQPACKET Unix socket and listens for connections on it. After receiving criu_req, CRIU processes it, do what is requested and sends response back. |
| | | | |
| | To launch service server run: | | To launch service server run: |
| Line 70: |
Line 77: |
| | | | |
| | == Client == | | == Client == |
| − | Client, in its turn, must connect to service socket, send criu_msg with request in it, and wait for a criu_msg with response. | + | Client, in its turn, must connect to service socket, send criu_msg with request in it, and wait for a criu_resp with response. |
| | You can find examples of client programs in C and Python in test/rpc/. | | You can find examples of client programs in C and Python in test/rpc/. |