So I want to use CRIU to make a snapshot of a JVM process and restore it later. For this purpose I wrote a little program which does nothing more but printing the counter every second:
package some;
public class Fun {
public static void main(String[] args) throws InterruptedException {
for(int i = 0; i < Integer.valueOf(args[0]); i++) {
System.out.println("Counter: "+i);
Thread.sleep(1000);
}
}
}
Now when I run the programm $ java some.Fun 3000
the program starts showing me the seconds, so far so good.
Now when I want to store the process with criu, i do $ ps -aux
, find the PID of my java process (3503 in this case) and call criu on it $ criu dump -t 3503 -o dump.log --shell-job
. After doing so, the terminal with the counter stops counting, prints Killed
and seems to terminate.
At this point in the folder where i called criu, i got some dump files which I can use to restore the process $ criu restore -o dump.log --shell-job
When I do so, a new process with a new PID is created, and the counter is starts counting from the moment it stopped, as it is supposed to be. Nice!
However, lets say I kill the process and try using the same dump files to restore the process. If I do this, criu terminates right away with the message Aborted (core dumped)
. Same happens if I try transfer the files on another machine, with the same java version and try to run it there...
Now my question is: is it supposed to be so? Are we supposed to be able to restore the state just once? Or am I doing something wrong? Thank you in advance!