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
Tikhomirov Pavel
d866bd196b v3 deduplication: look up for old pages in previous snapshot
old snapshot from "parent" symlink, and pids from pagemap-PID.img files

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:51:42 +04:00
Tikhomirov Pavel
ea403c7a08 v3 deduplication: add dedup comand to criu
Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:51:22 +04:00
Tikhomirov Pavel
5db1adc567 v3 page-read: add open_page_rw to open pages in O_RDWR mode
Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:51:20 +04:00
Tikhomirov Pavel
6336d537ac v3 page-read: make function seek_pagemap_page can be used in dedup
Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:51:09 +04:00
Tikhomirov Pavel
0f90727ddb v3 page-read: add reuse posibility of pagemap2iovec
Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:50:49 +04:00
Tikhomirov Pavel
530b6d11fd v3 page-read: replace read_pagemap_page_from_parent with seek_pagemap_page
Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:50:48 +04:00
Tikhomirov Pavel
632798b789 v3 Fix for open_pages_image_at to read if opened with O_RDWR
Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:50:47 +04:00
Tikhomirov Pavel
c49219bf6a v3 page-read: add print error in case of bad or corrupted image
1. add it instead of BUG_ON
we should print error if warn is assigned to true
2. correct use of read_pagemap_page_from_parent, provide warn = true

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:50:45 +04:00
Tikhomirov Pavel
164bc4bdf1 v3 page-read: check that don't read page from hole
Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:50:44 +04:00
Ruslan Kuprieiev
ca1f60d267 test: libcriu
This test is similiar to test/rpc, and can also be used as an
example of using libcriu.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:26:12 +04:00
Ruslan Kuprieiev
906a75ca03 lib: add check/dump/restore
These functions are to be used to check criu, dump process and restore process.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:26:11 +04:00
Ruslan Kuprieiev
a1e7407397 service: move constants to cr-service-const.h
Such constants as CR_MAX_MSG_SIZE and CR_DEFAULT_SERVICE_ADDRESS are need to be used in both service and lib.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:26:10 +04:00
Ruslan Kuprieiev
ba18a5e16c make: lib -- use ldflags-so and obj-ext-src-y
We need ldflags-so to link libcriu with -lprotobuf-c
and rpc.pb-c.o to use RPC.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:26:08 +04:00
Ruslan Kuprieiev
33993eaf5b make: add ldflags-so variable to make engine
We need it to use other dynamic libraries in libcriu.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-18 14:26:07 +04:00
Tikhomirov Pavel
5ec15bf25c page-read: add proper processing of return value
when get an error reading image file need stop restore

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-17 19:45:22 +04:00
Cyrill Gorcunov
b7529fe814 make: Makefile.build -- Improve autocleanup target
Currently we clean up with wildchar mask. This actually
not that correct. Lets remove only the files were generated
by our make engine.

This as well allows to clean up objects generated as $obj-e
target even if the directory $obj-e is laying in doesn't have
own Makefile.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 15:58:33 +04:00
Cyrill Gorcunov
0ce8c366dc make: protobuf -- Explicitly clean generated files
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 15:58:32 +04:00
Cyrill Gorcunov
02feb3a8eb make: pie -- Explicitly cleanup specific targets
make engine will be reworked to clean up only those
files which were generated with implicit rules. Thus
anything generated in specific way must be cleaned
up explicitly.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 15:58:31 +04:00
Pavel Emelyanov
5535e44dac crtools: Keep cr_dump_task's post-dump ret code
Broken by 09b7b57c.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 14:32:18 +04:00
Kir Kolyshkin
b11f24fd5d criu check: don't run as non-root
In case criu check is run as non-root, a lot of information is printed
to a user, with the only missing bit is it should run it as root.

Fix it.

I still don't like the fact that some other stuff is printed here,
like the timestamp and the __FILE__:__LINE__, but this should be
fixed separately.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:58:45 +04:00
Kir Kolyshkin
abd061481b pr_perror(): don't end message with a period
When pr_perror is used, an error message is appended with a comma
and an strerror(errno), so we should not put a period at the end,
otherwise we'll end up with something like this:

	Error: Can't bind.: Permission denied

