Line 1: |
Line 1: |
− | '''libcriu''' is a C API for CRIU, which is a simple wrapper around our [[RPC]]. Although you can use [[RPC]] directly, libcriu is a wrapper providing the interface that is much easier to use from C code. Note that [[RPC]] is supported in the first place, and if you want the most recent set of features you should probably use [[RPC]] directly. | + | '''libcriu''' is a C API for CRIU, a simple wrapper around our [[RPC]]. Although you can use [[RPC]] directly, libcriu is a wrapper providing the interface that is much easier to use from C code. Note that [[RPC]] is supported in the first place, and if you want the most recent set of features you should probably use [[RPC]] directly. |
| | | |
| == Introduction == | | == Introduction == |
Line 6: |
Line 6: |
| | | |
| To create a library <code>lib/libcriu.so</code>, run <code>make</code> in the main directory. | | To create a library <code>lib/libcriu.so</code>, run <code>make</code> in the main directory. |
− |
| |
− | {{Warning|The library is not thread- and fork- safe}}
| |
| | | |
| == Preparation == | | == Preparation == |
Line 19: |
Line 17: |
| === set service address === | | === set service address === |
| | | |
− | Use <code>void criu_set_service_address(char *address)</code> to specify path to a CRIU service socket. Call it with NULL to make libcriu use the default address (currently <code>/var/run/criu_service.socket</code>). | + | Use <code>void criu_set_service_address(char *address)</code> to specify path to a CRIU service socket. Call it with NULL to make libcriu use the default address (currently <code>criu_service.socket</code> in the local directory). Note that a CRIU service must be running at that address for the C API to work; you cannot use the C API standalone. To start a CRIU service, run <code>criu service --address /path/to/criu_service.socket</code>. The path given in this command is the path that needs to be passed to <code>criu_set_service_address</code>. |
| | | |
| === set dump/restore options === | | === set dump/restore options === |
Line 36: |
Line 34: |
| void criu_set_log_file(char *log_file); | | void criu_set_log_file(char *log_file); |
| </source> | | </source> |
| + | |
| + | {{Note|This set of calls is not thread safe! For thread safety the same calls with _local suffix should be used}} |
| | | |
| If no pid is set on dump, CRIU will dump the calling process itself. | | If no pid is set on dump, CRIU will dump the calling process itself. |
Line 131: |
Line 131: |
| == Examples == | | == Examples == |
| | | |
− | You could find example of using libcriu at [https://github.com/xemul/criu/tree/master/test/libcriu test/libcriu]. | + | You could find example of using libcriu at [https://github.com/checkpoint-restore/criu/tree/criu-dev/test/others/libcriu test/others/libcriu]. |
| | | |
| [[Category: API]] | | [[Category: API]] |
| + | [[Category: Outdated]] |