Difference between revisions of "Py API"

From CRIU
Jump to navigation Jump to search
(Created page with "== See also == * C API * CLI * RPC Category:API Category:Empty articles")
 
 
Line 1: Line 1:
 +
For python developers there exists an easy API to communicate with CRIU. The module sits in <code>lib/py/criu.py</code> file.
 +
 +
== Overview ==
 +
 +
To use CRIU just create the instance of the <code>criu</code> class.
 +
 +
=== Configuring ===
 +
 +
Specify the way to call CRIU binary by calling one of criu class methods
 +
 +
; <code>criu.use_sk(name)</code>
 +
: CRIU is run as [[RPC#Server|service]] and listens on the socket <code>name</code>
 +
 +
; <code>criu.use_fd(fd)</code>
 +
: CRIU is already [[RPC#SWRK mode|spawn]] and accepts requests on socket <code>fd</code>
 +
 +
; <code>criu.use_binary(path)</code>
 +
: CRIU binary is located in <code>path</code> and it will be fork()-ed and execp()-ed
 +
 +
By default the <code>use_binary('criu')</code> mode is activated.
 +
 +
=== Specifying options ===
 +
 +
Use the <code>criu.opts</code> object to set the [[RPC]] options by their [[RPC#Request|regular names]]
 +
 +
=== Running ===
 +
 +
These calls perform CRIU actions
 +
 +
; <code>criu.dump()</code>
 +
: Run the [[CLI/cmd/dump|dump action]]
 +
 +
; <code>criu.restore()</code>
 +
: Run the [[CLI/cmd/restore|restore action]]
 +
 +
; <code>criu.check()</code>
 +
: Run the [[CLI/cmd/check|check action]]
 +
 
== See also ==
 
== See also ==
  
Line 6: Line 44:
  
 
[[Category:API]]
 
[[Category:API]]
[[Category:Empty articles]]
 

Latest revision as of 09:26, 21 September 2016

For python developers there exists an easy API to communicate with CRIU. The module sits in lib/py/criu.py file.

Overview[edit]

To use CRIU just create the instance of the criu class.

Configuring[edit]

Specify the way to call CRIU binary by calling one of criu class methods

criu.use_sk(name)
CRIU is run as service and listens on the socket name
criu.use_fd(fd)
CRIU is already spawn and accepts requests on socket fd
criu.use_binary(path)
CRIU binary is located in path and it will be fork()-ed and execp()-ed

By default the use_binary('criu') mode is activated.

Specifying options[edit]

Use the criu.opts object to set the RPC options by their regular names

Running[edit]

These calls perform CRIU actions

criu.dump()
Run the dump action
criu.restore()
Run the restore action
criu.check()
Run the check action

See also[edit]