{"id":775,"date":"2018-11-08T15:59:23","date_gmt":"2018-11-08T13:59:23","guid":{"rendered":"https:\/\/lisas.de\/~adrian\/posts\/2018-Nov-08-criu-configuration-files.html"},"modified":"2026-03-30T22:41:23","modified_gmt":"2026-03-30T20:41:23","slug":"criu-configuration-files","status":"publish","type":"post","link":"https:\/\/lisas.de\/luges\/index.php\/2018\/11\/08\/criu-configuration-files\/","title":{"rendered":"CRIU configuration files"},"content":{"rendered":"<p>One of the CRIU uses cases is container checkpointing and restoring, which also can be used to migrate containers. Therefore container runtimes are using CRIU to checkpoint all the processes in a container as well as to restore the processes in that container. Many container runtimes are layered, which means that the user facing layer (Podman, Docker, LXD) calls another layer to checkpoint (or restore) the container (runc, LXC) and this layer then calls CRIU.<\/p>\n<p>This leads to the problem that if CRIU introduces a new feature or option, all involved layers need code changes. Or if one of those layers made assumption about how to use CRIU, the user must live with that assumption, which may be wrong for the user&#8217;s use case.<\/p>\n<p>To offer the possibility to change CRIU&#8217;s behaviour through all these layers, be it that the container runtime has not implemented a certain CRIU feature or that the user needs a different CRIU behaviour, we started to discuss configuration files in 2016.<\/p>\n<p>Configuration files should be evaluated by CRIU and offer a third way to influence CRIU&#8217;s behaviour. Setting options via CLI and RPC are the other two ways.<\/p>\n<p>At the Linux Plumbers Conference in 2016 during the Checkpoint\/Restore micro-conference I gave a short introduction talk about how configuration files could look and everyone was nodding their head.<\/p>\n<p>In early 2017 <a class=\"reference external\" href=\"https:\/\/github.com\/veruu\">Veronika Kabatova<\/a> provided patches which were merged in CRIU&#8217;s development branch <em>criu-dev<\/em>. At that point the development stalled a bit and only in early 2018 the discussion was picked up again. To have a feature merged into the <em>master<\/em> branch, which means it will be part of the next release, requires complete documentation (man-pages and wiki) and feature parity for CRIU&#8217;s CLI and RPC mode. At this point it was documented but not supported in RPC mode.<\/p>\n<p>Adding configuration file support to CRIU&#8217;s RPC mode was not a technical challenge, but if any recruiter ever asks me which project was the most difficult, I will talk about this. We were exchanging mails and patches for about half a year and it seems everybody had different expectations how everything should behave. I think at the end they pitied me and just merged my patches&#8230;<\/p>\n<p><a class=\"reference external\" href=\"https:\/\/criu.org\/Download\/criu\/3.11\">CRIU 3.11<\/a> which was released on 2018-11-06 is the first release which includes support for configuration files and now (finally) I want to write about how it could be used.<\/p>\n<p>I am using the <a class=\"reference external\" href=\"https:\/\/criu.org\/Simple_TCP_pair\">Simple_TCP_pair<\/a> example from CRIU&#8217;s wiki. First start the server:<\/p>\n<div class=\"highlight\">\n<pre><span><\/span><span class=\"c1\">#\ufe0f .\/tcp-howto 10000<\/span> <\/pre>\n<\/div>\n<p>Then I am starting the client:<\/p>\n<div class=\"highlight\">\n<pre><span><\/span><span class=\"c1\"># .\/tcp-howto 127.0.0.1 10000<\/span> Connecting<span class=\"w\"> <\/span>to<span class=\"w\"> <\/span><span class=\"m\">127<\/span>.0.0.1:10000 PP<span class=\"w\"> <\/span><span class=\"m\">1<\/span><span class=\"w\"> <\/span>-&gt;<span class=\"w\"> <\/span><span class=\"m\">1<\/span> PP<span class=\"w\"> <\/span><span class=\"m\">2<\/span><span class=\"w\"> <\/span>-&gt;<span class=\"w\"> <\/span><span class=\"m\">2<\/span> PP<span class=\"w\"> <\/span><span class=\"m\">3<\/span><span class=\"w\"> <\/span>-&gt;<span class=\"w\"> <\/span><span class=\"m\">3<\/span> PP<span class=\"w\"> <\/span><span class=\"m\">4<\/span><span class=\"w\"> <\/span>-&gt;<span class=\"w\"> <\/span><span class=\"m\">4<\/span> <\/pre>\n<\/div>\n<p>Once client and server are running, let&#8217;s try to checkpoint the client:<\/p>\n<div class=\"highlight\">\n<pre><span><\/span><span class=\"c1\"># rm -f \/etc\/criu\/default.conf<\/span> <span class=\"c1\"># criu dump -t `pgrep -f &#039;tcp-howto 127.0.0.1 10000&#039;`<\/span> Error<span class=\"w\"> <\/span><span class=\"o\">(<\/span>criu\/sk-inet.c:188<span class=\"o\">)<\/span>:<span class=\"w\"> <\/span>inet:<span class=\"w\"> <\/span>Connected<span class=\"w\"> <\/span>TCP<span class=\"w\"> <\/span>socket,<span class=\"w\"> <\/span>consider<span class=\"w\"> <\/span>using<span class=\"w\"> <\/span>--tcp-established<span class=\"w\"> <\/span>option. <\/pre>\n<\/div>\n<p>CRIU tells us that it needs a special option to checkpoint processes with established TCP connections. No problem, but instead of changing the command-line, let&#8217;s add it to the configuration file:<\/p>\n<div class=\"highlight\">\n<pre><span><\/span><span class=\"c1\"># echo tcp-established &gt; \/etc\/criu\/default.conf<\/span> <span class=\"c1\"># criu dump -t `pgrep -f &#039;tcp-howto 127.0.0.1 10000&#039;`<\/span> Error<span class=\"w\"> <\/span><span class=\"o\">(<\/span>criu\/tty.c:1861<span class=\"o\">)<\/span>:<span class=\"w\"> <\/span>tty:<span class=\"w\"> <\/span>Found<span class=\"w\"> <\/span>dangling<span class=\"w\"> <\/span>tty<span class=\"w\"> <\/span>with<span class=\"w\"> <\/span>sid<span class=\"w\"> <\/span><span class=\"m\">16693<\/span><span class=\"w\"> <\/span>pgid<span class=\"w\"> <\/span><span class=\"m\">16711<\/span><span class=\"w\"> <\/span><span class=\"o\">(<\/span>pts<span class=\"o\">)<\/span><span class=\"w\"> <\/span>on<span class=\"w\"> <\/span>peer<span class=\"w\"> <\/span>fd<span class=\"w\"> <\/span><span class=\"m\">0<\/span>. Task<span class=\"w\"> <\/span>attached<span class=\"w\"> <\/span>to<span class=\"w\"> <\/span>shell<span class=\"w\"> <\/span>terminal.<span class=\"w\"> <\/span>Consider<span class=\"w\"> <\/span>using<span class=\"w\"> <\/span>--shell-job<span class=\"w\"> <\/span>option.<span class=\"w\"> <\/span>More<span class=\"w\"> <\/span>details<span class=\"w\"> <\/span>on<span class=\"w\"> <\/span>http:\/\/criu.org\/Simple_loop <\/pre>\n<\/div>\n<p>Alright, let&#8217;s also add <em>shell-job<\/em> to the configuration file:<\/p>\n<div class=\"highlight\">\n<pre><span><\/span><span class=\"c1\"># echo shell-job &gt;&gt; \/etc\/criu\/default.conf<\/span> <span class=\"c1\"># criu dump -t `pgrep -f &#039;tcp-howto 127.0.0.1 10000&#039;` &amp;&amp; echo OK<\/span> OK <\/pre>\n<\/div>\n<p>That worked. Cool. Finally! Most CLI options can be used in the configuration file(s) and more detailed documentation can be found in the <a class=\"reference external\" href=\"https:\/\/criu.org\/Configuration_files\">CRIU wiki<\/a>.<\/p>\n<p>I want to thank Veronika for her initial implementation and everyone else helping, discussing and reviewing emails and patches to get this ready for release.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the CRIU uses cases is container checkpointing and restoring, which also can be used to migrate containers. Therefore container runtimes are using CRIU to checkpoint all the processes in a container as well as to restore the processes in that container. Many container runtimes are layered, which means that the user facing layer [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-775","post","type-post","status-publish","format-standard","hentry","category-luges"],"_links":{"self":[{"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/posts\/775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/comments?post=775"}],"version-history":[{"count":17,"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/posts\/775\/revisions"}],"predecessor-version":[{"id":1911,"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/posts\/775\/revisions\/1911"}],"wp:attachment":[{"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/media?parent=775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/categories?post=775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lisas.de\/luges\/index.php\/wp-json\/wp\/v2\/tags?post=775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}