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

1696 Commits

Author SHA1 Message Date
Pavel Emelyanov
da8dbe43bc rst: Move premmaped* variables on rst_info
This thing on pstre_item was created to carry task-specific
information across the "restore" code-flow.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 13:19:01 +03:00
Cyrill Gorcunov
7eb33a76a8 ghost-files: Save device and inode in image
Because we need to lookup for ghost files from
inotify system where we only have device/inode
as a key, we save dev/ino in ghost image entry.

Note we use in-kernel format for device to be
consistent with inotify and mount related
code base.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 11:11:10 +04:00
Cyrill Gorcunov
7bd34c699e files-reg: Add a few helpers to access ghost files remaps from inotify
The remap_put will be needed to defer unlinking of ghost files
if they are referred from inotify system.

The lookup_remap is needed to figure out if the watch
target the inotify has present in ghost files list.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 11:10:14 +04:00
Cyrill Gorcunov
746ac3fee5 files-reg: Move struct file_remap to the header
We will need to use it in inotify code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 11:10:10 +04:00
Pavel Emelyanov
679c5326c3 ptrace: Remove dead code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 23:33:06 +04:00
Andrey Vagin
caf875454f signal: fix logig about SIGMAX (v2)
A value of signo is in [1, SIGMAX].
Currenly signals are enumirated from 1 to SIGMAX, but SIGMAX
is not included. This patch fixes this mestake.

v2: * save backward compatibility
    * set a correct value of SIGMAX = 64. It can not be in a
    separate patch, because a format is changed again.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 19:26:54 +04:00
Pavel Emelyanov
e0d0dc821d rst: Rename task_entries->nr to ->nr_threads
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 17:22:45 +03:00
Pavel Emelyanov
70af6cdd62 rst: Helper for restore stage barrier
When finishing a stage we have to report this (decrement the
number of tasks in stage) and wait while stage switch. Write
a helper that does both.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 16:59:41 +03:00
Pavel Emelyanov
1a7c7d0404 fd: Consolidate . and .. checks in various readdir callers
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-29 21:12:51 +03:00
Andrey Vagin
d08905bf89 log: add pr_err_once
This function prints an error message only once.
[xemul: change ({}) to do {} while (0)]

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-29 17:43:06 +04:00
Pavel Emelyanov
03d0758df3 Revert "net: Introduce netdev index to name resolver"
This reverts commit ef3771d566dacb8ee9fe71b744d56f08674fe3db.
With new SO_BINDTODEVICE getting API it's not required.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-28 20:27:16 +03:00
Cyrill Gorcunov
aa53547aed bitops: Add for_each_bit helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-26 18:38:15 +04:00
Andrey Vagin
5d712b7430 cr-restore: remove unshared pages from inherited private mappings (v2)
A parent process can change a few pages after forking a child and
all this pages should not be avaliable from the child.

Each vma has a bitmap of existent pages. Parent's and child's bitmaps
can be compared and all pages which are not present in a child bitmap
are dropped.

v2: don't check page_bitmap on NULL

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:48:33 +04:00
Andrey Vagin
52247b12cf restorer: don't need to restore pages content in restorer
All memory content are restored before entering in restorer.c.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:48:31 +04:00
Andrey Vagin
d02844c8fb restore: use a new scheme for restoring of file private mappings
With this patch vma->shmid contains file id before mapping a region,
then it contains of a temporary address.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:48:28 +04:00
Andrey Vagin
71f3f7e67b restorer: remap private vmas to correct places (v3)
All private vmas are placed in a premmapped region and
they are sorted by start addresses, so they should be shifted apart.

Here is one more problem with overlapped temporary and target regions,
mremap could not remap such cases directly, so for such cases a vma is
remapped away and then remapped on a target place.

v2: fix accoding with Pavel's comments
v3: add a huge comment with pictures

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:48:27 +04:00
Andrey Vagin
f3e322a10f restore: don't unmap premmapped private vma-s (v2)
Private vma-s are mapped before forking children, then they are
remapped to corrected places in restorer.c.

In restorer all unneeded vma-s are unmaped. VMA-s from premmapped
regions should not be unmaped.

v2: replace guard pages on arithmetic in restorer

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:48:25 +04:00
Andrey Vagin
f2e4825338 restore: add helper for getting a temporary address of vma
A private vma will be mapped in a temporary place and an address will
be saved in vma->shmid, because nobody was used this field for private
vma-s before. For easy reading vma_premmapped_addr will be used for
getting the temporary address.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:39:12 +04:00
Andrey Vagin
0c77eaba1b mm: add a macros to determing private vma-s (v2)
Now this macros returns true only for anon | priv vmas.
It will be expanded to file | priv in a follow patch.

