Changes

Jump to navigation Jump to search
1,217 bytes added ,  23:33, 17 February 2016
no edit summary
Line 117: Line 117:  
$
 
$
 
</pre>
 
</pre>
 +
 +
== Example 3 - External files, FIFO-s ==
 +
"criu dump" tries to resolve paths for each files, so the first example works only for files which can be resolved from dumped mount namespaces. If we have a file from another namespace, we call it as "external" and criu isn't able to restore it without external help. We need to enumerate all external files on dump and set inherit file descriptors on restore. This descriptors will be used only to open a file via /proc/self/fd, so it doesn't metter with which flags an inherited descriptor has been opened. The format of file id is file[mnt_id:inode].
 +
 +
<pre>
 +
    criu dump --external file[72:a3e7]
 +
    criu restore --inherit-fd fd[4]:file[72:a3e7]
 +
</pre>
 +
 +
== Example 4 - External TTY-s ==
 +
 +
The format of tty id is tty[rdev:dev]. Why can we not use a pair of mnt_id and inode here?
 +
 +
<pre>
 +
    $ ipython
 +
    In [1]: import os
 +
    In [2]: st = os.stat("/proc/self/fd/0")
 +
    In [3]: print "tty[%x:%x]" % (st.st_rdev, st.st_dev)
 +
    tty:[8800:d]
 +
   
 +
    $ps -C sleep
 +
      PID TTY          TIME CMD
 +
    4109 ?        00:00:00 sleep
 +
   
 +
    $ ./criu dump --external 'tty[8800:d]' -D imgs -v4 -t 4109
 +
    $ ./criu restore --inherit-fd 'fd[1]:tty[8800:d]' -D imgs -v4
 +
</pre>
 +
    
[[Category:HOWTO]]
 
[[Category:HOWTO]]
 
[[Category:API]]
 
[[Category:API]]
 
[[Category:Files]]
 
[[Category:Files]]

Navigation menu