2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 21:38:16 +00:00

2617 Commits

Author SHA1 Message Date
Andrey Vagin
13e9291b51 zdtm: add a test case for pending signals
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 23:43:30 +04:00
Cyrill Gorcunov
be2773660b restore: Validate page address in restore_priv_vma_content
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 17:43:07 +04:00
Cyrill Gorcunov
b6f7d4a605 files-reg: Print file name on error
In case if there some error happened better to
know which exactly file failed on open, for example

 | Error (files-reg.c:535): Can't open file /lib64/libgcc_s-4.4.7-20120601.so.1 on restore: No such file or directory

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 17:41:47 +04:00
Cyrill Gorcunov
2eeb36647e pstree: Add more debug output for prepare_pstree_kobj_ids
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 14:49:44 +04:00
Cyrill Gorcunov
41192bbb33 restore: Return error instead of BUG_ON on image corruption
In case if there image corruption and page entry addres
is invalid -- exit out gracefully instead of BUG_ON hammer.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 14:48:55 +04:00
Cyrill Gorcunov
f81d009af8 restore: Add debug info on premapped VMA address
| Map 0x0000000000400000-0x00000000004a5000 0x0000000000000000 vma
| 	premap 0x0000000000400000-0x00000000004a5000 -> 00007f26eb898000

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 14:48:31 +04:00
Cyrill Gorcunov
6140f67326 util: Use read_fd_link helper in is_anon_link_type
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-21 00:45:45 +04:00
Cyrill Gorcunov
03040be51e protobuf: Print the image filename on error
For example

 | Error (protobuf.c:574): Unexpected EOF on /home/crtools/tools/cpt2/test/out/utsns-1.img

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-21 00:45:44 +04:00
Cyrill Gorcunov
401b4b89f1 util: Add read_fd_link helper
To fetch name of file opened from procfs.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-21 00:45:44 +04:00
Cyrill Gorcunov
b7960d7716 restore: Update error message in map_private_vma
"Can't fixup VMA's fd" is more understandable than plain
"Can't fixup fd".

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-21 00:44:33 +04:00
Cyrill Gorcunov
31122183d2 file: More detailed error on cwd restore
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-21 00:44:26 +04:00
Cyrill Gorcunov
5b8ee16c5f files: Fix id print format
Otherwise

| (00.013475)      1: Collect fdinfo pid=626 fd=4 id=0x           17008

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-21 00:43:45 +04:00
Andrey Vagin
3736fcf9f1 pipes: fix error handling
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-19 23:54:41 +04:00
Andrey Vagin
967ca651a8 tty: restore sid on master points only (v2)
If a master point has sid, it doesn't mean, that all slave points
will have sid. Look at tty03 for example:

  PID   SID TT       COMMAND
26748 26748 ?        tty03
26749 26749 pts/2     \_ tty03
26750 26750 ?             \_ tty03

The second process has not a file descriptor for the ctl tty,
but this tty is opened in tty03.

v2: If a slave point with sid has not a master point, the option
--shell-job must be set and sid isn't restored for such terminals.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-19 23:01:51 +04:00
Andrey Vagin
ef726ad51d zdtm: one more test case for controlling terminals
PID   SID TT       COMMAND
26748 26748 ?        tty03
26749 26749 pts/2     \_ tty03
26750 26750 ?             \_ tty03

The second process has not a file descriptor for the ctl tty,
but this tty is opened in tty03.

Currently CRIU can not restore this test case correctly.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-19 23:01:27 +04:00
Andrey Vagin
f2664d6524 pipe: don't reopen pipes via /proc, if it's not required
The system call open can add O_LARGEFILE.

A point is reopend for unsharing a file descriptor. So here are two
types of points. One is returned by pipe() and all other ones are
got via opening /proc/PID/fd.

Currently I know only one difference between these types, it's
O_LARGEFILE.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Tested-by: Alexander Kartashov <alekskartashov@parallels.com
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-19 23:00:59 +04:00
Alexander Kartashov
74053de77d cr-restore.c: fixed compilation errors on ARM
Use decode_pointer() to convert a virtual address into a native pointer.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-19 15:46:00 +04:00
Andrey Vagin
bce89dba4b restore: reserve the service descriptor for a control tty
I'm really lucky.

prepare_ctl_tty:
	e->fd           = get_service_fd(CTL_TTY_OFF); // -1 as fd is not set

