[CRIU] LXC integration

Andrew Vagin avagin at parallels.com
Tue Mar 18 00:10:53 PDT 2014


On Mon, Mar 17, 2014 at 11:35:58PM +0200, Deyan Doychev wrote:
> Hello everybody!
> 
> For the last few weeks I've been trying to dump LXC containers with
> CRIU. Everything seems to work just fine when there are no consoles
> inside the containers. I can dump the init process and the whole process
> tree of the container and restore it later. I'm able to add the
> processes to the right cgroup and fix host side network configuration
> with an action script.

I'm glad to hear that you want to do this work.

> 
> However the following two problems are present:
> 
> 1) After restoring the previously dumped container, LXC doesn't know
> about it and all the LXC commands claim it is stopped. This is normal
> since there is no lxc-start-like process on top with its socket and main
> loop.                                                                                               
>  
> 
> 2) I have containers that need their consoles and a working lxc-console
> command.
> 
> Currently I have the following ideas for fixing these problems:
> 
> 1) Adding an argument to the criu restore command that will make it
> exec() a custom command when restore is complete. Thus, the newly
> created init process will become a child of this command. Then we could
> create a new lxc-start-like command that will take pid as an argument
> and work with it instead of the pid returned by clone(). This way LXC
> will be able to intercept the SIGCHLD signal from the restored init
> process on container shutdown/restart and also send appropriate signals.

That sounds reasonable.

> 
> 2) Currently /dev/console and /dev/ttyX in the container are actually
> bind-mounted /dev/pts/Y files. I've been thinking about adding code that
> creates master-slave pty pairs when restoring mount-points and
> bind-mounts them to the /dev/ttyX files. After that, with a small patch
> to the tty.c file we'll be able to use the already allocated slaves,
> while the lxc-start-like command from 1) will get the masters' open file
> descriptors upon exec().

Look at criu plugin engine http://criu.org/Plugins. I think we can write
a plugin for restoring external terminals.

> 
> Before actually beginning with the implementation I'll be glad to hear
> what you think about these solutions. Also, I'm open to any other
> suggestions or improvement ideas.
> 
> Regards,
> Deyan Doychev

Thanks,
Andrew Vagin

> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list