Difference between revisions of "Action scripts"
Jump to navigation
Jump to search
Saied Kazemi (talk | contribs) (→RPC) |
(minor formatting and English fixes) |
||
Line 1: | Line 1: | ||
− | With the --action-script command line option, CRIU can call your action scripts (also known as hooks) at various stages of dumping/restoring. | + | With the <code>--action-script</code> command line option, CRIU can call your action scripts (also known as hooks) at various stages of dumping/restoring. The following hooks are available: |
− | ;network-lock | + | ;<code>network-lock</code> |
: request to lock a container network (used by Docker and [[LXC]]) | : request to lock a container network (used by Docker and [[LXC]]) | ||
− | ;network-unlock | + | ;<code>network-unlock</code> |
: requested to unlock a container network (used by Docker and [[LXC]]) | : requested to unlock a container network (used by Docker and [[LXC]]) | ||
− | ;post-dump | + | ;<code>post-dump</code> |
: called when CRIU finished dumping tasks before unfreezing them | : called when CRIU finished dumping tasks before unfreezing them | ||
− | ;post-restore | + | ;<code>post-restore</code> |
: called when CRIU has finished restoring tasks before unlocking the network | : called when CRIU has finished restoring tasks before unlocking the network | ||
− | ;setup-namespaces | + | ;<code>setup-namespaces</code> |
: called when the root task is alive and new set of namespaces is created to set them up | : called when the root task is alive and new set of namespaces is created to set them up | ||
+ | == CLI == | ||
− | + | These hooks are added with the <code>--action-script ''shell-code-to-execute''</code> option. When called, the <code>CRTOOLS_SCRIPT_ACTION</code> environment is set to a value determining which type of action is performed. | |
− | These hooks are added with the --action-script shell-code-to-execute option. When called, the CRTOOLS_SCRIPT_ACTION environment is set to a value determining which type of action is performed. | ||
== RPC == | == RPC == | ||
− | In case of RPC, action scripts are implemented as notifications | + | In case of RPC, action scripts are implemented as notifications. Once CRIU service wants to execute a script, it sends an RPC message to the caller and waits for it to respond with <code>criu_req</code> message having <code>notify_success = true</code>. |
== Library == | == Library == | ||
− | When using a library one can | + | When using a library, one can set up a callback using the <code>criu_set_notify</code> routine. |
[[Category:HOWTO]] | [[Category:HOWTO]] | ||
[[Category:API]] | [[Category:API]] |
Revision as of 16:31, 8 April 2015
With the --action-script
command line option, CRIU can call your action scripts (also known as hooks) at various stages of dumping/restoring. The following hooks are available:
network-lock
- request to lock a container network (used by Docker and LXC)
network-unlock
- requested to unlock a container network (used by Docker and LXC)
post-dump
- called when CRIU finished dumping tasks before unfreezing them
post-restore
- called when CRIU has finished restoring tasks before unlocking the network
setup-namespaces
- called when the root task is alive and new set of namespaces is created to set them up
CLI
These hooks are added with the --action-script shell-code-to-execute
option. When called, the CRTOOLS_SCRIPT_ACTION
environment is set to a value determining which type of action is performed.
RPC
In case of RPC, action scripts are implemented as notifications. Once CRIU service wants to execute a script, it sends an RPC message to the caller and waits for it to respond with criu_req
message having notify_success = true
.
Library
When using a library, one can set up a callback using the criu_set_notify
routine.