CRIU doesn't support relative unix sockets paths, so
tune the test to use absolute.
(v2: Off-by-one spotted by Filipe)
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Otherwise the connection can be disconnected due to a timeout, because
the kernel may drop packets from a receive queue (RcvPruned in
/proc/net/netstat).
Half of buffers always stay in the socket, another half is circulated.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
When cwd is removed (it can be) we need to collect the respective
file_desc before starting opening any files to properly handle
ghost refcounts. Otherwise we will miss one refcount from the
cwd's on ghost, which in turn will either BUG inside ghost removal,
or will fail the cwd due to the respective dir being removed too
early.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
If we have opened and rmdir-ed directory, the dump works OK
creating the ghost file and remap, but restore creates _file_
instead of directory.
Fix this.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
When we have opened and unlinked chr or blk device, we
shouls also take care of their rdev value. Thus -- new
field in image and some new steps on dump and restore.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Some tests require custom options for dump and restore. Instead
of hard-coding test names into zdth.sh, introduce the $test.opts
file from which zdtm would pick the needed options.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
On ARM some PTRACE_... constants are not declared in sys/ptrace.h file.
They are in linux/ptrace.h, but on x86 this file somewhat conflicts with
the sys/ one. For now fix ARM compilation by using criu/ one and think
of it later.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Andrey validly pointed out, that restoring pdeath_sig is not
compatible with criu_restore_child() call -- after criu restore
children, it will exit and fire the pdeath_sig into restored
tree root, potentially killing it.
The fix for that could be -- when started in swrk more, criu can
restore tree not as children tasks, but as siblings, using the
CLONE_PARENT flag when fork()-ing the root task.
With this we should also take care about errors handing -- right
now criu catches the SIGCHILD from dying children tasks, and
since we plan to create them be children of the criu parent (the
library caller) we will not be able to catch them. To do so we
SEIZE the root task in advance thus causing all SIGCHLD-s go to
criu, not to its parent.
Having this done we no longer need the SUBREAPER trick in the
library call -- tasks get restored right as callers kids :)
Some thoughts for future -- using this trick we can finally make
"natural" restoration of shell jobs. I.e. -- make criu restore
some subtree right under bash, w/o leaving itself as intermediate
task and w/o re-parenting the subtree to init after restore.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrey Vagin <avagin@parallels.com>
The implementation is pretty straightforward. When dumping per-thread
misc data with parasite, collect one, then write in thread_core_info.
On restore wait for creds restore and put the value back (some creds
changes drop it to zero).
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Perform dumping but with preliminary iterations. Each
time an iteration ends the ->more callback is called.
The callback's return value is
- positive -- one more iteration starts
- zero -- final dump is performed and call exits
- negative -- dump is aborted, the value is returned
back from criu_dump_iters
Inside callback one may (well, should) call criu_set_
function to alter the details of next iterations. In
particluar, then prev and next images directories should
be changed.
The @pi argument is an opaque value that caller may
use to request pre-dump statistics (not yet implemented).
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
After a bit more thinking I found a way to fetch arguments
from notifications -- pass opaque value into callback and
provide a set of calls for exploring one.
With this we can
a) provide more data if service supplies additional fields
in the future
b) not check the action name to decide whether or not the
requested argument is available
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This is achieved by supplying the callback. Every time a notification
arrives the callback is called. Return value of 0 means continue,
any other value aborst the request and the value is reported back
to the caller (from criu_dump/criu_restore calls).
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
It's derived from test.c, but is more self-contained
and explicitly checks for both C and R results.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Which is at the same time the demonstration of how to do the trick.
v2:
* remove stupid sleep 1 synchronization
* run internal version of child, not the external script
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
It fully uses the swrk action of criu. The problems, that caller may
have is that the restored tasks die _before_ libcriu's call returns.
v2:
* rename _sub to _child
* unblock sigchild before execl-ing criu
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
To help restoring tasks from images as kids to the caller, we can
do the trick.
1. Caller sets himself as child reaper with PR_SET_CHILD_SUBREAPER prctl
2. Caller makes sure criu binary is suid-ed and owned by root
3. Caller forks and calls execv() on criu asking it to restore
4. Criu finishes restore and exits. All its kids get reparented to the
criu's parent, i.e. -- to the library caller.
5. Caller stops being subreaper
In order to make the execv() and arguments passing simpler I propose
to execv() the service worker function, that accepts options via socket.
This is good for two reasons.
1. We don't have to construct CLI options in libcriu
2. We reuse other service's facilities, such as security checks,
ability to dump, pre-dump and other stuff
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>