<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://criu.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Zeyady98</id>
	<title>CRIU - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://criu.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Zeyady98"/>
	<link rel="alternate" type="text/html" href="https://criu.org/Special:Contributions/Zeyady98"/>
	<updated>2026-05-13T14:10:44Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.6</generator>
	<entry>
		<id>https://criu.org/index.php?title=API_compliance&amp;diff=5167</id>
		<title>API compliance</title>
		<link rel="alternate" type="text/html" href="https://criu.org/index.php?title=API_compliance&amp;diff=5167"/>
		<updated>2021-08-08T12:46:41Z</updated>

		<summary type="html">&lt;p&gt;Zeyady98: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page brings together 3 APIs we have&lt;br /&gt;
&lt;br /&gt;
== Actions ==&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
! [[Usage|CLI]]&lt;br /&gt;
! [[RPC]]&lt;br /&gt;
! [[C_API|C library]]&lt;br /&gt;
! comment&lt;br /&gt;
|-&lt;br /&gt;
| dump || CRIU_REQ_TYPE__DUMP || criu_dump ||&lt;br /&gt;
|-&lt;br /&gt;
| pre-dump || CRIU_REQ_TYPE__PRE_DUMP || criu_dump_iters ||&lt;br /&gt;
|-&lt;br /&gt;
| restore || CRIU_REQ_TYPE__RESTORE || criu_restore, criu_restore_child ||&lt;br /&gt;
|-&lt;br /&gt;
| show || || || Deprecated. The [[CRIT]] tool should be used instead&lt;br /&gt;
|-&lt;br /&gt;
| check || CRIU_REQ_TYPE__CHECK || criu_check ||&lt;br /&gt;
|-&lt;br /&gt;
| cpuinfo dump || CRIU_REQ_TYPE__CPUINFO_DUMP || ||&lt;br /&gt;
|-&lt;br /&gt;
| cpuinfo check || CRIU_REQ_TYPE__CPUINFO_CHECK || ||&lt;br /&gt;
|-&lt;br /&gt;
| exec || || ||&lt;br /&gt;
|-&lt;br /&gt;
| page-server || CRIU_REQ_TYPE__PAGE_SERVER || ||&lt;br /&gt;
|-&lt;br /&gt;
| service || || ||&lt;br /&gt;
|-&lt;br /&gt;
| dedup || || ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Options ==&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
! [[Usage|CLI]]&lt;br /&gt;
! [[RPC]]&lt;br /&gt;
! [[C_API|C library]]&lt;br /&gt;
! comment&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;tree&amp;quot;			|| pid			|| criu_set_pid			||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;leave-stopped&amp;quot;	||			||				||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;leave-running&amp;quot;	|| leave_running	|| criu_set_leave_running	||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;restore-detached&amp;quot;	||			||				|| tasks always restore detached in RPC/lib&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;restore-sibling&amp;quot;      || rst_sibling          ||                              || For [[RPC]] -- in swrk mode only&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;daemon&amp;quot;		||			||				|| only for page server in RPC/lib&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;images-dir&amp;quot;		|| images_dir_fd	|| criu_set_images_dir_fd	||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;work-dir&amp;quot;		|| work_dir_fd		|| criu_set_work_dir_fd		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;log-file&amp;quot;		|| log_file		|| criu_set_log_file		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;root&amp;quot;			|| root			|| criu_set_root		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;ext-unix-sk&amp;quot;		|| ext_unix_sk		|| criu_set_ext_unix_sk		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;tcp-established&amp;quot;	|| tcp_established	|| criu_set_tcp_established	||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;log-pid&amp;quot;		||			||				||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;evasive-devices&amp;quot;	|| evasive_devices	|| criu_set_evasive_devices	||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;veth-pair&amp;quot;		|| veths		|| criu_add_veth_pair		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;action-script&amp;quot;	|| notify_scripts	|| criu_set_notify_cb		|| see article about [[action scripts]]&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;link-remap&amp;quot;		|| link_remap		|| criu_set_link_remap		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;shell-job&amp;quot;		|| shell_job		|| criu_set_shell_job		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;file-locks&amp;quot;		|| file_locks		|| criu_set_file_locks		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;page-server&amp;quot;		|| ps			||				||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;address&amp;quot;		|| ps.address		||				||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;port&amp;quot;			|| ps.port		||				||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;pidfile&amp;quot;		|| ps.pid		||				|| page-server pid returned for RPC&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;prev-images-dir&amp;quot;	|| parent_img		|| criu_set_parent_images	||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;ms&amp;quot;			||			||				|| &amp;quot;Check&amp;quot; only&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;feature&amp;quot;              ||                      ||                              || &amp;quot;Check&amp;quot; only&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;track-mem&amp;quot;		|| track_mem		|| criu_set_track_mem		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;auto-dedup&amp;quot;		|| auto_dedup		|| criu_set_auto_dedup		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;libdir&amp;quot;		||			||				|| not clear how to do it in RPC&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;cpu-cap&amp;quot;		|| cpu_cap		|| criu_set_cpu_cap		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;force-irmap&amp;quot;		|| force_irmap		|| criu_set_force_irmap		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;exec-cmd&amp;quot;		|| exec_cmd		|| criu_set_exec_cmd		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;manage-cgroups&amp;quot;       || manage_cgroups       || criu_set_manage_cgroups      ||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;cgroup-root&amp;quot;          || cg_root              || criu_add_cg_root             ||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;inherit-fd&amp;quot;           || inherit_fd           ||                              || For [[RPC]] -- in swrk mode only&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;skip-mnt&amp;quot;             ||                      ||                              ||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;ext-mount-map&amp;quot;	|| ext_mnt/auto_ext_mnt	|| criu_add_ext_mount/criu_set_auto_ext_mount		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;enable-fs&amp;quot;            ||                      ||                              ||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;enable-external-sharing&amp;quot; || ext_sharing || criu_set_ext_sharing ||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;enable-external-masters&amp;quot; || ext_masters || criu_set_ext_masters ||&lt;br /&gt;
|-&lt;br /&gt;
|               	|| pidfd_store_sk	|| criu_set_pidfd_store_sk	|| see article about [[Pidfd store]]&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;network-lock&amp;quot;		|| network_lock		|| criu_set_network_lock	||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;help&amp;quot;			||			||				||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;version&amp;quot;		||			||				||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;pid&amp;quot;			||			||				|| obsoleted&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;namespaces&amp;quot;		||			||				|| obsoleted&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;close&amp;quot;		||			||				|| hidden and obsoleted&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;contents&amp;quot;		||			||				|| deprecated (for show)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;file&amp;quot;			||			||				|| deprecated (for show)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;fields&amp;quot;		||			||				|| deprecated (for show)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category: API]]&lt;br /&gt;
[[Category: Outdated]]&lt;/div&gt;</summary>
		<author><name>Zeyady98</name></author>
	</entry>
	<entry>
		<id>https://criu.org/index.php?title=TCP_connection&amp;diff=5166</id>
		<title>TCP connection</title>
		<link rel="alternate" type="text/html" href="https://criu.org/index.php?title=TCP_connection&amp;diff=5166"/>
		<updated>2021-08-08T12:43:21Z</updated>

		<summary type="html">&lt;p&gt;Zeyady98: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes how we handle established TCP connections.&lt;br /&gt;
