[CRIU] Self Restoring

Christopher Covington cov at codeaurora.org
Thu Apr 24 06:30:12 PDT 2014


Hi Maximilian,

On 04/24/2014 08:29 AM, Maximilian Kleber wrote:
> Hello everybody,
> 
> I’m currently working with CRIU as a part of my bachelor thesis.
> One of the ideas is to provide CRIU access via a library approach for Java
> applications.
> 
> For this I’m using the provided C Library and JNI.
> 
> One of the goals is that an application can checkpoint and restore itself. 
> To be able to restore itself later, I’ll set the leave_running option when
> issuing the checkpoint request (I know this should be avoided, but elsewise
> this feature does not make much sense).
> 
> Checkpointing, restoring via command line or restoring an older session within
> the application works. But I can’t checkpoint and then restore this checkpoint
> directly afterwards. I guess CRIU tries to restore the original PID but since
> the original application is still running, this results in a conflict and a
> restoring failure. 
> 
> So I guess process duplication is not possible but /is there a way an
> application can replace itself with an older checkpoint of the same execution
> session?/

Actually, it is possible to duplicate a process. You just need to use a new
PID namespace.

unshare -fp -- criu restore

There are minor changes needed for this to work--I'll post my patches soon.

> I already tried to fork a child before restoring the application and within
> this child I kill the parent process and restore then the older checkpoint,
> which seems to work fine but I can only work if the child has no other
> siblings, since then the PID conflicts occur again.
> Another issue is, that killing an application does not always terminate the
> application instantly, I have to somehow wait for the process to terminate.

As far as I know, ptrace is the only mechanism that allows wait() ing for the
termination of a non-child process (by making effectively making it a child
process). You can poll, but that has a potential race condition.

Regards,
Christopher

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by the Linux Foundation.


More information about the CRIU mailing list