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

2617 Commits

Author SHA1 Message Date
Andrey Vagin
ab2d10c247 zdtm: move file_locks test-cases to the common list
In this case they will be executed in other name-spaces.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-21 17:35:08 +04:00
Andrey Vagin
d6ae662374 cr-dump: call stat for /proc/pid/fd/X directly
This patch can be committed instead of:
[PATCH 1/6] cr-dump: move parasite_drain_fds_seized out of dump_task_files
[PATCH 2/6] cr-dump: fix dumping file locks in a mount namespace

readlink is not required here and a file can be unavailable,
if a process is in another mnt namespace

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-21 17:34:27 +04:00
Cyrill Gorcunov
8587f7dec1 zdtm: sched_prio -- Add missing headers
On glibc-2.16 I'm getting

 | sched_prio00.c: In function ‘main’:
 | sched_prio00.c:48:3: error: implicit declaration of function ‘setpriority’ [-Werror=implicit-function-declaration]
 | sched_prio00.c:48:19: error: ‘PRIO_PROCESS’ undeclared (first use in this function)
 | sched_prio00.c:48:19: note: each undeclared identifier is reported only once for each function it appears in
 | sched_prio00.c:60:3: error: implicit declaration of function ‘getpriority’ [-Werror=implicit-function-declaration]

fix it adding headers needed.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-21 17:32:18 +04:00
Pavel Emelyanov
475bb1e775 rst: Evaluate per-task clone mask early
When we've read all pstree-items and their ids we
can get the desired clone-flags early and avoid all
these dances with flag calculations in fork_with_pid
and company.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-19 01:16:19 +04:00
Pavel Emelyanov
10b338c5db fdt: Move shared-fdt structure preparation into separate fn
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-19 00:30:42 +04:00
Pavel Emelyanov
6045ca0e31 rst: Cehck for objects sharing before attaching helpers to tree
Helpers don't have any IDs on board and thus checks for "is
my X shared with parent" will be wrong.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-19 00:04:04 +04:00
Pavel Emelyanov
7ee4c484ae dump: Fix dump_zombies declaration
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 23:34:30 +04:00
Pavel Emelyanov
792bf0c494 cr: Fix namespaces restore from older images
In old images we had no clue whether the root task is to be
created in new namespaces. Remember using the --namespaces
option for explicitl specification of this fact.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:26 +04:00
Pavel Emelyanov
ac845bd1d8 cr: Obsolete the --namespaces option
It's no longer required to use this option -- two currently
supported cases (tasks on host and tasks in containers) can
be detected automatically. Keep this option for future.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:16 +04:00
Pavel Emelyanov
a46831aee9 cr: Detect namespaces presence automatically
Introduce the current_ns_mask variable, that collects info about
which namespaces tasks being dumped and to be restored live in.

For simlicity all tasks are supposed to live in one set of spaces.
This should be fixed eventually.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:10 +04:00
Pavel Emelyanov
2f22c68849 dump: Collect tasks' IDs early
It's required to know whether the root task lives in
namespaces very very early (e.g. -- to lock the network
properly). Thus we have to collect task IDs right at
the time we collect the tasks themselves.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:06 +04:00
Pavel Emelyanov
1a60975622 img: Save crtools process IDs in inventory
On restore we'll need to know whether the root task should be
cloned in new set of namespaces. It's natural to do it by
comparing root ids with some "other-world" IDs.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:02 +04:00
Pavel Emelyanov
15999f6b2f ids: Split routine that dumps task's IDs
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:24:55 +04:00
Pavel Emelyanov
2105e18eee core: Save tasks' namespaces IDs in the ids image
The recent kernels allow to get namespaces IDs by reading proc-ns links.
Use this to generate IDs for tasks' namespaces (I do generate them, since
IDs provided by kernel look ugly :( ).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:18:33 +04:00
Andrey Vagin
47c98c63d7 syscall: add sigqueueinfo, signalfd and pread
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:50:51 +04:00
Alexander Kartashov
2d70f89664 protobuf: cast the result of the macro pb_repeated_size to size_t
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:43 +04:00
Alexander Kartashov
b97e24e3fb cr: introduced the functions decode_pointer() and encode_pointer()
These functions are designated to convert a native pointer
to uint64_t used to store a virtual address in protobuf messages
and vice versa in a machine-independent way.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:43 +04:00
Alexander Kartashov
bde8beca71 cr: use uint64_t to represent a virtual address
The patch reverts the commit 58064d9b723bd5a5e5910ed752fb3b19cc962fa8.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:42 +04:00
Alexander Kartashov
ac97f9077a parasite-syscall.c: don't infect a VMA above TASK_SIZE
If a task executes a non-userspace code (that sometimes takes place on ARM)
while being seized the subsequent infection with the syscall blob fails
because ptrace fails to write to the VMA the PC is in.

