Changes

Jump to navigation Jump to search
996 bytes added ,  17:51, 2 October 2013
m
no edit summary
Line 10: Line 10:  
required criu_req_type type = 1;
 
required criu_req_type type = 1;
   −
optional criu_dump_req dump = 2;
+
optional criu_opts opts = 2;
 
}
 
}
 
</pre>
 
</pre>
    
==== criu_req_type ====
 
==== criu_req_type ====
There is only 1 request/response type for now.
+
There are only 2 request/response types for now.
 
<pre>enum criu_req_type {
 
<pre>enum criu_req_type {
 
EMPTY = 0;
 
EMPTY = 0;
 
DUMP = 1;
 
DUMP = 1;
 +
RESTORE = 2;
 
}
 
}
 
</pre>
 
</pre>
   −
==== criu_dump_req ====
+
==== criu_opts ====
It is used to store dump options.
+
It is used to store options.
<pre>message criu_dump_req {
+
<pre>message criu_opts {
 
required int32 images_dir_fd = 1;
 
required int32 images_dir_fd = 1;
 
optional int32 pid = 2;
 
optional int32 pid = 2;
Line 35: Line 36:  
optional bool file_locks = 8;
 
optional bool file_locks = 8;
 
optional int32 log_level = 9 [default = 2];
 
optional int32 log_level = 9 [default = 2];
 +
optional string log_file = 10;
 
}</pre>
 
}</pre>
   −
If no pid is set, CRIU will dump client process by default.
+
If no pid is set and type is DUMP, 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.
 
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.
 
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.
+
Client must open directory for/with 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.
 
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".
+
The logic of setting request is the same as when setting options in console. Here is an example:
 +
<pre>#criu restore -D /path/to/imgs_dir -v4 -o restore.log</pre>
 +
is equal to:
 +
<pre>
 +
request.type = RESTORE;
 +
 
 +
request.opts.imgs_dir_fd = open("/path/to/imgs_dir")
 +
request.opts.log_level = 4
 +
request.opts.log_file = "restore.log"
 +
</pre>
    
=== Response ===
 
=== Response ===
Line 53: Line 64:     
optional criu_dump_resp dump = 3;
 
optional criu_dump_resp dump = 3;
 +
optional criu_restore_resp restore = 4;
 
}
 
}
 
</pre>
 
</pre>
 +
Field "success" reports result of processing request, while criu_***_resp store some request-specific information.
 
==== criu_dump_resp ====
 
==== criu_dump_resp ====
criu_dump_resp is used to store response from CRIU.
+
criu_dump_resp is used to store dump response from CRIU.
 
<pre>
 
<pre>
 
message criu_dump_resp {
 
message criu_dump_resp {
Line 65: Line 78:  
Field "restored" is set to "true" if process was restored.
 
Field "restored" is set to "true" if process was restored.
    +
==== criu_restore_resp ====
 +
<pre>
 +
message criu_restore_resp {
 +
required int32 pid = 1;
 +
}
 +
</pre>
 +
Field "pid" is set to the PID of the restored process.
 
== Run ==
 
== Run ==
 
=== Server ===
 
=== Server ===
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 criu_resp 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 criu_resp with set request-specific criu_***_resp field back.
 +
If CRIU gets unknown type of request, it will return criu_resp with type == EMPTY and success == false.
    
To launch service server run:
 
To launch service server run:
    
<pre>#criu service --address <socket_address></pre>
 
<pre>#criu service --address <socket_address></pre>
 +
 +
Note that you can set suid flag on criu and run it as non-root user, but it will be able to serve only tasks with the same user's uid.
    
If no address is set, "/tmp/criu_service.socket" is used by default.
 
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>).
+
You may also like to demonize server(-d), set log level(-v<N>) or set log file(-o <logname>). Server log file wouldn't be very informative for now, though.
 
For the full list of options, please run "criu -h".
 
For the full list of options, please run "criu -h".
  
85

edits

Navigation menu