2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 05:48:05 +00:00

7582 Commits

Author SHA1 Message Date
Pavel Emelyanov
764b867432 log: Swap contents of criu-log and log headers
The former one (criu-log.h) is now for service functions like logfile
management, pidfile and alike. It's only needed by files that set up
logging and for users that want specific functions like log_get_fd or
pr_quelled.

The latter (log.h) is purely for those who need pr_xxx helpers only.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
58ee7c6348 log: Move default log-level to criu-log.h
Closer to the log-levels themselves.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
fd23573fc4 log: Remove print_data() from log header
It is in util.c and declaration IS in util.h

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
9a8df0b759 log: Remove dangling extern
We used to have print_image_data, now we don't.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
077ce58b45 criu: Add int.h-s to kerndat and files (compilation fix)
Prevuous sets interfered and broke compilation on non-x86.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
f6b8721155 util: Include int.h (compilation fix)
After macvlan patches it turned out that util.h needs
int types in, so it's better include it there.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Tycho Andersen
124fd587b6 test: add a --post-start hook
This hook runs after the test is started, in parallel with the actual test.
This can be used in case the test and the host need to coordinate somehow
in order to set something up (e.g. for a macvlan interface).

travis-ci: success for series starting with [v10,01/11] net: pass the struct nlattrs to dump() functions
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
dc58fccd9f Add missing headers for ppc64, arm and aarch
While tossing headers around non-x86 builds got broken
so move back missing parts for other arches. Other than
criu/arch/ stuff this is mostly int.h over .c files.

travis-ci: success for criu: Remove asm/ includes from non-arch sources
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
6d97294776 Hide asm/restore.h from sources
travis-ci: success for criu: Remove asm/ includes from non-arch sources
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
25218bcdb5 Hide asm/dump.h from sources
travis-ci: success for criu: Remove asm/ includes from non-arch sources
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
51730ab963 Hide asm/parasite-syscall.h from sources
travis-ci: success for criu: Remove asm/ includes from non-arch sources
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
22963d2827 Hide asm/restorer.h from sources
travis-ci: success for criu: Remove asm/ includes from non-arch sources
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
e142319376 Hide asm/processor-flags.h from sources
travis-ci: success for criu: Remove asm/ includes from non-arch sources
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
397c6a86e6 Hide asm/bitsperlong.h from sources
travis-ci: success for criu: Remove asm/ includes from non-arch sources
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
0b3e86c490 Hide asm/atomic.h from sources
travis-ci: success for criu: Remove asm/ includes from non-arch sources
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
570ca2df8f Hide asm/bitops.h from sources
travis-ci: success for criu: Remove asm/ includes from non-arch sources
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
4181f6e090 Hide asm/string.h from sources
travis-ci: success for criu: Remove asm/ includes from non-arch sources
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
e6a2715ccb Hide asm/page.h from sources
travis-ci: success for criu: Remove asm/ includes from non-arch sources
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
4650864e34 Hide asm/int.h from srources
travis-ci: success for criu: Remove asm/ includes from non-arch sources
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Pavel Emelyanov
96c7cb7661 Hide asm/types.h from sources
travis-ci: success for criu: Remove asm/ includes from non-arch sources
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:16 +03:00
Cyrill Gorcunov
912cc2d16f Add directory for common headers
The idea is to have one place for headers which
are shared between subprojects (zdtm, criu, compel).

travis-ci: success for Add directory for common headers (rev3)
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Pavel Emelyanov
19e0221328 travis: Put package list in a variable
Patches moving code around and changing packages list conflict
with each other all the time. Split these two :)

travis-ci: success for travis: Put package list in a variable
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kirill Tkhai
9c4744d67d mount: Set opts.has_binfmt_misc regardless of mnt_ns level
Since cr-time binfmt_misc is mounted regardless of mnt_ns
level, it's need just not to be over the system, make
parse method in consistent state with this behaviour.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kir Kolyshkin
e2f6bb831a criu.8: document restore --leave-stopped
Option --leave-stopped can now be used during restore,
but this was not reflected in the man page.

[v2: fix wording]

https://github.com/xemul/criu/issues/215

travis-ci: success for criu.8: document restore --leave-stopped (rev2)
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Andrei Vagin
6fc5e41fd8 mount: skip '/' only if it is there
If p->mountpoint is "/", off will be 0 and we will
try to acess path[-1].

 On Tue, Sep 20, 2016 at 05:17:27PM +0300, Kirill Tkhai wrote:
> >
> > int off = 0;
> >
> > ...
> >
> > if (p->mountpoint[1] != 0) /* not / */
> >    off = snprintf(path, len, %s, p->mountpoint);
> > if (path[off - 1] == '/') /* p->mountpoint = ./ */
> >
> >          ^^^
> > The above looks like off-by-one when off == 0. Is there is
> > a condition which guarantees that off is not zero?