The patch modifies the function get_vma_by_ip() to check the PC of the task
being seized is below the TASK_SIZE boundary. If the check fails
the first suitable VMA is infected.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:41 +04:00
Alexander Kartashov
bd10da7869 print_hex_l: don't print more than 8 hex digits on a 32-bit machine
This patch prevents compilation warnings about shift overflow on ARM.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:40 +04:00
Alexander Kartashov
ae89891279 cr: introduced the macro BITS_PER_ULONG
The macro specifies the size of the machine pointer explicitly.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:39 +04:00
Alexander Kartashov
3bb6d9f4fb cr: use the length modifier %z to print an integer of the type size_t
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:38 +04:00
Alexander Kartashov
4f7161dd4c file-lock.c: generalized format strings
This patch fixes format strings in newly added code.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:37 +04:00
Cyrill Gorcunov
6586c4685c fsnotify: Don't fail on old versions where no inotify/fanotify image present
Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 19:20:41 +04:00
Kinsbursky Stanislav
e0e258c344 ipc: restore IPC objects credentials
This part was lost after update to "sysctl" interface for IPC object ID
specifying (previous, currently obsolete, interface was able to pass proper
credentials with KEY change) .

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 16:00:48 +04:00
Kinsbursky Stanislav
dae5f928f7 ipc: do some renaming to make the code looks more pleasant
Signed-off: Stanislav Kinsbursky <skinsbursky@openvz.org>

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 16:00:47 +04:00
Andrey Vagin
ce4c8c1d31 crtools: don't prevent to dump memory mappings on /dev/zero (v2)
Oracle has such mappings.

v2: add check, that a file is a character device

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:46:33 +04:00
Qiang Huang
4a70646335 zdtm: add flock file lock's test case
We check shared lock, exclusive lock and mandatory-read lock for flock
file locks. After restore, by parsing /proc/locks file, we check if
the process holds the same file locks as it was dumped.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:42:50 +04:00
Qiang Huang
a52a66f652 zdtm: add posix file lock's test case
We check read lock and write lock for posix file locks. After restore,
we use fcntl(fd, F_GETLK, &lock), to see if the file is hold the same
lock as it was dumped.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:42:46 +04:00
Qiang Huang
882005a0ed doc: update the manpage document for file lock c/r
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:42:44 +04:00
Qiang Huang
4bf96b6680 crtools: restore flock&posix file locks
According to the file lock information from the image, we recall
flock or fcntl with proper parameters, so we can rehold the file
locks as we were dumped.
We only support flock and posix file locks so far.

Changelog since the initial version:
a. Use prepare_file_locks instead of restore function directly.
b. Fix some bugs.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:42:43 +04:00
Qiang Huang
95801808aa crtools: dump flock&posix file locks
Dump file locks' necessary entries to the image, we only support flock and
posix file lock right now.

Changelog since the initial version:
We got file lock info from global list, so the dump_task_file_locks
can be much simpler.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:42:41 +04:00
Qiang Huang
286801d4c1 crtools: collect and check file locks
We collect all file locks to a golbal list, so we can use them easily
in dump_one_task. For optimizaton, we only collect file locks hold by
tasks in the pstree.

Thanks to the ptrace-seize machanism, we can aviod the blocked file lock
issue, makes the work simpler.

Right now, the check handles only one situation:
-- Dumping tasks with file locks hold without the -l option.

