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

3753 Commits

Author SHA1 Message Date
Pavel Emelyanov
db33a144d2 mount: Fix the mi we print info about
The t and m match there, but strictly speaking we're working on the m.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-26 11:07:38 +04:00
Pavel Emelyanov
dcd680726c mount: Read mount images eary
We'll have to pre-mount some, so move the read_mnt_ns_img
before pivot_root call.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-26 11:07:37 +04:00
Pavel Emelyanov
70eb3cc4f3 mount: Make images reader return the list of mounts
To carry them with us in a local variable (next patches), not
the global mntinfo one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-26 11:07:35 +04:00
Pavel Emelyanov
cb4e125bd0 mount: Split reading images and populating the ns
We will need images at hands while we do pivot_root (see further patches),
so prepare the images reading routine.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-26 11:07:34 +04:00
Andrey Vagin
f0e0ee7a5c unix: fix calculation of pointers
CID 1141016 (#1 of 1): Extra sizeof expression (SIZEOF_MISMATCH)
suspicious_pointer_arithmetic: Adding "40UL /* sizeof (FilePermsEntry)
*/" to pointer "(FownEntry *)perms" of type "FownEntry *" is suspicious
because adding an integral value to this pointer automatically scales
that value by the size, 48 bytes, of the pointed-to type, "FownEntry".
Most likely, "sizeof (FilePermsEntry)" is extraneous and should be
replaced with 1.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-23 13:59:59 +04:00
Andrey Vagin
a5bb33417b service: don't leak a zero file descriptor
CID 1141017 (#1-2 of 2): Resource leak (RESOURCE_LEAK)
14. leaked_handle: Handle variable fd going out of scope leaks the handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-23 13:59:41 +04:00
Andrey Vagin
99bb419df1 image: don't leak a file descriptor
CID 1141015 (#1 of 1): Resource leak (RESOURCE_LEAK)
8. leaked_handle: Handle variable fd going out of scope leaks the handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-23 13:59:34 +04:00
Andrey Vagin
07d9e11374 unix: fix double free on error paths
CID 1141011 (#1 of 1): Double free (USE_AFTER_FREE)
24. double_free: Calling "free(void *)" frees pointer "ue" which has
already been freed.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-23 13:59:23 +04:00
Andrey Vagin
4202acbc8f zdtm: increase the amount of allowable inaccuracy
The timeout can be exceeded during dumping and restoring.
When we are testing snapshots, the test is dumped three times.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-23 13:55:19 +04:00
Andrew Vagin
c8e9701f21 ptrace: check, that PTRACE_LISTEN isn't defined yet
In file included from arch/x86/crtools.c:11:0:
include/ptrace.h:16:0: error: "PTRACE_LISTEN" redefined [-Werror]
 #define PTRACE_LISTEN  0x4208
 ^
In file included from include/ptrace.h:5:0,
                 from arch/x86/crtools.c:11:
/usr/include/sys/ptrace.h:150:0: note: this is the location of the previous definition
 #define PTRACE_LISTEN PTRACE_LISTEN
 ^
cc1: all warnings being treated as errors
make[1]: *** [arch/x86/crtools.o] Error 1

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-23 13:54:19 +04:00
Andrey Vagin
ad0249f649 lib: don't copy more than the buffer size
CID 1141012 (#1 of 1): Copy into fixed size buffer (STRING_OVERFLOW)
2. fixed_size_dest: You might overrun the 108 byte fixed-size string
"addr.sun_path" by copying "service_address" without checking the
length.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-23 13:53:53 +04:00
Pavel Emelyanov
d4df900236 unseize: Don't print error when unseizing stopped task into stopped state
Just a small mistake in prev patch.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 23:22:04 +04:00
Andrew Vagin
a2eaa5cf44 ptrace: the task state is restored automatically
It's a feature of PTRACE_SEIZE.  So we need to do something, only
if we want to change the state.

[xemul: If task _was_ in stopped state before dump and we want them
 to stay alive after dump, the existing code queues one more STOP
 to it. This affects subsequent dump, as we seize a stopped task
 with STOP in queue.

 One more item in TODO list -- support stopped tasks with STOP in
 queue :)
]

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 20:36:12 +04:00
Pavel Emelyanov
805e25effe ptrace: Add comment about early interrupt
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 16:42:24 +04:00
Andrey Vagin
800c4d09bb seize: add more detailed comment
Why we do several attempts to freeze tasks.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 16:41:14 +04:00
Kir Kolyshkin
fc9fea2fdc criu-log.h: fit macros in 80 columns
Before this patch, backslash was at 81th column which makes the text
twice longer on a standard 80 col terminal, which is quite annoying.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 16:09:13 +04:00
Kir Kolyshkin
8692291d42 tab-at-eol cleanup
Remove whitespace at EOL (found by git grep '	$')
(the character before $ is real tab, typed in shell using Ctrl+V Tab)

To people using vim, I'd suggest adding the following code to ~/.vimrc:

let c_space_errors = 1
highlight FormatError ctermbg=darkred guibg=darkred
match FormatError /\s\+$\|\ \+\t\|\%80v.\|\ \{8\}/

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 16:09:08 +04:00
Kir Kolyshkin
94b09be23a cr_service(): don't use pr_perror()
Since sd_listen_fds() doesn't set errno when returning a value > 1,
it doesn't make sense to use pr_perror(). Use pr_err() instead.

While at it, remove the period from the log message.

[v2: fix function names]

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 16:08:21 +04:00
Andrey Vagin
0dfb077621 zdtm: test dumping character devices with help of custom callbacks
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 16:07:39 +04:00
Andrey Vagin
6bbdec26f3 files: add ability to set callbacks for files (v7)
Here is nothing interecting. If a file can't be dumped by criu,
plugins are called. If one of plugins knows how to dump the file,
the file entry is marked as need_callback. On restore if we see
this mark, we execute plugins for restoring the file.

v2: Callbacks are called for all files, which are not supported by CRIU.
v3: Call plugins for a file instead of file descriptor. A few file
descriptors can be associated with one file.
v4: A file descriptor is opened in a callback. It's required for
    restoring anon vmas.
v5: Add a separate type for unsupported files
v6: define FD_TYPES__UNSUPP
v7: s/unsupp/ext (external)

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 16:07:38 +04:00
Andrey Vagin
1e4b8c8c23 tests: check callback-s for dumping and restoring sockets (v2)
Here are client, server programs and two libraries for dumping client
sockets and syslog socket.

The client can ask server to save a value and then request it later.
We suppose that after dumping and restoring the client will get
the same value.

So the dump callback requests the value and save it in a file.
The restore callback creates a new socket and ask server to save the
value from the file.

v2: open a syslog socket

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:28:53 +04:00
Andrey Vagin
9e3f4451e1 unix: add ability to set callbacks for external sockets (v5)
We don't know a state behind an external socket. It depends on logic
of the program, which handles this socket.

This patch adds ability to load a library with callbacks for dumping
and restoring external sockets.

This patch introduces two callbacks cr_plugin_dump_unix_sk and
cr_plugin_restore_unix_sk. If a callback can not handle a socket, it
must return -ENOTSUP.

The main questions, what kind of information should be tranfered in
these callbacks. Pls, think a few minutes about that and send me
your opinion.

v2: Use uflags instread of adding a new field
v3: clean up
v4: Unsuitable callbacks return -ENOTSUP.
v5: set USK_CALLBACK, if a socket was dumped by callback.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:28:41 +04:00
Andrey Vagin
afc61ba562 unux: postpone dumping sockets v2
Unix sockets are dumped, when a peer socket is found.
We are going to dump external sockets with help plugins. For the we need
to set the USK_CALLBACK flags in unix entry. Currently a socket is
dumped immediately when it's transfered, but we can be sure that a
socket is not external, only when we have its peer.

v2: add comments in code
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:27:36 +04:00
Andrey Vagin
59162cccf7 sk-unix/dump: allocate UnixSkEntry dynamically
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:27:35 +04:00
Andrey Vagin
8f66bf9794 unix: link a socket to its peer
We are going to add callback-s for dumping external sockets.
All external sockets are added into unix_list, but for dumping we need
to know all peers.

And one more thing is that a socket is not closed before its peer is
not be dumped. We are going to transfer the socket decriptor in the
callback.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:27:34 +04:00
Andrey Vagin
dc914912ec dump: try to stop a task as soon as possible
We read /proc/pid/status to determine a task state, but if a task is
running in this moment, its state may be changed.

This patch stops tasks before reading their /proc/pid/status

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:16:12 +04:00
Andrey Vagin
bf67879062 crtools: rework freeze of processes (v2)
Before this patch crtools freezes processes and if something is changed,
it unfreezes all processes and starts again from the beginning.

If if are going to dump fork-bomb, this method doesn't work. Because a
big tree is always changed.

We don't need unfreeze processes, which have been frozen and this patch
does that.

This patch uses depth-first search (DFS) for traversing a process tree.

A root task is frozen at first turn, than a child is frozen, than a
child of child and so on.

When all children of one process are frozen, criu reads the list of
children again and check that nothing changed. This processes continues
until all of them will not be frozen. Afte that a new child can not be
appeared, because all children for children are frozen too.

v2: add comments in code
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:16:11 +04:00
Andrey Vagin
978badc196 dump: rework freeze of threads
When we try to freeze threads, some of them can exit
and a few new ones can be born. Currently we unfreeze process free
int this case, so we have the same chance to failed in the next case.

I suggest to not unfreeze frozen threads, just try to update thread list
and freeze unfrozen threads.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:16:10 +04:00
Kir Kolyshkin
e2a0be63d4 mnt_tree_for_each_reverse(): init a variable
A warning catched by clang:

> > mount.c:869:71: error: variable 'progress' is uninitialized when used here
> >       [-Werror,-Wuninitialized]
> >   ...prev, MNT_WALK_NONE, fn, (struct list_head *) NULL, progress);
> >                                                          ^~~~~~~~
> > mount.c:802:4: note: expanded from macro 'MNT_TREE_WALK'
> >                         _prgs++;
> > \
> >                         ^
> > mount.c:867:14: note: initialize the variable 'progress' to silence this
> > warning
> >         int progress;
> >                     ^
> >                      = 0
> > 1 error generated.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 11:26:12 +04:00
Andrey Vagin
ca44f6f071 zdtm: add a new test, which creates and destroys threads
A thread can create another threads, if the number of threads is less
than the limit.

This test case is very useful to check criu freezer.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-19 22:53:42 +04:00
Pavel Emelyanov
a37cf7a407 seize: Add some comments about unseizing task
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-19 22:48:55 +04:00
Andrey Vagin
9cec289f74 dump: restore state correctly
Currently all task are restored as alive, but stopped tasks
must be restored as stopped.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-19 22:47:45 +04:00
Andrey Vagin
625ad48dfd dump: don't restore a state of threads
It is not needed, because stat is a property of task,
so we can restore a state of task and it should be enough.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-19 22:47:43 +04:00
Andrey Vagin
e027f116e4 plugin: add a function to get a descriptor to the image dir
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-19 21:49:39 +04:00
Andrey Vagin
d7cf271ed4 crtools: preload libraries (v2)
Libraries (plugins) is going to be used for dumping and restoring
external dependencies (e.g. dbus, systemd journal sockets, charecter
devices, etc)

A plugin can have the cr_plugin_init() and cr_plugin_fini functions for
initialization and deinialization.

criu-plugin.h contains all things, which can be used in plugins.

v2: rename lib to plugin
v3: add a default value for a plugin path.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-19 21:48:33 +04:00
Andrey Vagin
b90373b48c files: transfer file descriptor in dump_unsupp_fd
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 21:54:11 +04:00
Andrey Vagin
2add5b87fa plugin: allow to use logging function in plugins
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 21:52:12 +04:00
Pavel Emelyanov
c79751171f service: Add coment about cr_dump_task() scripts code propagation
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 21:24:52 +04:00
Ruslan Kuprieiev
fba791a607 service: fix bug, when root_item isn't initialized
If restore fails on early stage(like no images in directory), then root_item
might be uninitialized, so when we are trying to send response with root_item->pid
criu crashes.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 21:18:00 +04:00
Ruslan Kuprieiev
003cfcae19 service: fix bug, when criu reports success on dump fail
cr_dump_tasks() may return not only -1 on fail.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 21:17:53 +04:00
Ruslan Kuprieiev
f4f806186c test: libcriu -- check for -EBADE instead of -1
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 21:09:03 +04:00
Ruslan Kuprieiev
e80ee17368 lib: return -EBADE instead of -1
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 21:08:58 +04:00
Pavel Emelyanov
e4c366806f dedup: Mark dedup_one_pagemap static
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:57:17 +04:00
Pavel Emelyanov
ba96e646a4 page-read: Fix naming
The open_page_at one is quite obfuscating.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:55:22 +04:00
Pavel Emelyanov
55b96d0113 page-read: Fix compilation on older distros
SEEK_DATA appeared quite recently, define it if not present
in system headers.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:53:30 +04:00
Tikhomirov Pavel
de5fc0d1e9 v3 test/dedup: auto-dedup test
add auto-dedup when dumping the last time, and check if size become smaller

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:52:05 +04:00
Tikhomirov Pavel
41433f4043 v3 deduplication: add auto-dedup local
Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:52:04 +04:00
Tikhomirov Pavel
4904878258 v3 deduplication: add auto-dedup option
Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:51:47 +04:00
Tikhomirov Pavel
96b26f6392 v3 test/dedup: dedup on "parent" before restoring
if size become smaller and restored ok, then test passed
use mem-snap.sh

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:51:45 +04:00
Tikhomirov Pavel
00e4f24b3f v3 deduplication: add punching holes in "parent"
punch where coresponding data was updated in curent snapshot

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:51:44 +04:00