[CRIU] criu as forkall

Pavel Emelyanov xemul at parallels.com
Mon Feb 3 03:35:57 PST 2014


On 02/03/2014 03:10 PM, Inti Gonzalez-Herrera wrote:
> Hello,
> 
> I found CRIU last week and I realized that it can be used to implement some sort of forkall. 
> In short, I am working in a java application and I need to start the application many times.
> The problem is that the start-up time is not negligible and I need to start many of them. My
> first idea was to implement something as Android Zygote but that path lead me to a huge
> modification in the Linux kernel.
> 
> Fortunately, I found this project and I guess I can use it. I already checked and CRIU is able
> to dump the application in the exact moment I want. It deals properly with sockets and so on
> (almost, there is a little exception which is triggered when the connection is lost; however 
> it is not a problem for me).
> 
> Now, the problem I have is that I don't know how to restore the same application at the same
> time due to the PID problem. I mean, first restore is OK but in the second one the system cannot
> assign the same PID. Is there a way to solve that problem? Is it implemented?  What are the
> command line option? If the solution involves something else, can you please provide an example?
> I can see that a solution is to execute the app in a new namespace. I will solve the pid problem
> but it will imply other problems?

Yes, you can restore from images inside a pid namespace. "Other problems" you might meet are

1. You need to provide an init process for the new namespace. Otherwise your namespace will
   be flooded with dying zombies (if the will appear, of course)

2. Your application will not be able to communicate to the rest of the system using pids.
   Sockets/fifos/files would be still accessible, but not pids.

> Can you suggest some workarounds? I guess that the only use of pids I have are those inside the
> pthread library and maybe others with the virtual machine.

Well, the glibc caches pid value and uses it actively, so if you restore task with different
visible pid you may encounter problems in glibc.

> Thanks
> Inti Gonzalez

Thanks,
Pavel



More information about the CRIU mailing list