2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

1886 Commits

Author SHA1 Message Date
Konstantin Khlebnikov
fd735d8be3 zdtm: fix struct tpacket_req3 redeclaration
Linux has it since v3.2

cc -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -I../../lib   packet_sock.c ../../lib/libzdtmtst.a   -o packet_sock
packet_sock.c:70:8: error: redefinition of ‘struct tpacket_req3’
In file included from packet_sock.c:23:0:
/usr/include/linux/if_packet.h:245:8: note: originally defined here

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:36:41 +04:00
Konstantin Khlebnikov
cfa2150490 zdtm: fix comilation for non-constant PAGE_SIZE
On some systems PAGE_SIZE is declared as sysconf(_SC_PAGESIZE) in <sys/user.h>
this is non-constant expression, so it cannot be used in type declarations.

cc -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0   -c -o ns.o ns.c
ns.c:124:7: error: variably modified ‘stack’ at file scope

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:36:30 +04:00
Konstantin Khlebnikov
dccb15cc0f zdtm: fix compilation in test_msg()
cc -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0   -c -o msg.o msg.c
msg.c: In function ‘test_msg’:
msg.c:40:6: error: variable ‘len’ set but not used [-Werror=unused-but-set-variable]

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:36:21 +04:00
Pavel Emelyanov
720cab0bd8 fd: Sanitize open_fd with send_fd_to_self helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 22:27:21 +04:00
Pavel Emelyanov
8cc9477d46 fd: Rename tmp to ret in open_fd
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 22:20:21 +04:00
Pavel Emelyanov
97dba0eb8f fd: Fast path post open
Check for post_open callback presense before any other checks.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 22:07:21 +04:00
Pavel Emelyanov
84d1ffb986 fd: Move rst fd list iteration into helper
Same again -- for code to be cleaner.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 21:47:14 +04:00
Pavel Emelyanov
455aa8cd37 fd: Move ps fd list selection to separate routine
Just for cleaner (from my pov) code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 21:33:19 +04:00
Cyrill Gorcunov
ccc6b7285f parasite: Initialize fd in parasite_get_proc_fd
Otherwise I get

 | parasite.c: In function ‘parasite_service’:
 | parasite.c:383:11: error: ‘fd’ may be used uninitialized in this function [-Werror=uninitialized]
 | cc1: all warnings being treated as errors

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 18:56:24 +04:00
Andrey Vagin
30b08baa52 zdtm: open an one unlinked files two times
A few test check restoring of file descriptors to a one file struct.
Here is better to check, that a few file struct can be linked to one unlinked file.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 18:00:16 +04:00
Andrey Vagin
b11eeea381 restore: auto-unlink for ghost files (v2)
A ghost file is used for restoring descriptors of an unlinked file.
It is created, opened and deleted.

Currently ghost files are collected in root task and then removed
by crtools when everybody is restored. This scheme doesn't work,
ghost_file_list is not shared, plus tasks may live in different mount
namespace.

It was broken by the following commit:
bd4e5d2f restore: prepare shared objects after initializing namespaces

We can't just move clear_ghost_files(), because we need to wait, until
all processes have not opened a ghost file.
We can add one more global barrier or move clear_ghost_files() in
a restore code bellow an existent barrier.

Here is a better sollution, a gost file is deleted by the last user.

v2: Use the type atomic_t and fix a commit message.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 17:59:59 +04:00
Andrey Vagin
09d179602f atomic: add atomic_dec_and_test
This code is copied from the Linux kernel.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 17:55:23 +04:00
Andrey Vagin
834d996b91 crtools: add a separate type for atomic variables
It's a struct to prevent using usual arithmetic operations.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 17:55:15 +04:00
Andrey Vagin
c627c03714 mm: taking into account a gurad page to find a space for a restorer vma
Actually a gurad page is a part of a stack vma and we don't want to remap
it by a restorer vma.

The crtools on restore find a place for a restorer vma, which will not
intersect with other VMAs. A guard page is a part of a stack VMA, if
we don't take into account it, we can place the restorer VMA on it and
that case is a bug.

Would not this lead to situation where we expand stack manually? Every new
c/r cycle add one page to the bottom of stack, no? No:

strace:
mmap(0x5f4d0e0cc000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_GROWSDOWN, -1, 0) =
0x5f4d0e0cc000

