2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-26 11:57:52 +00:00

135 Commits

Author SHA1 Message Date
Pavel Emelyanov
f74ed43d0f libcriu: Add criu_add_cg_root() call
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
2014-08-22 19:20:06 +04:00
Tycho Andersen
f95b05eb75 opts: add --manage-cgroups option
criu managed cgroups is now an opt-in thing, so by default criu does not manage
(i.e. dump or restore) cgroups. This allows users to use the previous behavior.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:32:50 +04:00
Tycho Andersen
acaca5f14a lib: return -ECONNREFUSED as documented
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 13:58:49 +04:00
Tycho Andersen
14cad21eb5 lib: Generate pkgconfig file
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 13:57:18 +04:00
Tycho Andersen
0ef4f01066 lib: Initialize child messages correctly
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-04 13:10:35 +04:00
Pavel Emelyanov
84eb0a1927 criu: Restore tasks as siblings in swrk
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>
2014-07-01 16:16:07 +04:00
Pavel Emelyanov
8e11c8ec11 libcriu: Pi compilation -- add PR_SET_CHILD_SUBREAPER constant
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-27 15:27:14 +04:00
Pavel Emelyanov
7a2698cfe8 libcriu: Introduce the criu_dump_iters() call
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>
2014-06-27 14:29:52 +04:00
Pavel Emelyanov
43e5d05134 libcriu: Ability to fetch arguments from notifications
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>
2014-06-27 14:28:55 +04:00
Pavel Emelyanov
4562c3df57 libcriu: Add ability to request for notifications from service
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>
2014-06-27 14:28:52 +04:00
Pavel Emelyanov
24d2f56fad lib: Implement the criu_restore_child() call v2
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>
2014-06-27 14:24:36 +04:00
Pavel Emelyanov
b6f6426bef lib: Tossing bits around
This is to prepare a send-and-recv routine that works on existing socket.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-27 14:24:35 +04:00
Pavel Emelyanov
8f05162bb4 libcriu: Add add_veth_pair call
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-27 14:22:34 +04:00
Pavel Emelyanov
1a5a034413 libcriu: Add add_ext_mount_map call
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-27 14:22:33 +04:00
Pavel Emelyanov
3f4447d72e libcriu: Add simple missing criu_set_ calls
These are just copy the value on RPC message and
do nothing more.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-27 14:22:32 +04:00
Pavel Emelyanov
a09396cca5 libcriu: Add criu_set_root to header
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-27 14:22:31 +04:00
Cyrill Gorcunov
e1d43c4f8e lib: criu -- Test for nil on malloc/strdup calls
Otherwise nil dereference is possible.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-01 11:23:21 +04:00
Deyan Doychev
69a6bf4439 criu: Add exec-cmd option (v3)
The --exec-cmd option specifies a command that will be execvp()-ed on successful
restore. This way the command specified here will become the parent process of
the restored process tree.

Waiting for the restored processes to finish is responsibility of this command.

All service FDs are closed before we call execvp(). Standad output and error of
the command are redirected to the log file when we are restoring through the RPC
service.

This option will be used when restoring LinuX Containers and it seems helpful
for perf or other use cases when restored processes must be supervised by a
parent.

Two directions were researched in order to integrate CRIU and LXC:

1. We tell to CRIU, that after restoring container is should execve()
   lxc properly explaining to it that there's a new container hanging
   around.

2. We make LXC set himself as child subreaper, then fork() criu and ask
   it to detach (-d) from restore container afterwards. Being a subreaper,
   it should get the container's init into his child list after it.

The main reason for choosing the first option is that the second one can't work
with the RPC service. If we call restore via the service then criu service will
be the top-most task in the hierarchy and will not be able to reparent the
restore trees to any other task in the system. Calling execve from service
worker sub-task (and daemonizing it) should solve this.