travis-ci: success for mount: skip '/' only if it is there
Reported-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Acked-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Mike Rapoport
c3e184f14a core-ppc64: mark gregs and clear_tid_addr as (criu).hex
travis-ci: success for core-aarch64: mark gregs and clear_tid_addr as (criu).hex (rev2)
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Mike Rapoport
3396710df1 core-arm: mark gregs and clear_tid_addr as (criu).hex
travis-ci: success for core-aarch64: mark gregs and clear_tid_addr as (criu).hex (rev2)
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Mike Rapoport
ff9b8544f4 core-aarch64: mark gregs and clear_tid_addr as (criu).hex
travis-ci: success for core-aarch64: mark gregs and clear_tid_addr as (criu).hex (rev2)
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Pavel Emelyanov
0d6e15f5e5 parasite: Relax size checking for get_exec_start()
For compel-ization it's MUCH easier to introduce single
constant, all the more so no VMAs can be shorter than
one page :)

travis-ci: success for parasite: Relax size checking for get_exec_start()
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Pavel Emelyanov
267037e8e8 parasite: Relax the parasite_execute_trap_by_pid API
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kirill Tkhai
386f7fec2e mount: Move adding cr-time binfmt_misc to collect_mnt_namespaces()
Binfmt_misc may not exist on NS_ROOT, and exist on NS_OTHER that time.
So, add binfmt_misc only if no one mnt_ns has it.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kirill Tkhai
714bd7a03f mount: Do not fail on shared cr-time mounts mismatch
Since cr-time mount parent may be shared, and we do
not propagate the mount there, this patch excludes
them from validation.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Cyrill Gorcunov
172f3e1908 freeze -- Wait for exiting tasks to complete
There is a small race between exitings tasks and cgroup freezer:
it can report a pid of exiting process which we will consider
as a zombie and refuse to checkpoint. Lets do a trick instead:
if we meets such task just wait a bit and repeate a freezing.

v3: Use EAGAIN instead of EPERM since EPERM collide
    with general -1 error code.

travis-ci: success for freeze -- Wait for exiting tasks to complete (rev3)
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Ruslan Kuprieiev
4f329dd4b2 lib: add inherit_fd
It is already present in CLI and RPC, so libcriu should reflect it too.

travis-ci: success for lib: add inherit_fd
Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Tycho Andersen
6178668e6a test: robustify mnt_tracefs test
* make sure that tracefs is actually loaded, and try and access it after
  restore
* don't mount debugfs in /, leaving an ugly directory in /test
* clean up the debugfs mount point (with a hook, since the test can't
  unmount it due to perms)

travis-ci: success for test: robustify mnt_tracefs test
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kir Kolyshkin
5992d7198b CI: add clang build for travis-ci
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kir Kolyshkin
391bdbe44f zdtm/grow_map: fix test failure for clang
When this code is compiled by clang, it optimizes two byte writes into
one word write, like this:

>        fake_grow_down[0] = 'c';
>        *(fake_grow_down - 1) = 'b';
> 401b60:       66 41 c7 46 ff 62 63    movw   $0x6362,-0x1(%r14)

This is incorrect, as the stack is supposed to grow page by page,
so we need to touch one page then another, i.e. the order is important.

To fix, let's use volatile pointer. After this change, the following
(correct) code is generated:

>        *p-- = 'c';
>   401b60:       41 c6 06 63             movb   $0x63,(%r14)
>        *p = 'b';
>   401b64:       41 c6 46 ff 62          movb   $0x62,-0x1(%r14)

[v2: same fix for another similar place]

Cc: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kir Kolyshkin
5465179f96 CI: move GCOV flag to travis.yml
Move GCOV to travis environment, so now we can change it easily
on a per-build basis.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kir Kolyshkin
9fb43a4803 Makefile: don't compile with -O0 if GCOV=1
I found that everything we test on travis-ci is built with -O0.
I believe this is the wrong thing to do as we test something that is
compiled not the way it would be compiled for any real use.

Drop enabling DEBUG for GCOV.

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kir Kolyshkin
2f2fc08202 CI: move travis' after_success to a script
It is easier to handle it this way

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kir Kolyshkin
f645996228 scripts/travis/Makefile: mark phony target as such
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kir Kolyshkin
ca677a91ff parasite.c: rm unneeded init
This "struct ctl_msg" initialization is not really needed, as it is
initalized right away in __parasite_daemon_wait_msg() function.