&lt;br /&gt;
== TCP repair mode in kernel ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TCP_REPAIR&amp;lt;/code&amp;gt; socket option was added to the kernel 3.5 to help with C/R for TCP sockets.&lt;br /&gt;
&lt;br /&gt;
When this option is used, the socket is switched into a special mode, in which any action performed on it&lt;br /&gt;
does not result in anything defined by an appropriate protocol actions, but rather directly puts the socket&lt;br /&gt;
into the state that the socket is expected to be in at the end of a successfully finished operation.&lt;br /&gt;
&lt;br /&gt;
For example, calling &amp;lt;code&amp;gt;connect()&amp;lt;/code&amp;gt; on a repaired socket just changes its state to &amp;lt;code&amp;gt;ESTABLISHED&amp;lt;/code&amp;gt;,&lt;br /&gt;
with the peer address set as requested.&lt;br /&gt;
The &amp;lt;code&amp;gt;bind()&amp;lt;/code&amp;gt; call forcibly binds the socket to a given address (ignoring any potential conflicts).&lt;br /&gt;
The &amp;lt;code&amp;gt;close()&amp;lt;/code&amp;gt; call closes the socket without any transient &amp;lt;code&amp;gt;FIN_WAIT&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;TIME_WAIT&amp;lt;/code&amp;gt;/etc states,&lt;br /&gt;
socket is silently killed.&lt;br /&gt;
&lt;br /&gt;
=== Sequences ===&lt;br /&gt;
&lt;br /&gt;
To restore the connection properly, bind() and connect() is not enough. One also needs to restore the&lt;br /&gt;
TCP sequence numbers. To do so, the &amp;lt;code&amp;gt;TCP_REPAIR_QUEUE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;TCP_QUEUE_SEQ&amp;lt;/code&amp;gt; options were introduced.&lt;br /&gt;
&lt;br /&gt;
The former one selects which queue (input or output) will be repaired and the latter gets/sets the sequence. Note&lt;br /&gt;
setting the sequence is only possible on CLOSE-d socket.&lt;br /&gt;
&lt;br /&gt;
=== Packets in queue ===&lt;br /&gt;
&lt;br /&gt;
When set the queue to repair as described above, one can call recv or send syscalls on a repaired socket. Both calls&lt;br /&gt;
result on peeking or poking data from/to the respective queue. This sounds funny, but yes, for repaired socket one&lt;br /&gt;
can receve the outgoing and send the incoming queues. Using the &amp;lt;code&amp;gt;MSG_PEEK&amp;lt;/code&amp;gt; flag for &amp;lt;code&amp;gt;recv()&amp;lt;/code&amp;gt; is required.&lt;br /&gt;
&lt;br /&gt;
=== Options ===&lt;br /&gt;
&lt;br /&gt;
There are 4 options that are negotiated by the socket at the connecting stage. These are&lt;br /&gt;
&lt;br /&gt;
* mss_clamp -- the maximum size of the segment peer is ready to accept&lt;br /&gt;
* snd _scale -- the scale factor for a window&lt;br /&gt;
* sack -- whether selective acks are permitted or not&lt;br /&gt;
* tstamp -- whether timestamps on packets are supported&lt;br /&gt;
&lt;br /&gt;
All four can be read with &amp;lt;code&amp;gt;getsockopt()&amp;lt;/code&amp;gt; calls to a socket and in order to restore them the &amp;lt;code&amp;gt;TCP_REPAIR_OPTIONS&amp;lt;/code&amp;gt; sockoption is introduced.&lt;br /&gt;
&lt;br /&gt;
== Timestamp ==&lt;br /&gt;
&amp;quot;The sender's timestamp clock is used as a source of monotonic non-decreasing values to stamp the segments&amp;quot;(rfc7323). The Linux kernel uses the jiffies counter as the tcp timestamp.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;#define tcp_time_stamp          ((__u32)(jiffies))&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We add the &amp;lt;code&amp;gt;TCP_TIMESTAMP&amp;lt;/code&amp;gt; options to be able to compensate a difference between jiffies counters, when a connection is migrated on another host. When a connection is dumped, criu calls &amp;lt;code&amp;gt;getsockopt(TCP_TIMESTAMP)&amp;lt;/code&amp;gt; to get a current timestamp, then on restore it calls &amp;lt;code&amp;gt;setsockopt(TCP_TIMESTAMP)&amp;lt;/code&amp;gt; to set this timestamp as a starting point.&lt;br /&gt;
&lt;br /&gt;
== Checkpoint and restore TCP connection ==&lt;br /&gt;
&lt;br /&gt;
With the above sockoptions dumping and restoring TCP connection becomes possible. The criu just reads the socket&lt;br /&gt;
state and restores it back letting the protocol resurrect the data sequence.&lt;br /&gt;
&lt;br /&gt;
One thing to note here — while the socket is closed between dump and restore the connection should be &amp;quot;locked&amp;quot;, i.e.&lt;br /&gt;
no packets from peer should enter the stack, otherwise the RST will be sent by a kernel. In order to do so a simple&lt;br /&gt;
netfilter rule is configured that drops all the packets from peer to a socket we're dealing with. This rule sits&lt;br /&gt;
in the host netfilter tables after the criu dump command finishes and it should be there when you issue the&lt;br /&gt;
criu restore one. The locking method can be specified using the [https://criu.org/index.php?title=CLI/opt/--network-lock &amp;lt;code&amp;gt;--network-lock&amp;lt;/code&amp;gt;]option.&lt;br /&gt;
&lt;br /&gt;
Another thing to note is -- on restore there should be available the IP address, that was used by the connection.&lt;br /&gt;
This is automatically so if restore happens on the same box as dump. In case of hand-made live migration the&lt;br /&gt;
IP address should be copied too.&lt;br /&gt;
&lt;br /&gt;
That said, the command line option &amp;lt;code&amp;gt;--tcp-established&amp;lt;/code&amp;gt; should be used when calling criu to explicitly state, that the&lt;br /&gt;
caller is aware of this &amp;quot;transitional&amp;quot; state of the netfilter.&lt;br /&gt;
&lt;br /&gt;
In case the target process lives in NET namespace the connection locking happens the other way. Instead of&lt;br /&gt;
per-connection iptables rules the &amp;quot;network-lock&amp;quot;/&amp;quot;network-unlock&amp;quot; [[action scripts]] are called so that the user&lt;br /&gt;
could isolate the whole netns from network. Typically this is done by downing the respective veth pair end.&lt;br /&gt;
&lt;br /&gt;
== States ==&lt;br /&gt;
=== TCP_SYN_SENT ===&lt;br /&gt;
There is only one difference with TCP_ESTABLISHED, we have to restore a socket and disable the repair mode before calling &amp;lt;code&amp;gt;connect()&amp;lt;/code&amp;gt;. The kernel will send a one syn-sent packet with the same initial sequence number and sets the TCP_SYN_SENT state for the socket.&lt;br /&gt;
&lt;br /&gt;
=== Half-closed sockets ===&lt;br /&gt;
A socket is half-closed when it sent or received a fin packet. These sockets are in one for these states: TCP_FIN_WAIT1, TCP_FIN_WAIT2, TCP_CLOSING, TCP_LAST_ACL, TCP_CLOSE_WAIT. To restore these states, we restore a socket into the TCP_ESTABLISHED state and then we call shutfown(SHUT_WR), if a socket has sent a fin packet and we send a fake fin packet, if a socket has received it before. For example, if we want to restore the TCP_FIN_WAIT1 state, we have to call shutfown(SHUT_WR) and we can send a fake ack to the fin packet to restore the TCP_FIN_WAIT2 state.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Simple TCP pair]]&lt;br /&gt;
* [[TCP repair TODO]]&lt;br /&gt;
* [[CLI/opt/--tcp-close|Dropping the connection]]&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* http://lwn.net/Articles/495304/&lt;br /&gt;
&lt;br /&gt;
[[Category:Under the hood]]&lt;br /&gt;
[[Category:Sockets]]&lt;br /&gt;
[[Category: Editor help needed]]&lt;/div&gt;</summary>
		<author><name>Zeyady98</name></author>
	</entry>
	<entry>
		<id>https://criu.org/index.php?title=CLI/opt/--network-lock&amp;diff=5165</id>
		<title>CLI/opt/--network-lock</title>
		<link rel="alternate" type="text/html" href="https://criu.org/index.php?title=CLI/opt/--network-lock&amp;diff=5165"/>
		<updated>2021-08-08T12:37:39Z</updated>

		<summary type="html">&lt;p&gt;Zeyady98: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Set the method to be used for network locking/unlocking. Locking is done to ensure that tcp packets are dropped between dump and restore. This is done to avoid the kernel sending RST when a packet arrives destined for the dumped process.&lt;br /&gt;
