Difference between revisions of "Action scripts"

From CRIU
Jump to navigation Jump to search
(Update list of supported hooks)
m (→‎Library: Replace 'criu_set_notify' with 'criu_set_notify_cb')
 
(One intermediate revision by the same user not shown)
Line 32: Line 32:
  
 
;<code>orphan-pts-master</code>
 
;<code>orphan-pts-master</code>
: called after master pty is opened and unlocked (used by Docker)
+
: called after master pty is opened and unlocked (used by Docker). Used only in RPC mode, and the notification message contains a file descriptor for the master pty.
  
 
== CLI ==
 
== CLI ==
Line 44: Line 44:
 
== Library ==
 
== Library ==
  
When using a library, one can set up a callback using the <code>criu_set_notify</code> routine.
+
When using a library, one can set up a callback using the <code>criu_set_notify_cb</code> routine.
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
 
[[Category:API]]
 
[[Category:API]]

Latest revision as of 22:48, 28 February 2020

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:

pre-dump
called before the beginning of dump
post-dump
called when CRIU finished dumping tasks and before unfreezing them
pre-restore
called before the beginning of restore
post-restore
called when CRIU has finished restoring tasks and before unlocking the network
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)
setup-namespaces
called when the root task is alive and new set of namespaces is created to set them up
post-setup-namespaces
called after namespaces are configured
pre-resume
called at the moment when processes and resources are already restored but not yet in running state
post-resume
called at the very end, when everything is restored and processes were resumed
orphan-pts-master
called after master pty is opened and unlocked (used by Docker). Used only in RPC mode, and the notification message contains a file descriptor for the master pty.

CLI[edit]

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[edit]

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[edit]

When using a library, one can set up a callback using the criu_set_notify_cb routine.