This covers for the most part. But we still need some more work to make
it perfect robust in the future.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:42:07 +04:00
Qiang Huang
b08836cc51 pstree: add a function to check if a task is in pstree
Sometimes, when we parse some global info files, we can only care about
tasks which are taken into dump(such as file locks), which means their
pids are in the pstree.
So a function like this would be help.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:40:01 +04:00
Qiang Huang
de54cd4385 crtools: add image contents for filelocks
Some contents needed by filelock's image.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:40:00 +04:00
Qiang Huang
0de267ccdc crtools: add a callback to show filelocks-%d.img
Add a callback for filelock's image show.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:38:40 +04:00
Qiang Huang
c9797cfa27 protobuf: add a new description for saving file-lock
We need a new protobuf description for file-lock.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:38:11 +04:00
Qiang Huang
8f96ff85ff crtools: Add --file-locks option
Add --file-locks/-l option to support handling file locks, for safety,
only used for container.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:36:47 +04:00
Alexander Kartashov
5c01178279 protobuf: replace the constant 4294967295 with 0xFFFFFFFF in generated sources
This workarounds a compilation warning on ARM:

	packet-sock.pb-c.c: In function 'packet_sock_entry__init':
	packet-sock.pb-c.c:98:3: error: this decimal constant is unsigned only in ISO C90 [-Werror]
	packet-sock.pb-c.c: At top level:
	packet-sock.pb-c.c:318:1: error: this decimal constant is unsigned only in ISO C90 [-Werror]

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 19:41:01 +04:00
Alexander Kartashov
3c16edc0bd cr: generalized format strings
This patch replaces the format specifier %ld with PRIx64
in the following places:

* the format string argument of the functions scanf() and printf(),
* in the macros GEN_SYSCTL_*_FUNC.

We need explicit specification of the integer size there.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 19:20:08 +04:00
Alexander Kartashov
7997f673be restorer: introduced the struct krlimit
The layout of the struct rlimit depends on the value
of the macro FILE_OFFSET_BITS. If FILE_OFFSET_BITS is 64
the userspace and kernel definitions becomes incoherent
on a 32-bit platform.

The struct krlimit representing the kernel version of
the struct rlimit is introduced to address the issue:
the function restore_rlims() is fixed to convert between
the userspace and kernel representations of the struct.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 19:15:40 +04:00
Alexander Kartashov
d63ed7a443 x86: fixed the value of the macro TASK_SIZE to match the kernel one
This makes it possible to use TASK_SIZE instead of TASK_SIZE_MAX.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 19:10:58 +04:00
Alexander Kartashov
95bcaed4cb include/restorer.h: use the alias UserRegsEntry for UserX86RegsEntry
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 19:10:25 +04:00
Cyrill Gorcunov
d5bdf54eab fsnotify: fanotify -- Fix object read procedure
I occasionally read FanotifyMarkEntry object as InotifyWdEntry
in collect_one_fanotify_mark, this didn't trigger a bug in test
since the events are still occured (and before protobuf file
refine the formats were close to each other), which means
the fanotify00 test-case need to be updated (which is addressed
in further patch).

And don't forget to init fields.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 18:19:43 +04:00
Cyrill Gorcunov
29c940072a fsnotify: inotify -- Don't forget to init fields of fsnotify_mark_info
The object is allocated with malloc. The lack of initialization
is not problem at moment since we assign members in
collect_inotify_mark unconditionally but it might cause problems
in future so better to init it as early as possible.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 18:19:42 +04:00
Cyrill Gorcunov
c28573fda1 zdtm: fanotify00 -- Make test to check all flags we c/r
Just reading if event entry exist in buffer is not
enough we rathee need to be sure that all flags
and bits are recovered well.

For this sake we parse fdinfo before and after the
c/r sessions and compare results.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 18:19:05 +04:00
Cyrill Gorcunov
12b579bac0 fsnotify: fanotify -- Take into accout global flag assigned to fanotify object
Just missed it in first place.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 18:18:45 +04:00
Cyrill Gorcunov
27c8a3cf65 fsnotify: Rename collect_one_wd to collect_one_inotify_mark
To be consistent with naming (we have collect_one_fanotify_mark
helper already).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 18:18:03 +04:00
Cyrill Gorcunov
d6664eea4a proc-parse: Add alloc_fhandle/free_fhandle helpers
This removes code duplication. There is no strong
need for free_fhandle but I decided to add it to
be consistent with alloc/free handlers.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 18:17:46 +04:00
Cyrill Gorcunov
8573f5ec53 fsnotify: Drop parasite trailing \Space
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 18:17:23 +04:00