&lt;br /&gt;
Currently two methods are available:&lt;br /&gt;
: - &amp;lt;b&amp;gt;iptables&amp;lt;/b&amp;gt;: Use iptables rules to drop the packets. This is the default if 'method' is not specified.&lt;br /&gt;
: - &amp;lt;b&amp;gt;nftables&amp;lt;/b&amp;gt;: Use nftables rules to drop the packets.&lt;br /&gt;
&lt;br /&gt;
For more information: [https://www.criu.org/TCP_connection#Checkpoint_and_restore_TCP_connection TCP connection]&lt;br /&gt;
&lt;br /&gt;
[[Category:CLI]]&lt;/div&gt;</summary>
		<author><name>Zeyady98</name></author>
	</entry>
	<entry>
		<id>https://criu.org/index.php?title=CLI/opt/--network-lock&amp;diff=5164</id>
		<title>CLI/opt/--network-lock</title>
		<link rel="alternate" type="text/html" href="https://criu.org/index.php?title=CLI/opt/--network-lock&amp;diff=5164"/>
		<updated>2021-08-08T12:35:24Z</updated>

		<summary type="html">&lt;p&gt;Zeyady98: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Set the method to be used for network locking/unlocking. Locking is done to ensure that tcp packets are dropped between dump and restore. This is done to avoid the kernel sending RST when a packet arrives destined for the dumped process.&lt;br /&gt;
&lt;br /&gt;
Currently two methods are available:&lt;br /&gt;
: - &amp;lt;b&amp;gt;iptables&amp;lt;/b&amp;gt;: Use iptables rules to drop the packets. This is the default if 'method' is not specified.&lt;br /&gt;
: - &amp;lt;b&amp;gt;nftables&amp;lt;/b&amp;gt;: Use nftables rules to drop the packets.&lt;br /&gt;
&lt;br /&gt;
[[TCP connection]]&lt;br /&gt;
[[Category:CLI]]&lt;/div&gt;</summary>
		<author><name>Zeyady98</name></author>
	</entry>
	<entry>
		<id>https://criu.org/index.php?title=CLI/opt/--network-lock&amp;diff=5163</id>
		<title>CLI/opt/--network-lock</title>
		<link rel="alternate" type="text/html" href="https://criu.org/index.php?title=CLI/opt/--network-lock&amp;diff=5163"/>
		<updated>2021-08-08T12:34:24Z</updated>

		<summary type="html">&lt;p&gt;Zeyady98: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Set the method to be used for network locking/unlocking. Locking is done to ensure that tcp packets are dropped between dump and restore. This is done to avoid the kernel sending RST when a packet arrives destined for the dumped process.&lt;br /&gt;
&lt;br /&gt;
Currently two methods are available:&lt;br /&gt;
: - &amp;lt;b&amp;gt;iptables&amp;lt;/b&amp;gt;: Use iptables rules to drop the packets. This is the default if 'method' is not specified.&lt;br /&gt;
: - &amp;lt;b&amp;gt;nftables&amp;lt;/b&amp;gt;: Use nftables rules to drop the packets.&lt;br /&gt;
&lt;br /&gt;
[[Category:TCP connection]]&lt;br /&gt;
[[Category:CLI]]&lt;/div&gt;</summary>
		<author><name>Zeyady98</name></author>
	</entry>
	<entry>
		<id>https://criu.org/index.php?title=CLI/opt/--network-lock&amp;diff=5162</id>
		<title>CLI/opt/--network-lock</title>
		<link rel="alternate" type="text/html" href="https://criu.org/index.php?title=CLI/opt/--network-lock&amp;diff=5162"/>
		<updated>2021-08-08T12:33:37Z</updated>

		<summary type="html">&lt;p&gt;Zeyady98: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Set the method to be used for network locking/unlocking. Locking is done to ensure that tcp packets are dropped between dump and restore. This is done to avoid the kernel sending RST when a packet arrives destined for the dumped process.&lt;br /&gt;
&lt;br /&gt;
Currently two methods are available:&lt;br /&gt;
: - &amp;lt;b&amp;gt;iptables&amp;lt;/b&amp;gt;: Use iptables rules to drop the packets. This is the default if 'method' is not specified.&lt;br /&gt;
: - &amp;lt;b&amp;gt;nftables&amp;lt;/b&amp;gt;: Use nftables rules to drop the packets.&lt;br /&gt;
&lt;br /&gt;
[[Category:TCP_connection]]&lt;br /&gt;
[[Category:CLI]]&lt;/div&gt;</summary>
		<author><name>Zeyady98</name></author>
	</entry>
	<entry>
		<id>https://criu.org/index.php?title=API_compliance&amp;diff=5160</id>
		<title>API compliance</title>
		<link rel="alternate" type="text/html" href="https://criu.org/index.php?title=API_compliance&amp;diff=5160"/>
		<updated>2021-06-24T11:02:17Z</updated>

		<summary type="html">&lt;p&gt;Zeyady98: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page brings together 3 APIs we have&lt;br /&gt;
&lt;br /&gt;
== Actions ==&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
! [[Usage|CLI]]&lt;br /&gt;
! [[RPC]]&lt;br /&gt;
! [[C_API|C library]]&lt;br /&gt;
! comment&lt;br /&gt;
|-&lt;br /&gt;
| dump || CRIU_REQ_TYPE__DUMP || criu_dump ||&lt;br /&gt;
|-&lt;br /&gt;
| pre-dump || CRIU_REQ_TYPE__PRE_DUMP || criu_dump_iters ||&lt;br /&gt;
|-&lt;br /&gt;
| restore || CRIU_REQ_TYPE__RESTORE || criu_restore, criu_restore_child ||&lt;br /&gt;
|-&lt;br /&gt;
| show || || || Deprecated. The [[CRIT]] tool should be used instead&lt;br /&gt;
|-&lt;br /&gt;
| check || CRIU_REQ_TYPE__CHECK || criu_check ||&lt;br /&gt;
|-&lt;br /&gt;
| cpuinfo dump || CRIU_REQ_TYPE__CPUINFO_DUMP || ||&lt;br /&gt;
|-&lt;br /&gt;
| cpuinfo check || CRIU_REQ_TYPE__CPUINFO_CHECK || ||&lt;br /&gt;
|-&lt;br /&gt;
| exec || || ||&lt;br /&gt;
|-&lt;br /&gt;
| page-server || CRIU_REQ_TYPE__PAGE_SERVER || ||&lt;br /&gt;
|-&lt;br /&gt;
| service || || ||&lt;br /&gt;
|-&lt;br /&gt;
| dedup || || ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Options ==&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
! [[Usage|CLI]]&lt;br /&gt;
! [[RPC]]&lt;br /&gt;
! [[C_API|C library]]&lt;br /&gt;
! comment&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;tree&amp;quot;			|| pid			|| criu_set_pid			||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;leave-stopped&amp;quot;	||			||				||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;leave-running&amp;quot;	|| leave_running	|| criu_set_leave_running	||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;restore-detached&amp;quot;	||			||				|| tasks always restore detached in RPC/lib&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;restore-sibling&amp;quot;      || rst_sibling          ||                              || For [[RPC]] -- in swrk mode only&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;daemon&amp;quot;		||			||				|| only for page server in RPC/lib&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;images-dir&amp;quot;		|| images_dir_fd	|| criu_set_images_dir_fd	||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;work-dir&amp;quot;		|| work_dir_fd		|| criu_set_work_dir_fd		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;log-file&amp;quot;		|| log_file		|| criu_set_log_file		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;root&amp;quot;			|| root			|| criu_set_root		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;ext-unix-sk&amp;quot;		|| ext_unix_sk		|| criu_set_ext_unix_sk		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;tcp-established&amp;quot;	|| tcp_established	|| criu_set_tcp_established	||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;log-pid&amp;quot;		||			||				||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;evasive-devices&amp;quot;	|| evasive_devices	|| criu_set_evasive_devices	||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;veth-pair&amp;quot;		|| veths		|| criu_add_veth_pair		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;action-script&amp;quot;	|| notify_scripts	|| criu_set_notify_cb		|| see article about [[action scripts]]&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;link-remap&amp;quot;		|| link_remap		|| criu_set_link_remap		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;shell-job&amp;quot;		|| shell_job		|| criu_set_shell_job		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;file-locks&amp;quot;		|| file_locks		|| criu_set_file_locks		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;page-server&amp;quot;		|| ps			||				||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;address&amp;quot;		|| ps.address		||				||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;port&amp;quot;			|| ps.port		||				||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;pidfile&amp;quot;		|| ps.pid		||				|| page-server pid returned for RPC&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;prev-images-dir&amp;quot;	|| parent_img		|| criu_set_parent_images	||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;ms&amp;quot;			||			||				|| &amp;quot;Check&amp;quot; only&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;feature&amp;quot;              ||                      ||                              || &amp;quot;Check&amp;quot; only&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;track-mem&amp;quot;		|| track_mem		|| criu_set_track_mem		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;auto-dedup&amp;quot;		|| auto_dedup		|| criu_set_auto_dedup		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;libdir&amp;quot;		||			||				|| not clear how to do it in RPC&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;cpu-cap&amp;quot;		|| cpu_cap		|| criu_set_cpu_cap		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;force-irmap&amp;quot;		|| force_irmap		|| criu_set_force_irmap		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;exec-cmd&amp;quot;		|| exec_cmd		|| criu_set_exec_cmd		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;manage-cgroups&amp;quot;       || manage_cgroups       || criu_set_manage_cgroups      ||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;cgroup-root&amp;quot;          || cg_root              || criu_add_cg_root             ||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;inherit-fd&amp;quot;           || inherit_fd           ||                              || For [[RPC]] -- in swrk mode only&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;skip-mnt&amp;quot;             ||                      ||                              ||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;ext-mount-map&amp;quot;	|| ext_mnt/auto_ext_mnt	|| criu_add_ext_mount/criu_set_auto_ext_mount		||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;enable-fs&amp;quot;            ||                      ||                              ||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;enable-external-sharing&amp;quot; || ext_sharing || criu_set_ext_sharing ||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;enable-external-masters&amp;quot; || ext_masters || criu_set_ext_masters ||&lt;br /&gt;
|-&lt;br /&gt;
|               	|| pidfd_store_sk	|| criu_set_pidfd_store_sk	|| see article about [[Pidfd store]]&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;help&amp;quot;			||			||				||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;version&amp;quot;		||			||				||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;pid&amp;quot;			||			||				|| obsoleted&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;namespaces&amp;quot;		||			||				|| obsoleted&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;close&amp;quot;		||			||				|| hidden and obsoleted&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;contents&amp;quot;		||			||				|| deprecated (for show)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;file&amp;quot;			||			||				|| deprecated (for show)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;fields&amp;quot;		||			||				|| deprecated (for show)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category: API]]&lt;br /&gt;
[[Category: Outdated]]&lt;/div&gt;</summary>
		<author><name>Zeyady98</name></author>
	</entry>
	<entry>
		<id>https://criu.org/index.php?title=Pidfd_store&amp;diff=5159</id>
		<title>Pidfd store</title>
		<link rel="alternate" type="text/html" href="https://criu.org/index.php?title=Pidfd_store&amp;diff=5159"/>
		<updated>2021-06-24T10:41:28Z</updated>

		<summary type="html">&lt;p&gt;Zeyady98: Created page with &amp;quot;Pidfd store increases the reliability of pid reuse detection during pre-dumps/dumps using task pidfd instead of task creation time.  It is only supported for RPC and the C lib...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Pidfd store increases the reliability of pid reuse detection during pre-dumps/dumps using task pidfd instead of task creation time.&lt;br /&gt;