v2: check flags together.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:39:01 +04:00
Andrey Vagin
5373a22747 bitmap: add a function for finding the next set bit in a memory region
This code is borrowed from the Linux kernel sources.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:39:00 +04:00
Andrey Vagin
187419498f syscall: add sys_mremap
It will be used in restorer.c

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:38:58 +04:00
Pavel Emelyanov
86c848e186 rst: Remove unused extern fns declarations
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-13 20:52:40 +03:00
Pavel Emelyanov
e6617b5e2e parasite: Macro for getting parasite symbols
Same as previous patch -- easier to read and possible
to use tags.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-13 20:51:32 +03:00
Pavel Emelyanov
f86bbe6a9c restore: Introduce a macro to get restorer symbol address
This makes code more readable, saves one ptr on stack and
lets us jump into restorer code using tags.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-13 20:15:13 +03:00
Cyrill Gorcunov
2ee5a42f3e restore: Add restoration of the blocked threads signals from the image
To unify the code for both thread leader and regular threads
we move blocked signals for thread leader into threads argument
area and use restore_thread_common() helper.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:43:01 +04:00
Cyrill Gorcunov
5b7e3b8dae dump: Checkpoint per-thread blocked signals
I've moved dump_thread helper a bit lower in file
since I've to call for find_thread_state helper.
After all this groups all thread related functions
in one slab.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:56 +04:00
Cyrill Gorcunov
f107e8e9e2 dump: Save and remove per-thread argumens in parasite
This patch starts using parasite_init_threads_seized and
parasite_fini_threads_seized helpers to save per-thread
data in parasite and remove it on cure procedure.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:55 +04:00
Cyrill Gorcunov
80928f8c1b parasite: Declare @tid as pid_t in parasite_dump_thread
Just to be consistent with types we're using.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:54 +04:00
Cyrill Gorcunov
c8754da9ae parasite: Rename parasite_dump_tid_info to parasite_dump_thread
We will need to extend the structure to keep not only tid/tid_addr
but blocked signals as well, thus rename it to more generic
parasite_dump_thread.

The command PARASITE_CMD_DUMP_TID_ADDR renamed to
PARASITE_CMD_DUMP_THREAD for the same sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:53 +04:00
Cyrill Gorcunov
9dc332a593 parasite-syscall: Add parasite_[init|fini]_threads_seized helpers
We will use them from crtools code to save and restore blocked
signals mask of threads.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:51 +04:00
Cyrill Gorcunov
e441109efa parasite: Add [init|fini]_thread helpers
These helpers will be needed to save a blocked signals
mask for dumpee threads.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:49 +04:00
Cyrill Gorcunov
616b96421e parasite: Rework init/fini to reserve/free space for per-thread data
The per-thread information requires own space in parasite data.
In particular we will keep the blocked signals bound to thread
pids.

For this sake the caller need to provide the parasite how many
threads will be used to calculate space.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:48 +04:00
Pavel Emelyanov
d4735a22fa packet: Support mmap-ing of packet sockets
Three parts.

Proc: open of map_files' link doesn't work on sockets. We fstatat
it and check that it's a socket (it will be packet), then save
the socket inode on vma_area.

Dump: we resolve socket inode to socket id and save it on vma.
We use id, not inode, since on restore we'll have to mmap some
opened file, not just abstract socket with inode.

Restore: when reading vma-s we just need to find out on what fd
the respective packet socket is opened (i.e. -- no map-and-close
sockets supported by now) and dup() it to let restorer mmap it
back.

All this make it possible to c/r the tcpdump tool!

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-02 16:00:18 +03:00
Andrey Vagin
0fa83b0394 socket: increase socket buffers for restoring queues (v2)
Sizes of send and recv buffers are set to maximum to restore queues,
after that sizes of buffers are restored.

O_NONBLOCK is set to a socket to prevent blocking during restore.

#2411

v2: do the same for unix sockets.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-02 13:40:54 +04:00
Pavel Emelyanov
a6a476ff23 skopts: Prepare for xmalloc-able entries on SkOptsEntry 2012-11-01 17:53:57 +03:00
Pavel Emelyanov
2b9d87fe6b rst: Fix creds vs threads restoration
Writing to last_pid sysctl is CAP_SYS_ADMIN potected. Thus restoring
creds before it won't work in all the cases.

