Changes

2,500 bytes added ,  10:04, 15 September 2013
Created page with "CRIU-RPC is a remote procedure call (RPC) protocol which uses Google Protocol Buffers to encode its calls and SOCK_SEQPACKET Unix domain socket as a transport mechanism. == P..."
CRIU-RPC is a remote procedure call (RPC) protocol which uses Google Protocol Buffers to encode its calls and SOCK_SEQPACKET Unix domain socket as a transport mechanism.

== Preconditions ==
Well described here: [[Self_dump]].

== Protocol Buffers ==
See protobuf/criu-rpc.proto.
There are three types of structures for now:
=== Dump request ===
criu_dump_req is used to store dump options from client.
<pre>message criu_dump_req {
optional int32 pid = 1;
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];
}</pre>

If no pid is set, CRIU will dump client process by default.
Note: Whole tree <pid> must have the same uid, as a client, or client's uid must be == 0, otherwise CRIU won't dump nothing at all.

Only images_dir_fd is required, all other fields may not be set.
Client must open directory for images by himself and set images_dir_fd to it's fd.
CRIU will open /proc/<client's_pid>/fd/<images_dir_fd>, so it will work, if client is in another namespace.

For other options description, please, run "criu -h".

=== Dump response ===
criu_dump_resp is used to store response from CRIU.
<pre>
message criu_dump_resp {
required bool success = 1;
optional bool restored = 2;
}
</pre>

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 ==
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.

To launch service server run:

<pre>#criu service --address <socket_address></pre>

If no address is set, "/tmp/criu_service.socket" is used by default.
You may also like to demonize server(-d), set log level(-v<N>) or set log file(-o <logname>).
For the full list of options, please, run "criu -h".

== 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.
You can find examples of client programs in C and Python in test/rpc/.
85

edits