&lt;br /&gt;
It is only supported for RPC and the C library.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
A connectionless unix socket is passed to CRIU during each pre-dump/dump through&lt;br /&gt;
the RPC option &amp;lt;code&amp;gt;pidfd_store_sk&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;criu_set_pidfd_store_sk&amp;lt;/code&amp;gt; routine in the the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;NOTE&amp;lt;/b&amp;gt;: This is targeted at migration tools like P.Haul, because the passed socket must be kept alive throughout all pre-dump/dump iterations.&lt;br /&gt;
&lt;br /&gt;
== Feature check ==&lt;br /&gt;
&lt;br /&gt;
This feature requires &amp;lt;code&amp;gt;pidfd_open&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;pidfd_getfd&amp;lt;/code&amp;gt; syscalls.&lt;br /&gt;
Support could be checked with:&lt;br /&gt;
: CLI: &amp;lt;code&amp;gt;criu check --feature pidfd_store&amp;lt;/code&amp;gt;.&lt;br /&gt;
: RPC: &amp;lt;code&amp;gt;CRIU_REQ_TYPE__FEATURE_CHECK&amp;lt;/code&amp;gt; and set &amp;lt;code&amp;gt;pidfd_store&amp;lt;/code&amp;gt; to true in the &amp;quot;features&amp;quot; field of the request&lt;br /&gt;
&lt;br /&gt;
== How it works ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;pidfd_store_sk&amp;lt;/code&amp;gt; is used as a queue for task pidfds. CRIU sends tasks pidfds to this socket and receives them in the next pre-dump/dump iteration. Those pidfds could then be used to check whether the task is still alive, otherwise it is a case of pid reuse and CRIU should make a full page dump.&lt;br /&gt;
&lt;br /&gt;
[[Category:P.Haul]]&lt;br /&gt;
[[Category:Under the hood]]&lt;br /&gt;
[[Category:API]]&lt;/div&gt;</summary>
		<author><name>Zeyady98</name></author>
	</entry>
	<entry>
		<id>https://criu.org/index.php?title=RPC&amp;diff=5048</id>
		<title>RPC</title>
		<link rel="alternate" type="text/html" href="https://criu.org/index.php?title=RPC&amp;diff=5048"/>
		<updated>2020-04-10T22:09:08Z</updated>

		<summary type="html">&lt;p&gt;Zeyady98: /* Client */ update RPC examples path&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CRIU-RPC is a remote procedure call (RPC) protocol which uses Google Protocol Buffers to encode its calls. The requests are served by CRIU when either launched in so called &amp;quot;swrk&amp;quot; mode or by a service started with the &amp;lt;code&amp;gt;criu service&amp;lt;/code&amp;gt; command. It uses a &amp;lt;code&amp;gt;SEQPACKET&amp;lt;/code&amp;gt; Unix domain socket for transport. In case of a standalone service it listens at &amp;lt;code&amp;gt;/var/run/criu-service.socket&amp;lt;/code&amp;gt; as a transport.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;criu_req&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;criu_resp&amp;lt;/code&amp;gt; are two main messages for requests/responses. They are to be used for transferring messages and needed to provide compatibility with an older versions of rpc. Field type in them ''must'' be set accordingly to type of request/response that is stored. Types of request/response are defined in &amp;lt;code&amp;gt;enum criu_req_type&amp;lt;/code&amp;gt;. See the [[API compliance]] page for information what each option might mean.&lt;br /&gt;
