2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 09:58:09 +00:00

227 Commits

Author SHA1 Message Date
Ruslan Kuprieiev
8a7a360d6d uninstall: use --record with setup.py, v2
--record option allows us to keep track of files that are being
installed by writing them to specified file. We can than use that
file to do proper cleanup on uninstall.

v2, drop -r, as we shouldn't really care about dirs, because
    setup.py doesn't report them to us.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-05-06 14:38:29 +03:00
Cyrill Gorcunov
3276406d65 build: Add uninstall action
While most are handled from the scratch there is a significant
problem with python setup. So I added some preliminaty solution,
probably someohe with good knowledge of how setup.py works
improve it later.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-27 14:13:35 +03:00
Tycho Andersen
70afb3bde2 build: clean up various other bits
.gitid, and some of the build directories from setup.py need to be cleaned
on 'clean'.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Cyrill Gorcunov
029650bfed build: Unify phony forms usage
Explicit .PHONY is preferred for style unification sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Cyrill Gorcunov
d469c5f865 build: lib-py -- Fix building missing rpc module
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-20 13:39:10 +03:00
Pavel Emelyanov
3cffd523e4 Revert "seccomp: add a --no-seccomp option to disable dumping seccomp"
This reverts commit a98014f306be4b4fefdf01af31e1efa5d83e5e4f.

As per Saied Kazemi, actually dump works without seccomp support
from the kernel on non-seccomped tasks. The only problem was with
criu check, but this would be addressed separately.

Reverting the commit not to burden the API with (yet) unneeded stuff.

Conflicts:
	lib/c/criu.h
2016-02-20 13:35:47 +03:00
Cyrill Gorcunov
b95bc0d1eb build: pycriu -- Move into lib/py
As was intended from the scratch.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-19 14:32:19 +03:00
Cyrill Gorcunov
8e506041ef build: Bring install back to life
Fixes #114

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-19 14:31:42 +03:00
Cyrill Gorcunov
c1f31142f8 build: lib -- Fix building for C library
- drop unneeded @built-in.o rule
- use proper @CRIU_SO for -soname option
- add dep on version change

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-18 14:15:12 +03:00
Cyrill Gorcunov
4854940d6f build: Move versions definitions on top level
- define all versions in Makefile.versions toplevel file
 - rename CRTOOLSVERSION to CRIU_VERSION (and add CRIU_ prefixes)
 - rename versions for C librabry

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-18 14:15:09 +03:00
Dmitry Safonov
e6b26e73bc criu/build: include msg.mk in files that use msg-*
This patch fixes accidental dropping of msg-gen, msg-link messages.
Just run make with another warn enabled:
[criu]$ make --warn-undefined-variable 2>&1 | grep msg
  PBCC     images/ipc-msg.pb-c.c
  DEP      images/ipc-msg.pb-c.d
  CC       images/ipc-msg.o
Makefile.config:17: warning: undefined variable 'msg-gen'
Makefile.version:20: warning: undefined variable 'msg-gen'
Makefile:120: warning: undefined variable 'msg-link'
Makefile:149: warning: undefined variable 'msg-link'
Makefile:15: warning: undefined variable 'msg-gen'

Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-18 14:12:21 +03:00
Pavel Emelyanov
c271e13f9a lib: fix comilation after previous commit
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-17 14:29:47 +03:00
Tycho Andersen
a98014f306 seccomp: add a --no-seccomp option to disable dumping seccomp
Sometimes we may want to use CRIU on older kernels which don't support
dumping seccomp state where we don't actually care about the seccomp state.
Of course this is unsafe, but it does allow for c/r of things using
seccomp on these older kernels in some cases. When the task is in
SECCOMP_MODE_STRICT or SECCOMP_MODE_FILTER with filters that block the
syscalls criu's parasite code needs, the dump will still fail.

Note that we disable seccomp by simply feigning that we are in mode 0. This
is a little hacky, but avoids distributing ifs throughout the code and
keeps them in this one place.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-17 13:46:55 +03:00
Tycho Andersen
d45116ff8b build: crit -- Fix install target
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-15 15:32:53 +03:00
Cyrill Gorcunov
db6cb69394 build: Move everything criu related into criu directory
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-15 15:32:45 +03:00
Cyrill Gorcunov
da0eb1483b build: Move C and Python libraries into lib
Both CRIU library and CRIT python data are moved into
lib/c and lib/py.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-15 15:32:39 +03:00
Cyrill Gorcunov
da429bd433 lib: Don't use alloca over net received size
Better to obtain error if there is no free memory
than smashing the stack.

