Line 1: |
Line 1: |
− | The [[CLI/cmd/restore|restore]] command has several options how to restore the tree. | + | The [[CLI/cmd/restore|restore]] command has several options on how to restore the process tree. |
| | | |
| == Types of restore == | | == Types of restore == |
| | | |
− | ; Default
| + | === Default === |
− | : CRIU just forks the root task and all other tasks, restores the tasks, then waits for it to exit and after it exits itself. The process tree right after restore is shown on the picture below.
| |
| | | |
− | [[Image:Criu-restore-dflt.svg|300px|Default restore]]
| + | CRIU just forks the root task and all other tasks, restores the tasks, then waits for it to exit and after it exits itself. The process tree right after restore is shown on the picture below. |
| | | |
| + | [[Image:Criu-restore-dflt.svg|400px|Default restore]] |
| | | |
| + | <br clear="all"/> |
| | | |
− | ; Detached
| + | === Detached === |
− | : An option <code>--restore-detached</code> makes CRIU exit right after restoring the tree thus causing it to get reparented to the init process.
| + | An option <code>--restore-detached</code> makes CRIU exit right after restoring the tree thus causing it to get reparented to the init process. |
| | | |
− | [[Image:Criu-restore-detached.svg|300px|Detached restore]] | + | [[Image:Criu-restore-detached.svg|400px|Detached restore]] |
| | | |
| + | <br clear="all"/> |
| | | |
| + | === Sibling === |
| | | |
| + | An option <code>--restore-sibling</code> makes CRIU create root task as its own sibling and thus as caller's child. After restore is complete CRIU also exits thus leaving the restored tree being a pure child of the caller. |
| | | |
− | ; Sibling
| + | [[Image:Criu-restore-sibling.svg|400px|Sibling restore]] |
− | : An option <code>--restore-sibling</code> makes CRIU create root task as its own sibling and thus as caller's child. After restore is complete CRIU also exits thus leaving the restored tree being a pure child of the caller. | |
| | | |
− | [[Image:Criu-restore-sibling.svg|300px|Sibling restore]]
| + | <br clear="all"/> |
| | | |
| == Doing execv() in CRIU == | | == Doing execv() in CRIU == |
| | | |
− | In the default restore case it's possible to replace CRIU hanging between the caller process and the root one with something more useful. The <code>--exec-cmd</code> option makes CRIU call execv() with arguments that are to be given at the very end of the CLI after <code>--</code> argument. E.g. like this | + | In the default restore case it's possible to replace CRIU hanging between the caller process and the root one with something more useful. The <code>--exec-cmd</code> option makes CRIU call execv() with arguments that are to be given at the very end of the CLI after <code>--</code> argument. For example: |
| | | |
− | <pre>
| + | criu restore --images-dir img/ --exec-cmd -v4 -o restore.log -- my_waiter --my-waiter-arg |
− | criu restore --images-dir img/ --exec-cmd -v4 -o restore.log -- my_waiter --my-waiter-arg | |
− | </pre>
| |
| | | |
− | In this case the restored tree will look like in default case, but with the custom binary instead of CRIU processes. | + | In this case the restored tree will look like in the default case, but with the custom binary instead of the CRIU process. |
| | | |
− | [[Image:Criu-restore-n-exec.svg|300px|Restore with execv()]] | + | [[Image:Criu-restore-n-exec.svg|400px|Restore with execv()]] |
| + | <br clear="all"/> |
| | | |
− | == Getting pid of the tree == | + | == Getting PID of the tree == |
| | | |
− | In case the process tree lives in [[namespaces]] or is [[C/R in namespace|restored in new namespaces]], the real pid of the root task can become any. Knowing it depends on the [[API]] used. | + | In case the process tree lives in [[namespaces]] or is [[C/R in namespace|restored in new namespaces]], the real PID of the root task is not predefined. A way to obtain its value depends on the [[API]] used. |
| | | |
− | ; [[CLI]]
| + | === CLI === |
− | : When using the <code>--pidfile $path</code> option CRIU writes the PID of the root task in the <code>$path</code> file.
| + | In [[CLI]], <code>--pidfile ''path''</code> option can be used for CRIU to write the PID of the root task to a <code>''path''</code> file. |
| | | |
− | ; [[RPC]]
| + | === RPC === |
− | : In case of RPC the real pid of restored root task is reported back in the <code>criu_resp.restore.pid</code> field of the message.
| + | In case of [[RPC]], the real PID of the restored root task is reported back in the <code>criu_resp.restore.pid</code> field of the message. |
| | | |
| == See also == | | == See also == |