Commit graph

6815 commits

Author SHA1 Message Date
Kirill Tkhai
7ea3ed952f sockets: Fix int ino parameter of socket functions
Real ino is u32, while parameters are int. Fix that
to prevent crap with overflows.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:12:26 +03:00
Andrew Vagin
52d6ae030a cgroup: typo fix
CID 163487 (#1 of 1): Unused value (UNUSED_VALUE)
assigned_pointer: Assigning value from old_name to pe->name here, but that stored value is overwritten before it can be used.

Cc: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:12:26 +03:00
Mike Rapoport
d93119e94c criu: page-read: read pagemaps at open time and keep them in memory
xemul: There's bfd over pagemap images:

mike: Yes, but the bfd caches raw protobuf data, while the in-memory pagemap
      caches unpacked PagemapEntrie's. There's indeed some duplication, but
      you anyway have to go through 'bread -> unpack' to use pagemap.

      Also we read the entire pagemap and then close the image thus freeing
      the bfd cache.

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:12:26 +03:00
Mike Rapoport
462e089c6a criu: image: add img_raw_size helper
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:12:26 +03:00
Andrew Vagin
b78565e991 sk-inet: add a missed space in a error message
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:12:26 +03:00
Andrew Vagin
3f57b178e1 netfilter: use pr_perror only when errno has to be printed
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:12:26 +03:00
Andrew Vagin
39e4073daf zdtm/socket_aio: add the nouser flag
======================= Run zdtm/static/socket_aio in h ========================
Makefile:295: target 'mnt_enablefs.pid' given more than once in the same rule
Start test
Makefile:295: target 'mnt_enablefs.pid' given more than once in the same rule
./socket_aio --pidfile=socket_aio.pid --outfile=socket_aio.out
Run criu dump
=[log]=> dump/zdtm/static/socket_aio/24/1/dump.log
------------------------ grep Error ------------------------
(00.003450) Error (util.c:665): exited, status=3
(00.009104) Error (util.c:665): exited, status=3
(00.024564) Error (util.c:665): exited, status=3
(00.024598) Error (netfilter.c:88): Iptables configuration failed: Success
(00.024625) Error (cr-dump.c:1297): Dump files (pid: 24) failed with -1
(00.025117) Error (cr-dump.c:1605): Dumping FAILED.
------------------------ ERROR OVER ------------------------
Wait for zdtm/static/socket_aio to die for 0.100000

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:12:26 +03:00
Andrew Vagin
be663b002d test/crit-recode: skip images with zero size
Now we have many tests with the crfail flags. When criu dump fails,
criu may create image files, but doesn't fill them.

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:12:26 +03:00
Andrew Vagin
877558fc8c test/crit-recode: skip rule-%d.img
These images are generated by the ip tool.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:12:26 +03:00
Andrew Vagin
c91c8a5e69 files: simplify fchroot()
We can call fchdir into the taget directory and call chroot(".")

v2: fix one more comment speaking about proc

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:12:26 +03:00
Adrian Reber
2fdef836a5 criu: add an option to skip in-flight connections
Trying to migrate containers with tomcat and running ab as a test client
(ab -n 1000000 -c 20 http://url/to/test) criu sometimes exited with an
error if in-flight connections were detected. Criu can handle sockets
listening and with established connection. In-flight connections can
happen on sockets which do not yet have a full established connection
(SYN, SYN-ACK, and the last ACK is missing).

This adds a new option to criu:

 --skip-in-flight  this option skips in-flight TCP connections.
                   if TCP connections are found which are not yet completely
                   established, criu will ignore these connections in favor
                   of erroring out.

With this option criu will skip sockets in this state and let's the client
handle the re-connection.

Signed-off-by: Adrian Reber <areber@redhat.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:12:24 +03:00
Cyrill Gorcunov
85578bd5e8 rpc: Add interface --freeze-cgroup option
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:40 +03:00
Andrew Vagin
55de67a7fa zdtm/shm-unaligned: don't overriding recipe for target 'shm-unaligned.pid'
Makefile:305: warning: overriding recipe for target 'shm-unaligned.pid'
Makefile:290: warning: ignoring old recipe for target 'shm-unaligned.pid'
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:40 +03:00
Andrew Vagin
c48b5d1142 proc_parse: don't read an uninitialized pointer
CID 161665 (#1 of 1): Uninitialized pointer read (UNINIT)
14. uninit_use: Using uninitialized value vma.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:40 +03:00
Andrew Vagin
549d71f3cc aio: don't leak memory
CID 161664 (#1 of 1): Resource leak (RESOURCE_LEAK)
11. leaked_storage: Variable re going out of scope leaks the storage it points to.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:40 +03:00
Andrew Vagin
2a835eb8d1 zdtm: remove or replace noauto on crfail where it's possiable
CRIU dump should fail if criu can't handle something.

v2: add a separate patch to remove noauto for a few tests

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:40 +03:00
Andrew Vagin
99c6e840fc zdtm: remove the noauto flags for tests which can be executed
Looks like noauto was set by mistake for these tests

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:40 +03:00
Kirill Tkhai
eec3f49b4d dump: Allocate root_item before run pre-dump scripts
This allows pre-dump scripts to know CT root_item pid
and enter into its namespaces.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:40 +03:00
Tycho Andersen
b734cd4003 tests: add a test for cgroup kernel controller props
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:40 +03:00
Tycho Andersen
c38e18432d cgroups: add support for c/r of the devices cgroup
This one is a little big ugly, see comments for details. At some point we
should invent a better way to do these special cases, since we have them
for freezer, cpuset, and now devices. Perhaps something like fstype, where
you can ask the cgroup how to restore itself.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:40 +03:00
Tycho Andersen
a827d386e5 cgroup props: update controllers list and props list
In particular add support for the new controllers:

* perf_event (nothing here, but may be used by the perf tool so we should
  keep it)
* net_cls
* net_prio
* pids

Also add support for many more memory properties that were not implemented
in the first pass, but the container may use.

Note that this commit omits the "devices" controller, because that needs to
be checkpointed and restored in a special way.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:40 +03:00
Tycho Andersen
a6587ef404 cgroup props: ditch notify_on_release from individual controllers
This is listed as a global prop, so we don't need to list it individually.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:40 +03:00
Tycho Andersen
e30f45d3a0 cgroup props parser: allow empty property lists
We'll use this in the next patchset where we want to dump global properties
of the freezer cgroup, but none of the special ones for this cgroup,
because they're handled separately.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:40 +03:00
Mike Rapoport
d5095c00b5 criu: page-xfer: intorduce helpers for sending IOVs
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:40 +03:00
Mike Rapoport
afa9d8df51 criu: page-xfer: move code aroud
to remove forward declarations and create better grouping

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:39 +03:00
Kirill Tkhai
673ffadeef sk-unix: Move out interconnected pair setup
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:39 +03:00
Kirill Tkhai
c085d6af6d unix: Link all sockets in unix_sockets list
List "unix_sockets" is used to link external sockets.
Change this, to link all unix sockets there. To differ
really external sockets in fix_external_unix_sockets(),
we may check for socket's already_dumped value.

This may be useful to traverse over all unix sockets
in a namespace.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:39 +03:00
Kirill Tkhai
c58a2867cb pstree: Export current
Export current to allow to use find_unused_fd()
from everywhere.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:39 +03:00
Dmitry Safonov
a2de3eb831 travis: add coveralls.io support
I suggest to add support for coveralls.io.
It can't show all coverage, as we don't run all tests on travis,
but still everyone who forked CRIU can see instant coverage of
his Travis build. As a nice feature, it will show code cover
increasing/decreasing just after you push a commit - which
could give you a nice hint about content of a new tests.
For this feature, we need to build CRIU with `make GCOV=1`,
which adds --coverage and disables optimizations.

The resulting report looks like this:
https://coveralls.io/builds/6439346
I was thinking about codecov.io also, but it has fewer community,
less fixed issues on github - so I choose this service.

Just a random fun fact:
file-ids.c covered completely on tests, except -ENOMEM return.
Maybe it worth to run fault injections tests on Travis.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:39 +03:00
Cyrill Gorcunov
e47c3684fa test: static, fanotify00 -- Don't compare @s_dev in test
The s_dev as well as mnt_id may change during container
migration, so exclude them from the comparision.

Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:39 +03:00
Andrew Vagin
f1015e4cdf zdtm/tty*: wait when processes complete a preparation stage
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:39 +03:00
Dmitry Safonov
a8423135c5 parasite: drop unused PARASITE_CMD_DAEMONIZED
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:39 +03:00
Andrew Vagin
66299a0065 zdtm: use flake8 to verify zdtm.py
and fix various warnings. For example, we mix tab and space indentations.

v2: add flake8.cfg

Cc: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:09:35 +03:00
Mike Rapoport
93991e6678 criu: page-read: remove unnecessary forward declaration
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:07:38 +03:00
Mike Rapoport
cd7928d371 criu: page-read: make seek_pagemap_page a method of page_read
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:07:37 +03:00
Andrew Vagin
51970afa5e zdtm: don't fail if a test changed cwd
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:05:53 +03:00
Andrew Vagin
b599cda15b files: use pr_err instead of pr_perror
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:05:53 +03:00
Andrey Vagin
1cd1da9ca1 zdtm/ptrace_sig: don't print from signal handlers
It can be dead-lokced:
 #0  0x00007fafbf49f6ac in __lll_lock_wait_private () from /lib64/libc.so.6
 #1  0x00007fafbf44af1c in _L_lock_2460 () from /lib64/libc.so.6
 #2  0x00007fafbf44ad57 in __tz_convert () from /lib64/libc.so.6
 #3  0x00000000004022e2 in test_msg (format=0x404508 "Receive signal %d\n") at msg.c:51
 #4  <signal handler called>
 #5  0x00007fafbf3f2483 in __GI__IO_vfscanf () from /lib64/libc.so.6
 #6  0x00007fafbf408f27 in vsscanf () from /lib64/libc.so.6
 #7  0x00007fafbf4032f7 in sscanf () from /lib64/libc.so.6
 #8  0x00007fafbf449ba6 in __tzset_parse_tz () from /lib64/libc.so.6
 #9  0x00007fafbf44c4cb in __tzfile_compute () from /lib64/libc.so.6
 #10 0x00007fafbf44ae17 in __tz_convert () from /lib64/libc.so.6
 #11 0x00000000004022e2 in test_msg (format=format@entry=0x40458c "PASS\n") at msg.c:51
 #12 0x0000000000401ceb in main (argc=<optimized out>, argv=<optimized out>) at ptrace_sig.c:172

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Tested-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:05:53 +03:00
Cyrill Gorcunov
7e2f7296bd cg: rpc -- Fix typos for custom cgroup props engine
Seems @rpc-> part has been sneaked out (forgot to
push into index), as result it built fine locally,
but not when applied from the patch.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:05:53 +03:00
Cyrill Gorcunov
900e71cbec cg: rpc -- Add bindings for custom cgroup props engine
For handling  --cgroup-props, --cgroup-props-file and
--cgroup-dump-controller from RPC interface.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:05:52 +03:00
Pavel Emelyanov
92486c9015 coredump: Rename dir to coredump
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:04:58 +03:00
Andrew Vagin
308741d059 mount: detect sibling mounts correctly
I found the meaning of comparing basename-s for mounts in mount_qual(),
which was removed in v2.1-49-gbcf40bf.

I think it was an attempt to detect siblings (propagated mounts).

Actually it's wrong to compare only basenames for such mounts and
we need to generate full paths for them.

For example:
28 25 0:25 /	/sys/fs/cgroup/devices rw shared:10 - cgroup cgroup rw,devices
29 28 0:49 /	/sys/fs/cgroup/devices/101/xxx/yyy ...
38 35 0:25 /101 /sys/fs/cgroup/devices/ rw master:10 - cgroup cgroup rw,devices
39 38 0:49 /	/sys/fs/cgroup/devices/xxx/yyy ...

28 and 38 are in the one shared group. 29 and 39 siblings and probably
one of them was mounted and another one was propagated.

This patch adds a function to generate a sibling mount point and
use it to propagate mounts

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:04:58 +03:00
Andrew Vagin
fdeba04e86 mount: move functions to handle paths in a separate file
mount.c is too big already and the next patch adds one more such functions
with a few unit test, so it's better to add one more source file.

v2: fix compilation on arm and ppc
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:04:56 +03:00
Pavel Emelyanov
b0049beacc tcp: Move call to prepare socket
The restore_tcp_queues() will become int sk agnostic.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:04:00 +03:00
Pavel Emelyanov
e931c75734 tcp: Make reuse crit section wider
This lock will have to be moved into the libsocr which is
not nice, so pull this out of the restore_tcp_queues.

And, since we're extending the section anyway, pull it away
from sk-tcp.c at all. Makes the code a little bit cleaner.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:04:00 +03:00
Ruslan Kuprieiev
947358a9ed test: add manual test for criu-coredump
Convert criu images to coredumps and check if they are
readable by readelf.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:04:00 +03:00
Ruslan Kuprieiev
e569e46b31 test: fix manual crit test
In automated tests we use test/crit-recode.py because of performance
benefits(no need to launch python interpreter more than once), but
manual test is still useful for manual testing, so lets make it
work again.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:04:00 +03:00
Ruslan Kuprieiev
8a71a4a27d criu-coredump: merge criu-coredump project
This patch introduces a new subproject called "criu-coredump". The name
is pretty much self-explanatory, it allows generating coredumps from
criu images. Coredumps are readable and usable by gdb. The structure is
something in the middle of kernel-generated and gdb-generated core dumps.

This is a first iteration of core-dump patch series. It introduces
ability to generate gdb-operatable core dump only for x86_64 machines.
To support other architectures there will be a set to introduce proper
structures for notes section of the core dump. It is also worth noting,
that we still leave some notes(SIGINFO primarily) not fullfilled, as
I still need to figure out what to put in there in our case, where no
signal is involved in triggering core dump generation and other
caveats like zeroed vvar(we have problems with it withing CRIU itself
as well as gdb has some difficalties with it) and vsyscall vmas.
One can already use produced core dump with gdb, there is also
a quick simple demo https://asciinema.org/a/18936 .

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:04:00 +03:00
Cyrill Gorcunov
b28f93efaf cg: Add documentation about dumping specified controllers
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:04:00 +03:00
Cyrill Gorcunov
45dc87b819 cg: Add ability to dump specified controllers only
For example in containers case there might be a number
of controllers mounted on the node which we should not
carry inside image when container is migrated. So
add ability to dump predefined controllers only
specified via command line --cgroup-dump-controller
option.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-06-28 13:04:00 +03:00