The real reason of removing this init is when compiled by clang
with -O0 etc (i.e. compiler flags set when GCOV=1 env var is present),
clang inserts a call to memset to initialize the structure. This,
of course, leads to "compel piegen" complaining:

	Unexpected undefined symbol: `memset'. External symbol in PIE?

One way of solving it would be to provide a memset() which will call
builtin_memset(), or a simple C implemenation. But as this is the only
place that triggers such a call to memset(), and this initialization
is not really needed, it's easier just to remove it.

Now, there might be more cases like this in the future, but for now
we are good.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kir Kolyshkin
b4441d1bd8 restorer.c: rm unneded struct init
This 'struct timespec' initialization is non needed as we call
clock_gettime() right away which is supposed to fill it in.

The real reason of removing this init is when compiled by clang
with -O0 etc (i.e. compiler flags set when GCOV=1 env var is present),
clang inserts a call to memset to initialize the structure. This,
of course, leads to "compel piegen" complaining:

	Unexpected undefined symbol: `memset'. External symbol in PIE?

One way of solving it would be to provide a memset() which will call
builtin_memset(), or a simple C implemenation. But as this is the only
place that triggers such a call to memset(), and this initialization
is not really needed, it's easier just to remove it.

Now, there might be more cases like this in the future, but for now
we are good.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kir Kolyshkin
f18fce45a2 maps007 test: fix for clang
CLang doesn't like explicit NULL pointer dereference:
> maps007.c:176:2: error: indirection of non-volatile null pointer will be deleted, not trap [-Werror,-Wnull-dereference]
>         *((int *) 0) = 0;
>         ^~~~~~~~~~~~
> maps007.c:176:2: note: consider using __builtin_trap() or qualifying pointer with 'volatile'
>

Apparently, we need to add volatile to make it happy.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kir Kolyshkin
2ac1cc67a5 cmdlinenv00 test: fix for clang
clang complains:
> cmdlinenv00.c:35:11: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare]
>                 if (ret < 0) {
>                     ~~~ ^ ~

The fix is to use ssize_t not size_t.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kir Kolyshkin
2479c25d32 apparmor test: fix for clang
clang complains:
> apparmor.c:86:20: error: too many arguments in call to 'checkprofile' [-Werror]
>         if (checkprofile(0) == 0)
>             ~~~~~~~~~~~~  ^

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kir Kolyshkin
514ca4e93b rtc.c test: fix for clang
clang complains:
> clang -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0  -iquote ../lib/arch/x86/include -I../lib   rtc.c ../lib/libzdtmtst.a ../lib/libzdtmtst.a -o rtc
> rtc.c:50:7: error: taking the absolute value of unsigned type 'unsigned long' has no effect [-Werror,-Wabsolute-value]
>                 if (labs(delta - 1000000 / TEST_HZ ) > 100000) {
>                     ^

Declare delta as long.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:15 +03:00
Kir Kolyshkin
21c4675304 groups.c test: fix for clang
clang complains:
> clang -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0  -iquote ../lib/arch/x86/include -I../lib   groups.c ../lib/libzdtmtst.a ../lib/libzdtmtst.a -o groups
> groups.c:22:9: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare]
>         if (ng < 0) {
>             ~~ ^ ~

Declare ng as int.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:14 +03:00
Kir Kolyshkin
4be8daa153 vdso01 test: fix for clang
clang complains:
> clang -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0  -iquote ../lib/arch/x86/include -I../lib   vdso01.c ../lib/libzdtmtst.a ../lib/libzdtmtst.a -lrt -o vdso01
> vdso01.c:305:6: error: absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value
>       [-Werror,-Wabsolute-value]
>         if (abs(ts1.tv_sec - ts2.tv_sec) > TIME_DELTA_SEC) {
>             ^
> vdso01.c:305:6: note: use function 'labs' instead

Let's use labs() indeed.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:14 +03:00
Kir Kolyshkin
fe21d145de inotify_system tests: fix for clang
When compiling with clang, it complains like this:

> clang -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0  -iquote ../lib/arch/x86/include -I../lib   inotify_system.c ../lib/libzdtmtst.a ../lib/libzdtmtst.a -o inotify_system
> inotify_system.c:323:50: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare]
>         if ((common_desc.inot < 0) || (common_desc.file < 0) || \
>                                        ~~~~~~~~~~~~~~~~ ^ ~
> inotify_system.c:324:21: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare]
>                         (common_desc.dir < 0) || (common_desc.link < 0)) {
>                          ~~~~~~~~~~~~~~~ ^ ~
> inotify_system.c:324:47: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare]
>                         (common_desc.dir < 0) || (common_desc.link < 0)) {
>                                                   ~~~~~~~~~~~~~~~~ ^ ~
> 3 errors generated.

Indeed these fields are uint32_t. As they are used to store the results of
inotify_init() and inotify_add_watch() function calls, the type should be int.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-10-24 16:00:14 +03:00