send_fd_to_self:
if (dup2(fd, dfd) != dfd) { // tries to install sfd, but -1 == -1

tty_restore_ctl_terminal:
	if (!is_service_fd(fd, CTL_TTY_OFF))
		return fd == get_service_fd(type); // -1 = -1

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-18 23:04:09 +04:00
Cyrill Gorcunov
a9ac1b29b4 ids: Make sure the kIDs obtained from root_ids are sane
Otherwise we will get nil dereference in shared_fdt_prepare

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-18 22:42:28 +04:00
Cyrill Gorcunov
f0a4b4bfd5 ids: Make sure root ids is present in image
Here is updated one.

0001-ids-Make-sure-kIDs-is-present-in-image.patch

>From dee67b483f0ed1a6f81ebe95ae9bdf74d3ab2ad7 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov@openvz.org>
Date: Fri, 15 Mar 2013 00:43:30 +0400
Subject: [PATCH 1/2] ids: Make sure kIDs is present in image

Otherwise yield error instead of nil dereference
if we meet a broken image.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-18 22:41:56 +04:00
Andrey Vagin
31ce074b55 pipe: prevent dumping pipes in the packetized mode
This mode was introduced less than year ago:

commit 9883035ae7edef3ec62ad215611cb8e17d6a1a5d
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Apr 29 13:12:42 2012 -0700

    pipes: add a "packetized pipe" mode for writing

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-18 22:34:06 +04:00
Cyrill Gorcunov
62d532a97f mount: Add PB entries for FS types
mnt_entry::fstype is a part of image ABI, thus we need
to provide some "common" encoding outside tools would
know about this field encoding.

Thus we instorduce fstype enum in .proto file and use it
in source code as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-18 22:32:57 +04:00
Alexander Kartashov
2ce60f1dbc page-xfer.c: fixed format strings
This patch generalizes format strings in the file page-xfer.c
to prevent format string warnings on ARM.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-18 22:31:45 +04:00
Andrey Vagin
e101b381c3 restore: handle of errors from setting fd flags
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-18 22:29:22 +04:00
Andrey Vagin
17b05ab4a5 files: restore file descriptor flags on the correct fd
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-18 22:26:59 +04:00
Cyrill Gorcunov
2e20b48051 page-pipe: Don't forget to free page pipe buffer itself
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-18 22:26:04 +04:00
Cyrill Gorcunov
6f40cfb506 files-reg: Use pr_err instead of pr_perror if fd not found
Otherwise

 | (00.002843)      1: Error (files-reg.c:522): Can't find regfile for 0
 | : Success

which is inappropriate here.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-18 22:25:32 +04:00
Andrey Vagin
5f5306eda9 crtools: remove declaration of rt_sigset_t
Actually rt_sigset_t and k_rtsigset_t are the same

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-15 19:11:25 +04:00
Andrey Vagin
c776580dc0 restore: find VMA for each restored page
Otherwise ppage_bitmap and page_bitmap will be updated for wrong VMA

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-15 18:24:27 +04:00
Pavel Emelyanov
cc3a3c475b dump: Fix one-page mapping dump
The iov array for 1-page mapping would be zero. Fix this silly mistake.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-15 18:23:19 +04:00
Pavel Emelyanov
39402af71a page-xfer: Simplify one page-pipe dumping
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-15 18:23:19 +04:00
Pavel Emelyanov
4074a87637 shmem: Rework dumping code to use page-pipe and -xfer engines
This makes it easier to merge with anon vmas dumping and makes use of
page server for shared memory.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-15 18:23:19 +04:00
Pavel Emelyanov
6c83c24242 shmem: Simplify error paths
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-15 18:23:19 +04:00
Pavel Emelyanov
94c6d77340 shmem: Split shmem dumping code into two
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-15 18:23:19 +04:00
Pavel Emelyanov
9486946b81 zdtm: Return x perms back
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-15 17:31:21 +04:00
Cyrill Gorcunov
f3e5fd7155 ids: Don't forget to setup task state in write_img_inventory
Need to have proper fake-item state to make this code work ok:

get_task_ids
if (item->state != TASK_DEAD) {
	ret = dump_task_kobj_ids(item);
	if (ret)
		goto err_free;

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 21:24:48 +04:00
Cyrill Gorcunov
4159cd5de6 cr-restore: Report the mem size if mmap failed
Without patch

 | Error (cr-restore.c:414): Unable to reserve memory: Invalid argument

with applied

 | Error (cr-restore.c:414): Unable to reserve memory (0 bytes): Invalid argument

more convenient for debugging.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 19:41:31 +04:00
Cyrill Gorcunov
8dd32ad018 image: Fixup error paths in check_img_inventory
- Free unpacked PB data
 - Close file descriptor

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 19:38:57 +04:00
Andrey Vagin
a4f4ca73a1 zdtm: check unshared descriptors for one end of a pipe
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 19:36:17 +04:00
Andrey Vagin
7dc741f4f8 app-emu/lxc: create /var/run/netns/
In Fedora /var/run is on tmpfs, so all directories should be
recreated each times.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 19:35:36 +04:00
Pavel Emelyanov
d36480ed05 mem: Raise the page images IDs base for page server
Currently shmem generates page images in parallel
with page server and IDs may intersect. Fix this by
making page server create larger IDs.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 18:28:38 +04:00
Pavel Emelyanov
36b96d1e8a zdtm: Test how page server works
When -p is used, launch page server in the same dir as
crtools dump is to get fill dump in it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 18:16:46 +04:00
Pavel Emelyanov
213faeae6d mem: Introduce page server
The page server is a process, that is about to get pages over
the network and put them into pagemap- + pages- images. Right
now what it does is simply get the data and puts it into the
image files. When we have dirty set tracking in the kernel the
page server will have to collect "page changes" and properly
integrate them into images.

Running crtools with page server is like this:

dst_node# crtools page-server --port <port> -D dump/ ...
src_node# crtools dump -t <pid> --page-server --address <dst_node> --port <port> -D dump/ ...

After this images from dst_node/dump/ and src_node/dump/ should
be put into one place and tasks can be restored out of it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 18:16:44 +04:00
Pavel Emelyanov
02fc86958e mem: Abstraction layer for putting pages into image
We'll send them over network soon, so prepare abstraction layer for
this. Shmem is not on this scheme yet.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 18:16:43 +04:00
Pavel Emelyanov
8801f59615 mem: Protobuf format for page dumps
Since now we drain pages out of parasite, we can invent any format for
page dumps. Let is be ... prorobuf one! :)

Another thing to keep in mind, is that we're about to use splices and
implement iterative migration, so it's better to have actual pages be
page-aligned in the image.

And -- backward compatibility. That said the new format is:

1. pagemap-... file which contains a header (currently with a ID of
   the image with pages, see below) and an array of <nr_pages:vaddr>
   pairs. The first value means "how many pages to take from the
   file with pages (see below)" and the second -- where in the task
   address space to put them. Simple.

2. pages-... file which containes only pages one by one (thus aligned
   as we want).

This patch breaks backward compatibility (old images with pages wil
be restored and then crash). Need to do it before v0.5 release.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 18:16:41 +04:00
Andrey Vagin
a59fd3533f zdtm: make datagen/datachk faster for big chunks
Generate random data only for buffers with sizes less than FAST_SIZE
If a size of buffer is more that FAST_SIZE, the first FAST_SIZE bytes
are filled by random generator and then this chunk is used as pattern
for all other chunks.

With out this patch:
$ time bash -x test/zdtm.sh static/maps04
real	0m16.777s
user	0m0.054s
sys	0m0.724s

With this patch:
$ time bash -x test/zdtm.sh static/maps04
real	0m1.865s
user	0m0.128s
sys	0m0.745s

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-06 00:34:02 +04:00
Cyrill Gorcunov
28f063ab9c zdtm: ipc_namespace: Bound min/max for mqueue/msg_max
Otherwise
 | 11:03:13.524: 19446: ERR: ipc_namespace.c:212: Can't write 0 into /proc/sys/fs/mqueue/msg_max (errno = 22 (Invalid argument))
 | 11:03:13.524: 19446: ERR: ipc_namespace.c:273: Failed to randomize ipc namespace tunables (errno = 22 (Invalid argument))
 | 11:03:13.524: 19446: ERR: ipc_namespace.c:336: Failed to randomize ipc ns before migration (errno = 22 (Invalid argument))
 | 11:03:13.527: 19445: ERR: test.c:298: Test exited with unexpectedly with code 1 (errno = 4 (Interrupted system call))

https://bugzilla.openvz.org/show_bug.cgi?id=2530

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-06 00:32:07 +04:00
Andrey Vagin
50a20dfbdc zdtm: fix race in test_waitsig for multithreaded tests
A signal can be handled by non-leader thread and sigsuspend
will not be woken up.

kill can send signals to a specified thread, so a futex is used for
synchronization.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-06 00:31:14 +04:00
Cyrill Gorcunov
38c699a754 arch: Add mssing \Newline to get_task_regs message and print pid as well
It's leftover from early times.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-06 00:30:25 +04:00
Cyrill Gorcunov
8a8c38b6a3 image: Move magic numbers to magic.h
This allows to reuse magic numbers outside of crtools code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-06 00:29:29 +04:00