Found by git grep -w pr_perror | grep '\."'

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:58:05 +04:00
Kir Kolyshkin
078465859b criu --help: improve --work-dir description
There should either be a comma before the second line, or it should be
in parenthesis. I chose latter.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:37:42 +04:00
Kir Kolyshkin
37e1ed1345 criu --help: add missing colon
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:37:34 +04:00
Kir Kolyshkin
195d8f81d0 criu --help: rephrase --pidfile description
... to fit in a single line.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:37:29 +04:00
Kir Kolyshkin
f2ec7be125 criu --help: limit output to 80 columns
...by rephrasing the --work-dir option description.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:37:20 +04:00
Kir Kolyshkin
09b7b57c83 criu: don't return negative values from main() 2/2
We should return 1 not -1, because -1 becomes 255.

This is second part, patching return from functions.
Using 'ret != 0' condition seems like the best and easiest
thing to do, so we expect a function to return 0 in normal
case and any non-zero value in case of error.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:36:33 +04:00
Kir Kolyshkin
f59326aba6 criu: don't return negative values from main() 1/2
We should return 1 not -1, because -1 becomes 255.

>From man bash: "the shell may use values above
125 specially". Don't be a black sheep and return 1.

This is first part, patching obvious direct return statements.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:36:27 +04:00
Kir Kolyshkin
bf5a8e13e1 cr_service(): don't exit(-1)
We should exit(1) on error, exit(0) on success.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:36:21 +04:00
Kir Kolyshkin
b744883e42 cr_service(): close fd on error
... and don't return -1.

This is a missing part from commit 3477223.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:36:14 +04:00
Pavel Emelyanov
6bfc566d0d files: Don't lose anon-file type name
The symlink reader reports the amount of bytes read
in case of success.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:09:50 +04:00
Pavel Emelyanov
87317c26fa zdtm: Allow to specify more than one exclude pattern
We sometimes want to exclude several tests from run. Writing
expression with \-s is annoying. Let's make it possible to
do several -x's instead.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 16:40:49 +04:00
Pavel Emelyanov
ae98ef6ae0 mount: Factor out mount tree build for NEWNS and non-NS cases
We anyway build the tree, in the NS case -- few calls later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 16:19:48 +04:00
Pavel Emelyanov
bd69c6173d mount: Free old mounts for pivot-root case
If we specify a new root for restore old mounts get destroyed
with pivot_root + umount calls, tree umount is omitted. In this
case mi-s are leaked.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 16:13:31 +04:00
Pavel Emelyanov
f35d7cd7fe mount: Don't validate mounts read from proc on restore
Validation means -- check chat we can _restore_ this tree.
Those read from proc can be in any state -- we're going to
umount them (can do anything) and do path resolution (work
for any knots as well).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 16:01:14 +04:00
Cyrill Gorcunov
e9f9fdb9b3 headers: Drop uintX_t usage
We have a mess of uintX_t and uX usage. Drop off uintX_t ones.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 10:03:07 +04:00
Kir Kolyshkin
26fda7a319 space-before-tab whitespace cleanup
Remove space before tab characters.

Found by git grep ' 	' (Space, Ctrl-V, Tab in shell).

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 10:00:53 +04:00
Kir Kolyshkin
d64d68d66c whitespace-at-eol cleanup
Remove whitespace at EOL (found by git grep ' $')

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-12 10:00:45 +04:00
Shawn Landden
2e15e4da92 systemd socket activation support
Makes the criu RPC socket socket-activated with
systemd [1], meaning that systemd will create and listen to
the UNIX socket /var/run/criu-srvice.socket
on behalf of criu until a connection comes in, when it will
then pass control of the socket, along with the first connection
over to a newly spawned criu daemon.

This is similar to inetd, but criu stays around after getting
started, listening itsself on the socket.

[1] http://0pointer.de/blog/projects/socket-activation.html

v2: stripped down sd-daemon.[ch]
    moved units to scripts/sd

v3: stripped down further by removing unneeded includes

Signed-off-by: Shawn Landden <shawn@churchofgit.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 09:58:50 +04:00
Pavel Emelyanov
873d1dac9d unix: Move odev to kdev conversion into phys_stat_dev_match
This is more correct, as if st_dev == phys_dev check fails
we have to treat phys_dev as kdev for path resolve device
comparison.