A rule of thumb for alloca() based functions is to
use them with predefined small sizes (such as we
do in swapping builtin sizes for parasite engine).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:53:02 +03:00
Ruslan Kuprieiev
f39bb8f9f0 libcriu: use swrk by default
Not sure if it is okay, but this patch breaks backward compatibility,
as we now discourage people from using criu as a system service by default.
But it is better to be done rather sooner than later, considering criu service
is not widely used.

On a patch side, we just need to daemonize swrk if self-dump is requested.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-15 14:35:15 +03:00
Andrew Vagin
9841778fec Don't use strlcpy in libcriu (v2)
../../lib/libcriu.so: undefined reference to `strlcpy'

v2: don't include string.h

Reported-by: Mr Jenkins
Cc: Kir Kolyshkin <kir@openvz.org>
Fixes: e5654e586cf5 ("Use strlcpy")
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-09 18:32:19 +03:00
Kir Kolyshkin
e5654e586c Use strlcpy
It's better to

1. Use strlcpy() instead of strncpy() as otherwise we might end up
   with a not NULL-terminated string, which opens a portal to hell.
   There are a few places reported by Coverity for this, such as:
    - in criu_connect(), Coverity CID 51591;
    - in proc_pid_parse(), Coverity CID 51590;
    - in move_veth_to_bridge(), Coverity CID 51593;
    - etc.

2. Use strlcpy() instead of strcpy() to avoid buffer overruns.
   Some of these are also reported by Coverity, for example
   the one in dump_filemap(), Coverity CID 51630.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-07 14:57:28 +03:00
Andrew Vagin
7ae72c651f lib: don't use uninitialized value "m"
*** CID 150397:  Memory - illegal accesses  (UNINIT)
/lib/criu.c: 696 in criu_local_add_irmap_path()
690
691             return 0;
692
693     err:
694             if (my_path)
695                     free(my_path);
>>> >>>     CID 150397:  Memory - illegal accesses  (UNINIT)
>>> >>>     Using uninitialized value "m".
696             if (m)
697                     free(m);
698
699             return -ENOMEM;
700     }
701

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-23 15:40:22 +03:00
Tycho Andersen
4f2e4ab3be irmap: add --irmap-scan-path option
This option allows users to specify their own irmap paths to scan in the event
that they don't have a path in one of the hard coded hints.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 11:46:12 +03:00
Cyrill Gorcunov
c5d485c94b lib: Add helpers to setup ghost limit
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-08-10 17:44:53 +03:00
Ruslan Kuprieiev
46e8aeed12 rpc: add constants for cgroups modes
Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-08-07 13:46:14 +03:00
Hui Kang
3d1e8c6883 Enable manage cgroup modes in criu service
Signed-off-by: Hui Kang <hkang.sunysb@gmail.com>
Looks-good-to: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-08-06 14:28:54 +03:00
Ruslan Kuprieiev
b652b06124 libcriu: hide struct criu_opts
Users shouldn't use it directly anyway, they should
use criu_set* fucntions for that.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-08-03 17:04:19 +03:00
Ruslan Kuprieiev
5f985fbabc libcriu: introduce CRIU_COMM_BIN
In this mode libcriu will execute criu binary in swrk
mode, so users are not always obliged to run criu service
daemon.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-31 15:42:38 +03:00
Ruslan Kuprieiev
7f56602d09 libcriu: move swrk launching code from restore_child to swrk_connect
Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-31 15:42:01 +03:00
Ruslan Kuprieiev
9adbbcce7f libcriu: criu_restore_child: don't forget to set errno
Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-31 15:41:53 +03:00
Artem Kuzmitskiy
79fd764ae6 Add dumping of unnamed unix sockets.
* Added functionality for dumping unnamed unix sockets.
  When we call CRIU with dump option, for unnamed socket we
  should pass it inode into --ext-unix-sk. Details about this problem
  described in http://criu.org/External_UNIX_socket#What_to_do_with_socketpair.28.29-s.3F.
  Usage example:
    criu dump -D images -o dump.log -v4 --ext-unix-sk=4529709 -t 13506

* fix typo error in log output

Signed-off-by: Artem Kuzmitskiy <artem.kuzmitskiy@lge.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-29 17:51:51 +03:00
Ruslan Kuprieiev
841f610a21 libcriu: don't include rpc.pb-c.h into criu.h, v2
Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 13:32:51 +03:00
Artem Kuzmitskiy
61a59fdd20 Added support linking libcriu into C++ source
This patch adds capability to using libcriu from C++ code.

Signed-off-by: Artem Kuzmitskiy <artem.kuzmitskiy@lge.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 13:30:52 +03:00
Ruslan Kuprieiev
de17028a08 libcriu: criu_init_opts: don't leak on rpc and opts
Reported-by: Andrew Vagin <avagin@gmail.com>
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-21 16:47:25 +03:00
Ruslan Kuprieiev
18034bb642 libcriu: allow user to specify service fd, v2
Currently, libcriu is connecting to CRIU service
by itself, just asking user for a path to socket.
But in some cases users need to provide fd instead
path. For example, sometimes task has no access to
criu socket because of strict security mesures, but
is able to inherit fd from a parent that has access
to criu socket.

v2, use union for addr and fd

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-16 23:09:43 +03:00
Ruslan Kuprieiev
9e0ff7af4f libcriu: use criu_opts structure to keep all the options
criu_opts contains rpc options and notify callback,
so we can keep all options in just one structure.
This will allow us to easily extend libcriu functionality
and yet keep all options in one place.

We're also not hiding rpc opts structure anymore, so
it is pretty clear where power-user should put his own
CriuOpts instance if he would like to do that.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-16 14:29:47 +03:00
Ruslan Kuprieiev
679aaa56ca libcriu: add ability to use local options structure
Having ability to have your own options structure is quite nice
and allows much more flexible use of libcriu in cases when you
want to have a bunch of instances of options structures.

This patch also allows users to use raw CriuOpts structure
modified in any suitable way, whether by libcriu's criu_local_set
methods or by using protobuf-c directly.

It is also worth noting, that backward-compatibility in API and ABI
is preserved.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-13 14:55:00 +03:00
Ruslan Kuprieiev
2403ee4695 libcriu: add skip_mnt and enable_fs support
Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-05-07 18:37:16 +03:00
Tycho Andersen
d885caf941 add RPC options for automatic external mount handling
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-22 12:29:47 +03:00
Andrey Vagin
a1ca6efa50 service: allocate buffers for messages dinamically (v2)
Currently we use a static buffer, but it is too small.

Error (cr-service.c:58): Failed unpacking request: Success
Error (cr-service.c:694): Can't recv request: Success
data too short after length-prefix of 1217

v2: use recv instead on recvmsg

Reported-by: Ross Boucher <rboucher@gmail.com>
Cc: Ross Boucher <rboucher@gmail.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-04-21 16:09:09 +03:00
Ruslan Kuprieiev
c7c772f93e libcriu: add cr_errno support
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-22 17:38:52 +03:00
Ruslan Kuprieiev
870bf2d5fd libcriu: print error if exec failed
Reported-by: Paschalis Mpeis <paschalis.mpeis@ed.ac.uk>
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-11 11:26:07 +03:00
Pavel Emelyanov
53957fadc3 restore: Introduce the --restore-sibling option
We have a slight mess with how criu restores root task.
Right now we have the following options.

1) CLI
	a) Usually
	task calling criu
	 `- criu
	     `- root restored task

	b) when --restore-detached AND root has pdeath_sig

	task calling criu
	 `- criu
	 `- root restored task

2) Library/SWRK
	task using lib/swrk
	 `- criu
	 `- root restored task

3) Standalone service
	a) Usually
	service
	 `- service sub task
	     `- root restored task

	b) when root has pdeath_sig
	criu service
	 `- criu sub task
	 `- root restored task

It would be better is CRIU always restored the root task as sibling,
but we have 3 constraints:

First, the case 1.a is kept for zdtm to run tests in pid namespaces
on 3.11, which in turn doesn't allow CLONE_PARENT | CLONE_NEWPID.

Second, CLI w/o --restore-detach waits for the restored task to die and
this behavior can be "expected" already.

Third, in case of standalone service tasks shouldn't become service's
children.

And I have one "plan". The p.haul project while live migrating tasks
on destination node starts a service, which uses library/swrk mode. In
this case the restored processes become p.haul service's kids which is
also not great.

That said, here's the option called --restore-child that pairs the
--restore-detach like this:

* detached AND child:

task
 `- criu restore (exits at the end)
 `- root task

The root task will become task's child.
This will be default to library/swrk.
This is what LXC needs.

* detach AND !child

task
 `- criu restore (exits at the end)
     `- root task

The root task will get re-parented to init.
This will be compatible with 1.3.
This will be default to standalone service and
to my wish with the p.haul case.

* !detach AND child

task
 `- criu restore (waits for root task to die)
 `- root task

This should be deprecated, so that criu restore doesn't mess
 with task <-> root task signalling.

* !detach AND !child

task
 `- criu restore (waits for root task to die)
     `- root task

This is how plain criu restore works now.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@openvz.org>
2014-09-10 18:30:30 +04:00
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