Fix this by making all threads restore creds themselves, and the
thread group leader -- after all of them.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrey Vagin <avagin@parallels.com>
2012-10-30 10:04:37 +03:00
Cyrill Gorcunov
b1f1154c8a auxv: Use real size of the auxv vector
The size of vector depends on the kernel config
so use the real size of a vector dumped. Otherwise
we might fail on restore.

Reported-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 19:54:12 +04:00
Pavel Emelyanov
1bc50df94b rst: Remove unused field from task_restore_args
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 17:01:26 +03:00
Pavel Emelyanov
f8142ba352 rst: Make thread_restore_args be part of task_restore_args
The former is actually the parameters of thread group leader, so
it's natural to have them on-task.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 17:00:18 +03:00
Cyrill Gorcunov
f0606bc8d9 tty: Introduce deferred checking of tty sids
The dumping of tty peers is somewhat tricky. And it became more
complex once we allowed to migrate/inherit sessions.

It's being found (in screen c/r) that we've a problem in looking
up of session leaders while dumping tty.

Let me explain with more details. Here is an example of screen
session

  PID   GID   SID
20567 20567 20567           SCREEN
20568 20568 20568  pts/3     \_ /bin/bash

The screen opens master peer (ptmx) and then provides
bash the slave peer (pts/3) where bash sets up a session
leader on it.

Thus we get interesting scenario -- our pstree construction
is done in lazy fashion, we run parasite code to fetch sid/pgid
of a process tree item only when we're really dumping the task.

Thus when we start dumping ptmx peer (which belongs to SCREEN)
we've not yet constructed the process tree item for children
(ie /bin/bash) and the lookup function in tty code (which walks
over all process items in a tree) simply fails to find sid of
child, because we've not yet dumped it.

Thus, to resolve such situation we verify tty sids at late stage
of dumping.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:37:34 +04:00
Cyrill Gorcunov
73217b7a7d tty: parasite -- Add support for new kernel ioctls to fetch state
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:36:46 +04:00
Cyrill Gorcunov
a343afad34 syscalls: Add sys_madvise
Will need it for VMA restore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-26 00:16:04 +04:00
Cyrill Gorcunov
fc6e73964a types: Add a few MADV_ definition
On my testing machine these defs are not present
so define them where needed.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-26 00:16:02 +04:00
Pavel Emelyanov
93d41b1a83 inet: Disable dumping of shutdown sockets
This requires more work than for unix sockets. For now
report that we cannot do it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-24 18:39:54 +04:00
Pavel Emelyanov
8471081244 unix: Add support for shutdown sockets
Get the info from kernel diag message (it should always be there)
and restore the shutdown at the very end.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-24 18:39:54 +04:00
Pavel Emelyanov
ef3771d566 net: Introduce netdev index to name resolver
It will be required to support socket bound to devices.

When restoring w/o net namespaces -- collect existing devices.
When restoring with them -- collect what is received from image.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-19 17:35:46 +04:00
Cyrill Gorcunov
9ba5c935f1 options: Add "--shell-job" option
This option will tells the tool to procceed dumping
even if a root task is not a session leader.

This implies that this option will allow to "migrate"
one external tty connection. Say a person may dump
"top" application in one bash shell and restore it
in another shell session.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-18 15:51:57 +04:00
Cyrill Gorcunov
9c579cfd02 sfd_type: Add SELF_STDIN_OFF service fd and call helpers where needed
We will need it for slave ttys migration. They serve for one purpose --
to clone self stdio descriptor and use it with tty layer, which will
be addressed in further patches.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-18 15:51:56 +04:00
Andrew Grigorev
51e9cd32b2 types: use siginfo_t from signal.h for rt_signalfn_t declaration
It should fit the sa_sigaction declaration, otherwise compiler
complains about uncasted assignments.

 | restorer.c: In function тАШ__export_restore_taskтАЩ:
 | restorer.c:318:20: error: assignment from incompatible pointer type [-Werror]

So just use siginfo_t here from the system signal.h header.

Signed-off-by: Andrew Grigorev <andrew@ei-grad.ru>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-18 15:02:37 +04:00
Pavel Emelyanov
aa731ee1d7 core: Support task scheduler policies and priorities
No magic here, just fetch info using getpriority and sched_getxxx calls.
Good news is that the mentioned syscalls take pid as argument and do work
with it, i.e. -- no need in parasite help here.

Restore is splitted into prep -- copy sched bits from image on restorer
args -- and the restore itself. It's done to avoid restoring tasks info
with IDLE priority ;) To make restorer not-fail sched bits are validated
for sanity on prep stage.

Minimal sanity test is also there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-17 00:23:25 +04:00