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

3672 Commits

Author SHA1 Message Date
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
Ruslan Kuprieiev
07e153fc4c service: set success to true before exit
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-05 12:05:46 +04:00
Pavel Emelyanov
3708ecb499 mount: Introduce generic FSs parsing callback
And make use of it in for btrfs.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
2013-12-04 20:03:17 +04:00
Pavel Emelyanov
b6e2dfd2de mount: Prepare fstypes to contain more unsupported FSs
We will need to parse btrfs stuff, but this one is not
in the supported list yet (as it's bound to hardware).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
2013-12-04 20:03:15 +04:00
Cyrill Gorcunov
a5785c94bc files-reg: Don't fail matching if ghost file is on BTRFS subvolume
In case if ghost file is on BTRFS subvolume we should not fail
but test if there is a match.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-04 19:23:34 +04:00
Cyrill Gorcunov
9e6bd8c512 sk-unix: Don't fail if socket path lays on btrfs volume
Because socket migh lay on btrfs volume (thus the device
number reported by diag module won't be the same as obtained
from stat(2)) we need to do an additional test and try
to resolve device number with help of btrfs engine.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-04 19:23:33 +04:00
Cyrill Gorcunov
e54ad19a06 mount: Add phys_stat_dev_match helper
This helper serves to hide fs specifics (in particular
btrfs) thus the caller won't need the details.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-04 19:23:32 +04:00
Cyrill Gorcunov
c9069ba09f proc_parse: Call for btrfs_parse_mountinfo on every mount
This helper will cause BTRFS engine to collect all subvolumes.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-04 19:23:31 +04:00
Cyrill Gorcunov
d4eaf8d612 btrfs: Introduce BTRFS engine
It is been found that BTRFS uses per subvolume device
numbering scheme  which causes some of our tests to fail
if they are laying on this filesystem.

Here we introduce minimal engine which parses subvolumes
present on mount point.

The interface is two functions

 - btrfs_parse_mountinfo: this one parses subvolume and caches the results
 - is_btrfs_subvol: test if device id is laying on subvolume

In the code we assume that cpu we're running on
is little endian, thus if one day we run on big
ending machine the code must be updated accordingly.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-04 19:23:28 +04:00
Cyrill Gorcunov
232e3a28a7 proc_parse: Introduce @private member into mount_info structure
It will hold auxiliary data associated with mount point. We
will use it for btrfs handling but in future it can be extended.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-04 18:18:22 +04:00
Cyrill Gorcunov
eeb21b8a34 proc_parse: Remember a type of FS provided by a kernel
We will need it for btrfs handling. Also print out the
FS type for easier debug

 | (00.003545)     type unsupported (cgroup) source cgroup 1c / @ /sys/fs/cgroup/blkio flags 30000e options blkio,
 | (00.003558)     type unsupported (cgroup) source cgroup 1d / @ /sys/fs/cgroup/perf_event flags 30000e options perf_event,
 | (00.003571)     type unsupported (cgroup) source cgroup 1e / @ /sys/fs/cgroup/hugetlb flags 30000e options hugetlb,
 | (00.003584)     type unsupported (ext4) source /dev/sda2 800002 / @ / flags 300000 options data=ordered,
 | (00.003670)     type tmpfs (tmpfs) source tmpfs 20 / @ /tmp flags 100000 options
 | (00.003696)     type unsupported (mqueue) source mqueue d / @ /dev/mqueue flags 300000 options

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-04 18:18:21 +04:00
Cyrill Gorcunov
56f4679dfc fsnotify: Fix typo in get_mark_path debug output
@path is always nil here, we actually need @remap->path

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-04 17:36:04 +04:00
Cyrill Gorcunov
a1fd4119bc mount: Print device obtained from stat() call
For debug purpose.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-03 22:50:40 +04:00
Cyrill Gorcunov
58c4631ae7 mount: Drop useless NULL assignment
We allocate mount_info with xzalloc, no need for
additional NULL assignment.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-03 22:50:00 +04:00
Cyrill Gorcunov
38c34aae5e proc_parse: Don't setup ret = 0 early
If we fail in xmalloc the function occasionally return
0 meaning that everything is fine. Don't do that, wait
until routine complete.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-03 22:49:30 +04:00
Pavel Emelyanov
20e8d193e5 tty: Print very descriptive message about shell job dump
First thing people typically do with criu is run something
in shell and try to dump it. This is typicall pitfall, as
in that case we face external sid and tty problem. Print a
message on stdout about this and advice wiki page to read.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-03 09:59:17 +04:00
Ruslan Kuprieiev
2e8ff1a22a v2 service: don't send dump response in case of self-dump without leave_running
Currently we have a bug: if no leave_running is set in request, service won't send dump response. We must not send response only if it was a self-dump request and no leave_running option was set.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-02 19:50:44 +04:00
Tikhomirov Pavel
7be5a1b95d v2 page-read: Check parent pagemap read return value
Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-02 15:28:59 +04:00
Cyrill Gorcunov
654131626e proc_parse: Delay freeing of kernel fs type
We will need it for additional handling once parsing
of mount entry is complete (in particular btrfs requires
additional processing to figure out subvolumes names).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-29 15:36:12 +04:00
Cyrill Gorcunov
b4266c7e67 string: Add strlcat helper
We will need it for btrfs subvolumes handling.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-29 15:36:07 +04:00
Cyrill Gorcunov
f4e40ef7e2 mount: Use is_root_mount helper instead of strcmp
It's designed specificly for that.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-28 15:46:00 +04:00
Cyrill Gorcunov
d7141750d2 sk-unix: Use pr_warn instead of pr_perror if socket path can't be stat'ed
The error message is rather confusing people. In worst case (if
it happened that we need this uncollected socket), criu will
print out real error message later.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-28 15:38:52 +04:00
Cyrill Gorcunov
75ebb6d02c sk-unix: Print the name of sockets being dropped
Useful for bug hunting.

 | (00.005209) unix: Dropping path /mnt/disk1/new_subvol/criu/test/zdtm/live/static/sockets00.test
 | for unlinked bound sk 0x26.0x1d4e real 0x23.0x1d4e

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-28 15:36:33 +04:00
Pavel Emelyanov
f2bb77c017 criu: Version 1.0 release
The next version is ready. It looks like it's time to make it
be the first major release, so here it is -- the v1.0. It's as
functional as v0.8 but with a lot of bug fixes and improvements.
And it's still :) compatible wrt images and cli options with
older criu-s.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
v1.0
2013-11-25 20:05:10 +04:00
Andrey Vagin
57d25e7cea mm: fix expression to determine which vma-s can be shared
Currently only addresses are compared. It's obviously not enough.

* First of all the parent vma must be private.
* Both vma-s must have the identical set of MAP_GROWSDOWN and MAP_FILES
  flags.
* Both vma-s must be linked to the same file.

https://bugzilla.openvz.org/show_bug.cgi?id=2824
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-22 18:19:23 +04:00
Andrey Vagin
7659c995f5 vm: don't overwrite vma->shmid for private mappings
shmid contains a file id for file mappings. It's required to determine,
which VMA-s are cowed. The parent maps a VMA and saves premmaped
address. Then  child trys to determing, which VMA-s must be inhereted
from parent, for that it compares addresses, flags and file id.

We don't want to transfer vma_area-s in restorer, so when a VMA entry is
copied in restorer memory, the premmaped address is save in shmid.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-22 18:19:08 +04:00
Ruslan Kuprieiev
b49d096016 service: set CHECK type on check response
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-22 09:29:12 +04:00
Pavel Emelyanov
42bd5163df files: Print more info about unsupported fd to dump
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-21 15:28:37 +04:00
Pavel Emelyanov
2677006cf5 restorer: Check error from exe link restore
Kenrel API is stable enough not to ignore it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-21 15:28:14 +04:00
Kir Kolyshkin
e49faff1ff fopen_proc(), opendir_proc(): don't print two errors
Both fopen_proc() and opendir_proc() are calling open_proc().
If open_proc() fails, it prints an error message. Before this
patch, a second error message was printed due to missing brackets.
This second message is a bit more specific (it tells the exact
file/dir we failed to open) but it is redundant, because more
generic error was already printed by open_proc(). It is also
can be misleading because for the second message we reuse
the same errno while we should not.

So, let's remove this second error message print by using brackets.

Alternatively, we could leave this as is (just fixing indentation)
and let two errors be printed -- there is nothing wrong with that,
but I think in this case less messages is better.

This is a fix to commit 5661d80.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-21 13:40:35 +04:00
Pavel Emelyanov
2ba384e852 rst: Add comment about old memory unmap
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-20 14:41:34 +04:00
Pavel Emelyanov
c3b9448cf7 pidfile: Don't push opts.pidfile as write_pidfile arg
opts are criu-wide available.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-20 14:26:41 +04:00