Howver, this is not the case for non-btrfs FSs, and for the
latter one doesn't change anything as it uses anon devices
which are equal for kdev and odev cases.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 08:44:15 +04:00
Pavel Emelyanov
0d8f688e5c mount: Fixup phys/virt devices dumping for ghost files
When dumping a ghost file we put real device in its header,
not the (btrfs) virtual one. This is done since we put real
devices into fsnotify images (we get them from proc). That
said on fsnotify ghost restore we don't need to do path
resolution, just devices compare.

And one more thing. When dumping device for ghost file for
_non_ btrfs case we have to convert stat dev_t into kernel
dev_t as all the other places in criu manipulate the latter
ones.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 08:18:21 +04:00
Andrew Vagin
fe764c2c14 mount: add btrfs into fstypes
It's used by phys_stat_resolve_dev (broken by c5d2386a)

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 01:07:12 +04:00
Pavel Emelyanov
976265a078 mount: Add comments about mount list and tree
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 17:34:41 +04:00
Pavel Emelyanov
0efaf212b2 mount: Clean code a bit
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 17:19:40 +04:00
Pavel Emelyanov
c5d2386a2f btrfs: Remove volume parsing code
Now we have more robust and fs agnostic path-resolution
engine for resolving dev conflicts.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 17:18:59 +04:00
Cyrill Gorcunov
1ba08ca664 mount: Extend phys_stat_dev_match to use path resolving instead of btrfs engine
Instead of scanning btrfs subvolumes (which can be even unaccessbile
if mount point lays on directory instead of subvolume itself) we use
path resolving feature here -- once we need to figure out if some
device number need to be altered up to mount point (as we know stat()
called on subvolume returns st_dev for subvolume itself, but not
one that associated with a superblock and shown in /proc/self/mountinfo
output).

This as well implies that we need to check if device number for ghost
files are to be updated to match mountinfo, thus we use phys_stat_resolve_dev
helper here.

After this patch the previously merged btrfs engine is no longer needed
(at least it seems so) and can be dropped.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 16:05:22 +04:00
Cyrill Gorcunov
5372e3910c mount: btrfs -- Introduce phys_stat_resolve_dev helper (v2)
This routine is aimed to find a mount point on which
the path passed as argument is laying on. We walk over
all mount points and see which one is matching.

Once found (in worst case it will be a root mount point
so function is never failing) we're checking if this is
btrfs and then return subvolume0 device id.

See commit 921cf873f30ad35df2b65602ed402f94695a6eb3
for details what the hell we're doing here.

v2: rewrite mount_resolve_path w/o recursion

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 16:05:21 +04:00
Cyrill Gorcunov
cf1ce5f817 mount: Build mount tree on dump restore early, if needed
For paths resolution we will need mount tree to be parsed
and built, but it's not that simple -- the current code
implies that once parsed the tree must not be re-parsed
again, so we pass @parse argument from a caller: if a task
we're restoring do not use mount namespace, we should parse
mount tree early, otherwise defer this action until mount
tree is read from the image.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 16:05:19 +04:00
Cyrill Gorcunov
8e0c1037f3 mount: Introduce @mntinfo_root variable
This variable should be carrying root of a parsed
mount tree pointed by @mntinfo. Thus if @mntinfo
get destroyed the @mntinfo_root should be set to NULL.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 16:05:18 +04:00
Cyrill Gorcunov
921cf873f3 btrfs: Don't fail if we meet non-subvolume mountpoint
If mount point is not a subvolume we need more complex logic
to figure out which subvolumes it might have. It'll be addressed
later, at moment simply don't fail in such case: for worst
scenarion we will fail later in CRIU code when devs are not
matching, in best case if application is not using notify,
sockets or deleted files -- we should continue without errors.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-05 15:56:03 +04:00
Cyrill Gorcunov
fe5f60b9d4 btrfs: Don't miss subvol0 on matching
Subvolume 0 has own device number as well, don't miss it
when looking up for match.

Reported-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Tested-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-05 12:45:47 +04:00