[CRIU] SWRK mode legalization

Andrew Vagin avagin at parallels.com
Mon Mar 30 00:58:56 PDT 2015


On Thu, Mar 26, 2015 at 06:18:07PM +0300, Pavel Emelyanov wrote:
> Hi,
> 
> As you know there are currently 2 ways of using CRIU -- one via CLI and another
> one by starting a CRIU service and talking to it using RPC commands (and a .so
> which provides C function wrappers around RPC calls).
> 
> We have yet another undocumented way to use CRIU which is called SWRK. In this
> mode CRIU is fork+exec-ed as it if is about to be used as CLI tool, but instead
> of passing arguments via CLI, caller gives to CRIU a socket and sends RPC
> commands directly into it. IOW, swrk mode is a mixture of CLI and RPC -- one
> doesn't have to start a service, but can request CRIU with easier-to-use RPC
> commands.
> 
> The mode is not documented as the way to start one seemed not nice from my
> perspective, it's like this
> 
>    int sk[2];
>    socketpair(PF_UNIX, SOCK_SEQPACKET, 0, sk);
>    if (fork() == 0) {
>          close(sk[0]);
>          sprintf(buf, "%d", sk[1]);
>          execl("criu", "criu", "swrk", buf, NULL);
>    }
>    close(sk[1]);
>    /* start feeding RPC commands into sk[0] here */
> 
> Originally this mode was done to make life for the P.Haul easier, but right now
> it looks like integration with Docker would be much easier if done in swrk way.
> LXC can probably also benefit from it.
> 
> So I think it's a good time to stop hiding it, nail down the API and use in
> Docker (and probably LXC).

Hi Pavel,

I have reworked libcontainer to use the swrk mode. It works and I like
it. I have sent a patch which is added inherite_fd into rpc request.

https://github.com/docker/libcontainer/pull/486

I vote to open swrk.

Thanks,
Andrey

> 
> Having nothing better as the above code snippet in mind, I thought to just add
> a couple of argv[] sanity checks to criu and declare this as official swrk API.
> If you have suggestions how to make it better -- you're warmly welcome :)
> 
> The RPC is described here (http://criu.org/RPC) and there's a small section
> about swrk in the bottom of the page.
> 
> -- Pavel


More information about the CRIU mailing list