&lt;br /&gt;
== Protocol ==&lt;br /&gt;
&lt;br /&gt;
The protocol is simple: client sends a &amp;lt;code&amp;gt;criu_req&amp;lt;/code&amp;gt; message to server, server responds back with &amp;lt;code&amp;gt;criu_resp&amp;lt;/code&amp;gt;. In most of the cases the socket gets closed, but there are three exceptions from this rule, see below.&lt;br /&gt;
&lt;br /&gt;
== Request ==&lt;br /&gt;
&lt;br /&gt;
This is the header of the request. It defines the operation requested and options.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
message criu_req {&lt;br /&gt;
	required criu_req_type type	= 1;&lt;br /&gt;
	optional criu_opts opts		= 2;&lt;br /&gt;
	optional notify_success         = 3; /* see Notifications below */&lt;br /&gt;
	optional keep_open              = 4; /* for multi-req, below */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Currently, there are a few request/response types:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
enum criu_req_type {&lt;br /&gt;
	EMPTY		= 0;&lt;br /&gt;
	DUMP		= 1; /* criu dump */&lt;br /&gt;
	RESTORE		= 2; /* criu restore */&lt;br /&gt;
	CHECK		= 3; /* criu check */&lt;br /&gt;
	PRE_DUMP	= 4; /* criu pre-dump */&lt;br /&gt;
	PAGE_SERVER	= 5; /* criu page-server */&lt;br /&gt;
	NOTIFY          = 6; /* see Notifications below */&lt;br /&gt;
	CPUINFO_DUMP	= 7; /* criu cpuinfo dump */&lt;br /&gt;
	CPUINFO_CHECK	= 8; /* criu cpuinfo check */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following options are available:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
message criu_opts {&lt;br /&gt;
	required int32			images_dir_fd	= 1;&lt;br /&gt;
	optional int32			pid		= 2; /* if not set on dump, will dump requesting process */&lt;br /&gt;
&lt;br /&gt;
	optional bool			leave_running	= 3;&lt;br /&gt;
	optional bool			ext_unix_sk	= 4;&lt;br /&gt;
	optional bool			tcp_established	= 5;&lt;br /&gt;
	optional bool			evasive_devices	= 6;&lt;br /&gt;
	optional bool			shell_job	= 7;&lt;br /&gt;
	optional bool			file_locks	= 8;&lt;br /&gt;
	optional int32			log_level	= 9 [default = 2];&lt;br /&gt;
	optional string			log_file	= 10; /* No subdirs are allowed. Consider using work-dir */&lt;br /&gt;
&lt;br /&gt;
	optional criu_page_server_info	ps		= 11;&lt;br /&gt;
&lt;br /&gt;
	optional bool			notify_scripts	= 12;&lt;br /&gt;
&lt;br /&gt;
	optional string			root		= 13;&lt;br /&gt;
	optional string			parent_img	= 14;&lt;br /&gt;
	optional bool			track_mem	= 15;&lt;br /&gt;
	optional bool			auto_dedup	= 16;&lt;br /&gt;
&lt;br /&gt;
	optional int32			work_dir_fd	= 17;&lt;br /&gt;
	optional bool			link_remap	= 18;&lt;br /&gt;
	repeated criu_veth_pair		veths		= 19;&lt;br /&gt;
&lt;br /&gt;
	optional uint32			cpu_cap		= 20 [default = 0xffffffff];&lt;br /&gt;
	optional bool			force_irmap	= 21;&lt;br /&gt;
	repeated string			exec_cmd	= 22;&lt;br /&gt;
&lt;br /&gt;
	repeated ext_mount_map		ext_mnt		= 23;&lt;br /&gt;
	optional bool			manage_cgroups	= 24;&lt;br /&gt;
	repeated cgroup_root		cg_root		= 25;&lt;br /&gt;
&lt;br /&gt;
	optional bool			rst_sibling	= 26; /* swrk only */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Comments and examples ===&lt;br /&gt;
&lt;br /&gt;
* If no &amp;lt;code&amp;gt;pid&amp;lt;/code&amp;gt; is set and type is &amp;lt;code&amp;gt;DUMP&amp;lt;/code&amp;gt;, CRIU will dump client process by default.&lt;br /&gt;
* All processes in the subtree starting with &amp;lt;code&amp;gt;''pid''&amp;lt;/code&amp;gt; must have the same uid, as a client, or client's uid must be root (uid == 0), otherwise CRIU will return an error.&lt;br /&gt;
* Only the &amp;lt;code&amp;gt;images_dir_fd&amp;lt;/code&amp;gt; is required, all other fields are optional. Client must open directory for/with images by itself and set &amp;lt;code&amp;gt;images_dir_fd&amp;lt;/code&amp;gt; to the opened &amp;lt;code&amp;gt;fd&amp;lt;/code&amp;gt;. CRIU will open &amp;lt;code&amp;gt;/proc/''client_pid''/fd/''images_dir_fd''&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The logic of setting request is the same as when setting options in console.&lt;br /&gt;
&lt;br /&gt;
Here is an example:&lt;br /&gt;
&lt;br /&gt;
 # criu restore -D /path/to/imgs_dir -v4 -o restore.log&lt;br /&gt;
&lt;br /&gt;
This is equal to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
request.type = RESTORE;&lt;br /&gt;
&lt;br /&gt;
request.opts.imgs_dir_fd	= open(&amp;quot;/path/to/imgs_dir&amp;quot;)&lt;br /&gt;
request.opts.log_level		= 4&lt;br /&gt;
request.opts.log_file		= &amp;quot;restore.log&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sub-messages for options ===&lt;br /&gt;
&lt;br /&gt;
==== Info about page-server ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
message criu_page_server_info {&lt;br /&gt;
	optional string		address	= 1; /* bind address -- if not set 0.0.0.0 is used */&lt;br /&gt;
	optional int32		port	= 2; /* bind port -- if not set on request, autobind is used and port is returned in response */&lt;br /&gt;
	optional int32		pid	= 3; /* page-server pid -- returned in response */&lt;br /&gt;
	optional int32		fd	= 4; /* could be used to inherit fd by page-server */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
message criu_veth_pair {&lt;br /&gt;
	required string		if_in	= 1; /* inside veth device name */&lt;br /&gt;
	required string		if_out	= 2; /* outside veth device name */&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Info about veth mappings (&amp;lt;code&amp;gt;--ext-mount-map&amp;lt;/code&amp;gt; analogue) ====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
message ext_mount_map {&lt;br /&gt;
	required string		key	= 1;&lt;br /&gt;
	required string		val	= 2;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Specifying where cgroup root should be (&amp;lt;code&amp;gt;--cgroup-root&amp;lt;/code&amp;gt; analogue) ====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
message cgroup_root {&lt;br /&gt;
	optional string		ctrl	= 1;&lt;br /&gt;
	required string		path	= 2;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Response ==&lt;br /&gt;
&lt;br /&gt;
This message is sent after (un)successful execution of the request.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
message criu_resp {&lt;br /&gt;
	required criu_req_type		type		= 1;&lt;br /&gt;
	required bool			success		= 2;&lt;br /&gt;
&lt;br /&gt;
	optional criu_dump_resp		dump		= 3;&lt;br /&gt;
	optional criu_restore_resp	restore		= 4;&lt;br /&gt;
	optional criu_notify		notify		= 5;&lt;br /&gt;
	optional criu_page_server_info	ps		= 6;&lt;br /&gt;
&lt;br /&gt;
        optional int32			cr_errno	= 7;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The field &amp;lt;code&amp;gt;success&amp;lt;/code&amp;gt; reports result of processing request, while &amp;lt;code&amp;gt;criu_***_resp&amp;lt;/code&amp;gt; store some request-specific information. The response type is set to the corresponding request type or to &amp;lt;code&amp;gt;EMPTY&amp;lt;/code&amp;gt; to report a &amp;quot;generic&amp;quot; error. If &amp;lt;code&amp;gt;success == false&amp;lt;/code&amp;gt;, one should check &amp;lt;code&amp;gt;cr_errno&amp;lt;/code&amp;gt; field to get a more detailed error code (see [https://github.com/xemul/criu/blob/master/include/cr-errno.h#L8 include/cr-errno.h]).&lt;br /&gt;
&lt;br /&gt;
==== The criu_dump_resp is used to store response from DUMP request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
message criu_dump_resp {&lt;br /&gt;
	optional bool restored		= 1;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This message can be sent twice — one time for the process that calls DUMP, and  another time for the same process again, in case it requested a self-dump. In the latter case the ''restored'' field would be true.&lt;br /&gt;
&lt;br /&gt;
==== The response on RESTORE request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
message criu_restore_resp {&lt;br /&gt;
	required int32 pid		= 1;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;pid&amp;lt;/code&amp;gt; field is set to the PID of the newly restored process.&lt;br /&gt;
&lt;br /&gt;
==== Info about page server ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;criu_page_server_info&amp;lt;/code&amp;gt; from requests will be sent back on &amp;lt;code&amp;gt;PAGE_SERVER&amp;lt;/code&amp;gt; request. The &amp;lt;code&amp;gt;port&amp;lt;/code&amp;gt; field will contain the port to which the server is bound.&lt;br /&gt;
&lt;br /&gt;
=== Notifications ===&lt;br /&gt;
&lt;br /&gt;
If the &amp;lt;code&amp;gt;opts.notify_scripts&amp;lt;/code&amp;gt; in the request is set to &amp;lt;code&amp;gt;TRUE&amp;lt;/code&amp;gt;, CRIU would report back resp messages with type set to &amp;lt;code&amp;gt;NOTIFY&amp;lt;/code&amp;gt; and this field present. The notifications are the way [[action scripts]] work for RPC mode.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
message criu_notify {&lt;br /&gt;
	optional string script		= 1;&lt;br /&gt;
	optional int32	pid		= 2;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After handling the notification the client must response with the request again with the type set to &amp;lt;code&amp;gt;NOTIFY&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;notify_success&amp;lt;/code&amp;gt; set to the whether the notification was successful. In case of successful notification acknowledge the server doesn't close the socket and continues to work.&lt;br /&gt;
&lt;br /&gt;
== Pre-dumps ==&lt;br /&gt;
&lt;br /&gt;
Before issuing a &amp;lt;code&amp;gt;DUMP&amp;lt;/code&amp;gt; request client may send one or more &amp;lt;code&amp;gt;PRE_DUMP&amp;lt;/code&amp;gt; requests. Once the &amp;lt;code&amp;gt;PRE_DUMP&amp;lt;/code&amp;gt; is sent and response is received, client may send one more &amp;lt;code&amp;gt;PRE_DUMP&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;DUMP&amp;lt;/code&amp;gt; request. The server would only close the socket after the &amp;lt;code&amp;gt;DUMP&amp;lt;/code&amp;gt; one.&lt;br /&gt;
&lt;br /&gt;
== Multi-request mode ==&lt;br /&gt;
&lt;br /&gt;
If the &amp;lt;code&amp;gt;req.keep_open&amp;lt;/code&amp;gt; flag is set to true server will not close the socket after response, but will wait for more requests. This mode is supported only for the following request types:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;PRE_DUMP&amp;lt;/code&amp;gt; (automatically)&lt;br /&gt;
* &amp;lt;code&amp;gt;PAGE_SERVER&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;CPUINFO_DUMP&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CPUINFO_CHECK&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Run ==&lt;br /&gt;
&lt;br /&gt;
=== SWRK mode ===&lt;br /&gt;
&lt;br /&gt;
This mode turns on when one &amp;lt;code&amp;gt;fork() + exec()&amp;lt;/code&amp;gt; CRIU with the &amp;lt;code&amp;gt;swrk&amp;lt;/code&amp;gt; action and one more argument specifying the number of descriptor with &amp;lt;code&amp;gt;SOCK_SEQPACKET&amp;lt;/code&amp;gt; Unix socket. With this CRIU works as service worker task accepting standard RPC requests via the mentioned socket and using one to do action scripts notifications and result reporting.&lt;br /&gt;
&lt;br /&gt;
=== Server ===&lt;br /&gt;
&lt;br /&gt;
On a server side, CRIU creates &amp;lt;code&amp;gt;SOCK_SEQPACKET&amp;lt;/code&amp;gt; Unix socket and listens for connections on it. After receiving &amp;lt;code&amp;gt;criu_req&amp;lt;/code&amp;gt;, CRIU processes it, does what was requested and sends &amp;lt;code&amp;gt;criu_resp&amp;lt;/code&amp;gt; with set request-specific &amp;lt;code&amp;gt;criu_***_resp&amp;lt;/code&amp;gt; field back.&lt;br /&gt;
If CRIU gets unknown type of request, it will return &amp;lt;code&amp;gt;criu_resp&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;type == EMPTY&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;success == false&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To launch the service, run:&lt;br /&gt;
&lt;br /&gt;
 # criu service [options]&lt;br /&gt;
&lt;br /&gt;
Options accepted by service are&lt;br /&gt;
&lt;br /&gt;
; --address &amp;lt;path&amp;gt;&lt;br /&gt;
: where to put listening socket&lt;br /&gt;
&lt;br /&gt;
; --pid-file &amp;lt;path&amp;gt;&lt;br /&gt;
: where to write pid of service process&lt;br /&gt;
&lt;br /&gt;
; --daemon&lt;br /&gt;
: tells service to daemonize&lt;br /&gt;
&lt;br /&gt;
; -o &amp;lt;file&amp;gt;&lt;br /&gt;
: says where to write logs&lt;br /&gt;
&lt;br /&gt;
; -v[N]&lt;br /&gt;
: sets the log level&lt;br /&gt;
&lt;br /&gt;
=== Client ===&lt;br /&gt;
&lt;br /&gt;
Client, in its turn, must connect to service socket, send &amp;lt;code&amp;gt;criu_req&amp;lt;/code&amp;gt; with request in it, and wait for a &amp;lt;code&amp;gt;criu_resp&amp;lt;/code&amp;gt; with response.&lt;br /&gt;
You can find examples of client programs in C and Python in test/others/rpc/.&lt;br /&gt;
&lt;br /&gt;
With RPC facilities one can perform a [[self dump]].&lt;br /&gt;
&lt;br /&gt;
There's a [[C API|library]] that implements simple wrappers on top of RPC.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[CLI]]&lt;br /&gt;
* [[C API]]&lt;br /&gt;
&lt;br /&gt;
[[Category: API]]&lt;/div&gt;</summary>
		<author><name>Zeyady98</name></author>
	</entry>
</feed>