Signed-off-by: Deyan Doychev <deyandoichev@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-03-25 01:20:02 +04:00
Deyan Doychev
714c27fc11 libcriu: Add criu_set_root to the interface.
This function implements the --root command line option in libcriu.

Signed-off-by: Deyan Doychev <deyandoichev@gmail.com>
Reviewed-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-03-21 08:34:37 +04:00
Cyrill Gorcunov
f0b5bedfa5 libcriu: Add criu_set_cpu_cap helper
To setup cpu capability mask.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-28 20:34:42 +04:00
Christopher Covington
89bb170a26 Always use ARCH_DIR
The top-level makefile defines an ARCH_DIR variable. Always use
it rather than referencing ARCH directly, since ARCH may be set
by the user on the command line and that raw input may not be
what needs to be used internally.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-10 14:33:11 +04:00
Christopher Covington
f287d29ebe Fix library build
A user may have necessary linker directories specified in CFLAGS.
Make sure to include them.

Change-Id: I76c2a7bd6e34cc282bfcd5f83cc69ae7fa2c8cc2

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-10 14:31:53 +04:00
Adrian Reber
b0e6ebc1c7 Makefile: add soname to libcriu.so
Using a soname makes it easy for applications to
detect if the ABI of libcriu.so has changed.
It still creates libcriu.so as before in lib. During
'make install' additional links are created:

 libcriu.so -> libcriu.so.1.0
 libcriu.so.1 -> libcriu.so.1.0

Signed-off-by: Adrian Reber <adrian@lisas.de>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-07 15:35:20 +04:00
Ruslan Kuprieiev
579e55fa0d libcriu: add work_dir support
As we've added work_dir_fd to RPC, lets add support for it to libcriu.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 18:27:20 +04:00
Andrey Vagin
a5bb33417b service: don't leak a zero file descriptor
CID 1141017 (#1-2 of 2): Resource leak (RESOURCE_LEAK)
14. leaked_handle: Handle variable fd going out of scope leaks the handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-23 13:59:41 +04:00
Andrey Vagin
ad0249f649 lib: don't copy more than the buffer size
CID 1141012 (#1 of 1): Copy into fixed size buffer (STRING_OVERFLOW)
2. fixed_size_dest: You might overrun the 108 byte fixed-size string
"addr.sun_path" by copying "service_address" without checking the
length.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-23 13:53:53 +04:00
Ruslan Kuprieiev
e80ee17368 lib: return -EBADE instead of -1
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 21:08:58 +04:00
Ruslan Kuprieiev
906a75ca03 lib: add check/dump/restore
These functions are to be used to check criu, dump process and restore process.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:26:11 +04:00
Ruslan Kuprieiev
ba18a5e16c make: lib -- use ldflags-so and obj-ext-src-y
We need ldflags-so to link libcriu with -lprotobuf-c
and rpc.pb-c.o to use RPC.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:26:08 +04:00
Pavel Emelyanov
60af777286 lib: Don't compile-in util-fd.c
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-07 16:08:29 +04:00
Cyrill Gorcunov
5006ed5f7c version: Define version as a macro
Defining it as static char is a bad idea especially
if it get included and never used -- we will get
"unused" variable error.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-14 15:00:17 +04:00
Cyrill Gorcunov
46eff20bd2 make: libcriu -- Use `obj-ext-src-y' target for pie/util-fd.c recompilation
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-04 16:16:51 +04:00
Cyrill Gorcunov
1056365970 lib: libcriu -- Use `lib-so' facility
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-02 16:17:13 +04:00
Cyrill Gorcunov
dfdac2cf3a make: Use generic build engine for libcriu.so
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-29 14:48:13 +04:00
Ruslan Kupreev Руслан
27f9b0335d v2 criu: Initial skeleton for criu library
Add target lib to Makefile for criu library.
Created directory lib and add there Makefile and criu.c - skelettons for criu library.

Signed-off-by: Ruslan Kupreev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-18 21:47:11 +04:00