<div dir="ltr">Great! Now that Andrey has confirmed it works with libcontainer, we should definitely publish this method and make it available.<div><br></div><div>Thanks,<br><div><br></div><div>--Saied</div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 30, 2015 at 12:58 AM, Andrew Vagin <span dir="ltr"><<a href="mailto:avagin@parallels.com" target="_blank">avagin@parallels.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Mar 26, 2015 at 06:18:07PM +0300, Pavel Emelyanov wrote:<br>
> Hi,<br>
><br>
> As you know there are currently 2 ways of using CRIU -- one via CLI and another<br>
> one by starting a CRIU service and talking to it using RPC commands (and a .so<br>
> which provides C function wrappers around RPC calls).<br>
><br>
> We have yet another undocumented way to use CRIU which is called SWRK. In this<br>
> mode CRIU is fork+exec-ed as it if is about to be used as CLI tool, but instead<br>
> of passing arguments via CLI, caller gives to CRIU a socket and sends RPC<br>
> commands directly into it. IOW, swrk mode is a mixture of CLI and RPC -- one<br>
> doesn't have to start a service, but can request CRIU with easier-to-use RPC<br>
> commands.<br>
><br>
> The mode is not documented as the way to start one seemed not nice from my<br>
> perspective, it's like this<br>
><br>
> int sk[2];<br>
> socketpair(PF_UNIX, SOCK_SEQPACKET, 0, sk);<br>
> if (fork() == 0) {<br>
> close(sk[0]);<br>
> sprintf(buf, "%d", sk[1]);<br>
> execl("criu", "criu", "swrk", buf, NULL);<br>
> }<br>
> close(sk[1]);<br>
> /* start feeding RPC commands into sk[0] here */<br>
><br>
> Originally this mode was done to make life for the P.Haul easier, but right now<br>
> it looks like integration with Docker would be much easier if done in swrk way.<br>
> LXC can probably also benefit from it.<br>
><br>
> So I think it's a good time to stop hiding it, nail down the API and use in<br>
> Docker (and probably LXC).<br>
<br>
</div></div>Hi Pavel,<br>
<br>
I have reworked libcontainer to use the swrk mode. It works and I like<br>
it. I have sent a patch which is added inherite_fd into rpc request.<br>
<br>
<a href="https://github.com/docker/libcontainer/pull/486" target="_blank">https://github.com/docker/libcontainer/pull/486</a><br>
<br>
I vote to open swrk.<br>
<br>
Thanks,<br>
Andrey<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> Having nothing better as the above code snippet in mind, I thought to just add<br>
> a couple of argv[] sanity checks to criu and declare this as official swrk API.<br>
> If you have suggestions how to make it better -- you're warmly welcome :)<br>
><br>
> The RPC is described here (<a href="http://criu.org/RPC" target="_blank">http://criu.org/RPC</a>) and there's a small section<br>
> about swrk in the bottom of the page.<br>
><br>
> -- Pavel<br>
</div></div></blockquote></div><br></div>