Line 6: |
Line 6: |
| | | |
| * First, X software uses SystemV IPC shared memory to exchange data between server and application, thus you'll have to run the whole stuff in IPC namespace; | | * First, X software uses SystemV IPC shared memory to exchange data between server and application, thus you'll have to run the whole stuff in IPC namespace; |
− | * Second, in order to be restored reliably, it's recommended to run VNC server, window manager and application in a PID namespace; | + | * Second, in order to be restored reliably, it's recommended to run [https://tigervnc.org/ VNC server], window manager and application in a PID namespace; |
| * Third, when started from shell they will inherit session ID and terminal from that shell, which might block dump. | | * Third, when started from shell they will inherit session ID and terminal from that shell, which might block dump. |
| | | |
Line 22: |
Line 22: |
| #!/bin/bash | | #!/bin/bash |
| set -m | | set -m |
− | Xvnc :25 -v -geometry 800x600 -i 0.0.0.0 -SecurityTypes none & | + | Xvnc :25 -v -geometry 800x600 -interface 0.0.0.0 -SecurityTypes none & |
| pid=$! | | pid=$! |
| trap "kill $pid; wait" EXIT | | trap "kill $pid; wait" EXIT |
Line 31: |
Line 31: |
| with the above "software" the server can be launched like this: | | with the above "software" the server can be launched like this: |
| | | |
| + | # chmod a+x vnc_server.sh |
| # ./newns ./vnc_server.sh icewm | | # ./newns ./vnc_server.sh icewm |
| | | |
Line 36: |
Line 37: |
| <pre> | | <pre> |
| 17854 ? Ss 0:00 /bin/bash ./vnc-server.sh icewm | | 17854 ? Ss 0:00 /bin/bash ./vnc-server.sh icewm |
− | 17855 ? Sl 0:00 \_ Xvnc :25 -v -geometry 800x600 -i 0.0.0.0 -SecurityTypes none | + | 17855 ? Sl 0:00 \_ Xvnc :25 -v -geometry 800x600 -SecurityTypes none |
| 17863 ? R 0:00 \_ icewm | | 17863 ? R 0:00 \_ icewm |
| </pre> | | </pre> |
Line 42: |
Line 43: |
| == Launch VNC client == | | == Launch VNC client == |
| | | |
− | After this you can start your favorite VNC client (viewer) to see what's inside the server. The latter would be visible on port 5925 (:25 argument). | + | After this you can start your favorite VNC client (viewer) to see what's inside the server. The latter would be visible on port 5925 (:25 argument). For example: |
| + | |
| + | $ vncviewer localhost:25 |
| | | |
| [[File:Vnc.jpg|400px]] | | [[File:Vnc.jpg|400px]] |
Line 52: |
Line 55: |
| Then you should create a directory for image files (e.g. <code>imgs</code>) and dump the tree starting from the VNC launching script | | Then you should create a directory for image files (e.g. <code>imgs</code>) and dump the tree starting from the VNC launching script |
| | | |
− | # criu dump -t 17854 --images-dir imgs/ --log-file dump.log -v 4 --tcp-established | + | # criu dump -t 17854 --images-dir imgs/ --log-file dump.log -v4 --tcp-established |
| | | |
| | | |
− | The <code>-v 4</code> option is required to make criu more verbose and the <code>--tcp-established</code> one is needed, to make criu handle active TCP connection -- the one between VNC server and VNC client. | + | The <code>-v4</code> option is required to make criu more verbose and the <code>--tcp-established</code> one is needed, to make criu handle active TCP connection -- the one between VNC server and VNC client. |
| | | |
| Check the criu return code to be 0, or the imgs/dump.log file last message to be | | Check the criu return code to be 0, or the imgs/dump.log file last message to be |
Line 65: |
Line 68: |
| == Restore VNC server == | | == Restore VNC server == |
| | | |
− | # criu restore --images-dir imgs/ --log-file rst.log -v 4 --tcp-established -d | + | # criu restore --images-dir imgs/ --log-file rst.log -v4 --tcp-established -d |
| | | |
| What has changed from the dump command is the action (it's restore now), the log file name (not to mix things up) and the new <code>-d</code> option. It says, that after restoring criu should exit and make the restored tree of tasks to be reparented to the init task. | | What has changed from the dump command is the action (it's restore now), the log file name (not to mix things up) and the new <code>-d</code> option. It says, that after restoring criu should exit and make the restored tree of tasks to be reparented to the init task. |
Line 72: |
Line 75: |
| | | |
| Restore finished successfully. Resuming tasks. | | Restore finished successfully. Resuming tasks. |
| + | |
| + | == Video Demo == |
| + | |
| + | [https://www.youtube.com/watch?v=j4wlYY7lTDw Dumping video player with CRIU] |
| + | |
| + | [https://www.youtube.com/watch?v=roJ91Kqeq5w Example how CRIU can dump and restore a TCP connections] |
| + | |
| + | [https://www.youtube.com/watch?v=kjhuzSl6JYc Checkpoint and restore of Firefox with CRIU] |
| + | |
| + | == See also == |
| + | |
| + | * [[Screen]] |
| + | * [[TCP connection]] |
| | | |
| [[Category: HOWTO]] | | [[Category: HOWTO]] |