/proc/PID/maps:
5f4d0e0cd000-5f4d0e0cd000 rw-p 00000000 00:00 0
.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-10 14:35:38 +04:00
Andrey Vagin
8a7dc1da8f dump: dump zombies from another PID namespace
The problem is to get a virtual pid for zombies.
This code gets two list of children from current and target pidns.
Then it removes alive task from the second list and dumps remaining zombies.

A procfs from a target pidns is needed for dumping zombies,
crtools gets it from parasite code.

v2: Fix comment and get proc fd from a root task

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-07 19:17:18 +04:00
Andrey Vagin
f3c66956b5 dump: get a file descriptor on procfs from parasite
This proc will be used for dumping zombies from pidns.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-07 19:16:36 +04:00
Andrey Vagin
9508e39e9b crtools: use pit_t for PIDs
Here is a bit mess, because we used unsigned int instead of pid_t.
A negative value is used for uninitialized PID's variables.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-07 19:16:35 +04:00
Andrey Vagin
7a65c70158 util: add ability to change a file descriptor on procfs (v2)
When a pidns is dumped, crtools uses procfs from this pidns
for getting information about zombies.

v2: Use close_proc() instead of restore_proc_fd().
    A current proc will be opened again, if it's required.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-07 19:16:34 +04:00
Andrey Vagin
5c171b1385 parasite: get a file descriptor for procfs from a target pidns (v2)
It will be used for dumping zombies.

v2: Add a fast path, if /proc belongs to the target pipns. it's usually for CT.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-07 19:16:33 +04:00
Andrey Vagin
760994c60b dump: get children by pid instead of pstree_item
pstree_item contains virtual and real pid and we want to
get children by both of this pids.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-07 19:16:31 +04:00
Andrey Vagin
f6d373cc8c restore: prevent killing of nonpositive PIDs
I don't like surprises.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-07 18:52:59 +04:00
Andrey Vagin
0ae2bad0c6 mm: mark a vma as stack, if a value of sp is in it
/proc/PID/maps can contains not up to date information about a stack vma.
A kernel marks a VMA as stack, if thread_struct->usersp is in it,
but usersp is updated, when a process calls a syscall.

This problem is occured, when we try to dump/restore a process in a loop.
When a restorer resumes a process, a restorer vma will be marked as stack.

A thread stack should not be marked as stack, because its vma is mapped
w/o MAP_GROWSDOWN.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-07 18:21:04 +04:00
Andrey Vagin
0e0da2de9e dump: use a virtual pid in names of zombie's core files
All per task images contains a virtual pid.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-07 18:19:17 +04:00
Andrey Vagin
d1b96437c9 dump: avoid extra jumps dump_one_task
It looks better and the next patches adds more checks
before memory allocations.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-07 17:48:55 +04:00
Cyrill Gorcunov
e25d115212 files: Use switch in collect_fd
For easier transition to tty c/r. We will need more
types here, thus using switch statement makes code
a bit easier to read.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-05 20:00:06 +04:00
Cyrill Gorcunov
1fd9913ffb files: Add a few comments on structures we use for files handling
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-05 19:58:30 +04:00
Cyrill Gorcunov
c9f7112595 types: Add ASSIGN_MEMBER helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-05 19:57:52 +04:00
Cyrill Gorcunov
45375d5721 restore: Rename a task item being restored to `current'
An analogue to current macro the kernel has.
The name 'me' is somehow confusing.

No func. changes.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-05 19:52:55 +04:00
Cyrill Gorcunov
d25520da35 log, restorer: Make write_ log helpers to honor logging level
Make restorer-log.c to be more similar to general log code.

 - Use current_logfd/current_loglevel variable names
 - Add ability to filter out messages which log level
   is not requested

For example, if a program get restorer without any log
level specified -- we restore it silently not printing
even a single message (if no error happened of course).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-05 17:16:38 +04:00
Andrey Vagin
97cfb70747 fown: get pid and uid-s from parasite
A task may be in another pidns and crtools should get a pid from this pidns.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-05 16:41:14 +04:00
Cyrill Gorcunov
05466cc38a restorer: Pass current log level to the arguments
Will need it to honor current log level in restorer.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-03 14:44:09 +04:00
Cyrill Gorcunov
3a00f4cdc8 log: Add log_get_loglevel() helper
Will need it to fetch log level for restorer code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-03 14:44:01 +04:00
Cyrill Gorcunov
ff7d7455e2 Introduce log-levels.h
To teach restorer code the log levels we
need a separate file for their definition.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-03 14:43:51 +04:00
Cyrill Gorcunov
3234308d62 make: Fix build bug introduced in 726a1180
In 726a1180 we made protobuf library to depend
on *.ch which is good thing but a bit incomplete.
We need a rule to generate headers if they are
missed.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-03 13:26:14 +04:00
Andrey Vagin
582df5130b unix-sk: allocate unix_sk_info from a shared pool
Because unix_sk_info contains a futex, which may be used from a few
processes, we need to collect unix sockets into shared mem regions.

Reported-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 17:24:22 +04:00
Andrey Vagin
85b5a9243d protobuf: add ability to collect objects in a shared memory (v2)
v2: s/shcollect_image/collect_image_sh/

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 17:23:50 +04:00
Andrey Vagin
67b6748f68 util: add ability to release a last piece from a shared pool (v2)
v2: s/shfree/shfree_last

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 17:23:27 +04:00
Andrey Vagin
ae70bc0ad6 net: add ability to set names for outside links of veth devices
When restoring a container crtools create veth pair inside it and then
pushed one end to the namespaces crtools live in (outside). To facilitate
the subsequent management of the otter end of the veth pair this option
is added -- one can specifu a name by which the respective end would be
visible. E.g.: --veth-pair eth0=veth101.0

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 01:07:32 +04:00
Cyrill Gorcunov
bf94ff3a26 check: Don't forget to init mountns
Otherwise fstatat fails as

> > $ ./crtools check
> > Error (sk-unix.c: 283): Can't stat socket 12547 (./var/run/sdp): Bad file descriptor

Reported-by: "Muralidhar, Rajeev D" <rajeev.d.muralidhar@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 01:04:14 +04:00
Andrey Vagin
d8af1d72fa zdtm: don't use dprintf, because it's not thread safe
pthread00 hangs if dprintf is used, and works well if fprintf is used.

One more mention of this bug is here:
http://sourceware.org/bugzilla/show_bug.cgi?id=12847

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 01:03:10 +04:00
Andrey Vagin
9ec01ff307 log: don't create a log file in a current directory
We can set a directory for log and image files.
crtools sets it as a current directory and then creates all files in it.
It works before we don't decide to change a mount name space.

I suggest to open a log dir and create files for help openat.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 01:02:30 +04:00
Andrey Vagin
855c20ac1c zdtm: don't used --log-pid by default
I added this options and I found, that it was a bad idea.
Currently crtools prints PID for each message, so
--log-pid can help if an error in the restorer code.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 01:01:40 +04:00
Andrey Vagin
234b5883b9 zdtm: show errors if a test failed
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 01:00:26 +04:00
Andrey Vagin
292d0adfdd zdtm: add forgotten tests
This tests passed already, so add them in the regular list.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 01:00:07 +04:00
Cyrill Gorcunov
726a1180aa make: Make protobuf target to depend on *.ch
Our general source code depends on headers
generated during protobuf library building
but if library is already built and *.ch
files are removed we might hit a problem
where dep files can't be generated.

Thus add explicit rule pointing out that
library depends on generated *.ch files.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 00:59:25 +04:00
Cyrill Gorcunov
40688d1945 make: Use PROTO_ prefix for protobuf targets
It's easier to handle things if we know that names
in makefiles are never intersected.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 00:59:05 +04:00
Cyrill Gorcunov
d88eebc9e0 make: Move common definitions to Makefile.inc
To eliminate code duplication.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 00:58:37 +04:00
Cyrill Gorcunov
de78c6db55 make: Don't forget to clean protobuf generated file on rebuild
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 00:58:02 +04:00
Andrey Vagin
c5f6a082b9 zdtm: use a current stack for preccesses created by clone()
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-28 23:19:45 +04:00
Andrey Vagin
d34b9004a7 restore: use a currect stack for new processes (v3)
Why do we need a new stack? We already have one and it can be used.

We need to step a bit for executing a glibc clone()

v2: Don't lose a page from a child's stack
v3: Remove the defined constant STACK_SIZE

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-28 23:19:28 +04:00