2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-24 02:47:32 +00:00

73 Commits

Author SHA1 Message Date
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
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
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
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
Pavel Emelyanov
0efaf212b2 mount: Clean code a bit
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 17:19:40 +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
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
Pavel Emelyanov
e42a486f39 files: Extend comment about "overlinked" files dump and restore
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-15 00:26:54 +04:00
Andrey Vagin
4850fd94a8 crtools: move cr_options in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 18:17:52 +04:00
Andrey Vagin
1300cf4915 crtools: move all stuff about fdset in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 15:24:48 +04:00
Cyrill Gorcunov
fcfa58026c dump: Don't forget to cleanup link remap if needed
In case if checkpoint is failed or -R option passed
we need to remove link remap files created during
dump procedure.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-01 13:36:07 +04:00
Pavel Emelyanov
b978c6f873 util: Introduce buffer size for carrying /proc/self/fd/N path
There's ... a number of places where we want to do something
with /proc/self/fd/%d path. Each time we guess buffer size
that is enough for this. Make standard constant for this and
save some space on stack and drop args for some functions.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-15 13:59:59 +04:00
Pavel Emelyanov
baa2583a1d files-reg: Sanitize ghost files re-opening for read
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-15 13:51:35 +04:00
Pavel Emelyanov
b8a85cf57d files: Remove FIXME from comment
Linked remap is implemented already.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-29 10:13:55 +04:00
Pavel Emelyanov
84737e2796 build: Generate most of the pb-desc automatically
These contain linkage between number, data type and routines
for pb messages we write/read to/from image files. Most of them
have simple number-type-routines mapping, so introduce a generating
script for that.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-23 21:47:31 +04:00
Pavel Emelyanov
821621cdb7 files: Don't restore pos when file doesn't support one
It's not quite clean, but on dump non-seekable files dump 0xff...ff into
64-bit pos field of the image. Thus on restore we'd face an error in the
do_open_reg. In order not to have separate helper for non-seekable files
just skip the position restore for such.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-23 16:18:18 +04:00
Pavel Emelyanov
60e6d38868 collect: Shorten common images collecting code
Now we have a set of cinfo-s, it's possible to collect all
this stuff in a plan for-loop.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-21 03:52:18 +04:00
Pavel Emelyanov
64e7d2435a collect: Reduce amount of args to collect_image call
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-21 03:27:06 +04:00
Pavel Emelyanov
9917c4fe34 rst: Compact file-descs collects a bit
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-21 01:06:58 +04:00
Pavel Emelyanov
e03ab6b409 rst: Rework remaps collection on generic collect routine
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-21 00:55:26 +04:00
Cyrill Gorcunov
00be48d575 files-reg: Show ghost file name on error
| Can't open ghost file /tmp/file_aio.cRgOVJ.cr.169.ghost: File exists

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-01 16:39:01 +04:00
Pavel Emelyanov
d020ebb36d files: Compact the code by removing per-file dump helpers
Since *all* of them just call do_dump_gen_file with proper ops,
just call one directly. Compacts the code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-06-14 00:11:08 +04:00
Cyrill Gorcunov
8feb155d91 files: ghost -- Make sure we never have ghost bit in id
Just to protect ourself from unpredicted changes.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-06-13 19:40:43 +04:00
Cyrill Gorcunov
4531f0ac7d files: Add ability to use read link in dump_one_reg_file
To be able to dump procfs namespace entries we will need to
analyze the link name first and then figure out if the file
referred indeed a procfs entry or it's plain regular file.

This means we read link early, and to escape double reading
of same link, once we read it we remember it in fd_parms
structure which we pass to dump_one_reg_file.

Still the dump_one_reg_file is not solely used from inside
of dump_one_file, but from a number of other places (fifo,
special files) where fd_parms is filled only partially
and fill_fd_params is not even called. Thus dump_one_reg_file
must be ready for such scenario and read the link name by own
if the caller has not provided one.

To achieve all this we do

 - extend fd_parms structure to have a reference on a new
   fd_link structure, thus if caller already read the link
   name it might assign the reference and call for dump_one_reg_file

 - tune up dump_one_reg_file to fill own copy of fd_link
   structure if the caller has not provied one

  [ xemul: Added const to fill_fdlink arg ]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 03:36:54 +04:00
Cyrill Gorcunov
1d56fe2bf4 files-reg: Use read_fd_link helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-07 22:42:59 +04:00
Cyrill Gorcunov
921dbf23de Don't use \Newline in pr_perror
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-02 22:44:24 +04:00
Pavel Emelyanov
bdf570c9a1 files: Don't dump files whose path doesn't start with /
There are some proc files (ns ones in particular) that are
fake files and on open they screw their path up. Don't dump
them for now.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-30 18:33:46 +04:00
Pavel Emelyanov
5cae819d8c img: Get rid of open_image_ro helper
O_RSTR flag should be used instead for regular open_image

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-09 19:22:21 +04:00
Andrey Vagin
c518d47ad3 files-reg: don't forget to close fd in case of error
CID 996201 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_handle: Handle variable "fd" going out of scope leaks the handle.

CID 996202 (#1 of 1): Resource leak (RESOURCE_LEAK)
6. 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-04-05 08:21:30 +04:00
Cyrill Gorcunov
b6f7d4a605 files-reg: Print file name on error
In case if there some error happened better to
know which exactly file failed on open, for example

 | Error (files-reg.c:535): Can't open file /lib64/libgcc_s-4.4.7-20120601.so.1 on restore: No such file or directory

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 17:41:47 +04:00
Cyrill Gorcunov
6f40cfb506 files-reg: Use pr_err instead of pr_perror if fd not found
Otherwise

 | (00.002843)      1: Error (files-reg.c:522): Can't find regfile for 0
 | : Success

which is inappropriate here.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-18 22:25:32 +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
Andrey Vagin
0fc129a121 files: pass a file descriptor on an fdinfo image instead of cr_fdset
Currently fdinfo dumps for each task, so CR_FD_FDINFO is in cr_fdset.
A few tasks can share one fd table and the set of descriptors will be
dumped once and a image name will contain files_id instead of pid.
In this case CR_FD_FDINFO will go away from cr_fdset.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-11 14:47:09 +04:00
Alexander Kartashov
6f61488f21 x86: moved x86-specific files into the directory arch/x86.
* The following files goes into the directory arch/x86/include/asm unmodified:
  - include/atomic.h,
  - include/linkage.h,
  - include/memcpy_64.h,
  - include/types.h,
  - include/bitops.h,
  - pie/parasite-head-x86-64.S,
  - include/processor-flags.h,
  - include/syscall-x86-64.def.

* Changed include directives in the source files that include the headers
  listed above.

* Modified build scripts to reflect the source moves.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:02:47 +04: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
bae3324447 ghost: Cleanup ghost file dumping
No need in function-wide fd variable for copying file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-05 22:59:35 +03:00
Huang Qiang
223dce83c2 fix many unclosed file opened by open_image_ro
Many image files opened by open_image_ro weren't closed before return, fix
them all in this patch.

Signed-off-by: Huang Qiang <h.huangqiang@huawei.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-24 16:51:50 +04:00
Andrey Vagin
595e2c7694 files-reg: don't forgot about mntns_root in linked-remap
All operations with files should be relative to mntns_root

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-28 19:15:52 +04:00
Pavel Emelyanov
1be08acc7c remap: Add cmdline option to allow linked remap
By default crtools shouldn't modify the environment, except for
killing the dumped tasks. The link remap does so and should sit
under explicit cmdline option.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-26 06:39:23 +04:00
Pavel Emelyanov
563b116096 files: Support opened-and-unlinked files with non zero link count
These are not ghost, as they are still on fs, so we cannot take
them with us in the image. Neither we can easily find the other name
of that file. Sad :(

To make it work we linkat() the new name to that file using the
AT_EMPTY_PATH flag to link directly to the opened fd. If we could
openat() the fd's parent we would better do it, but we can't and
thus have to create the link name by explicit absolute path :(

This modifies the fs we're dumping, so I'll introduce one more cmd
line option for that soon.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-26 06:22:52 +04:00
Pavel Emelyanov
aab7e72ff1 rst file: Introduce the file_remap abstraction
For linked remaps we'll use similar technique as for ghost
files, but lighter. For that sake make reg_file_info remap
to file_remap, not to the whole host_file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-26 06:20:06 +04:00
Pavel Emelyanov
7cdfc8b3c5 ghostf: Move remap_id ghost bit clear to open_remap_ghost
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-26 06:16:51 +04:00
Pavel Emelyanov
246d8336c6 files: Add path len arg to check_path_remap
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-26 06:15:43 +04:00
Cyrill Gorcunov
a3c6869ca1 reg-files: No need for atomic @users
We're under lock anyway.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:13:20 +04:00
Cyrill Gorcunov
997b295d67 files-reg: Use global mutex to serialize ghost file creation
Otherwise there is a race between files with same names:

link(name -> ghost)                link(name->ghost)
open(name)
unlink(name)
                                   open(name) -> ENOENT

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:12:58 +04:00
Andrey Vagin
b11eeea381 restore: auto-unlink for ghost files (v2)
A ghost file is used for restoring descriptors of an unlinked file.
It is created, opened and deleted.

Currently ghost files are collected in root task and then removed
by crtools when everybody is restored. This scheme doesn't work,
ghost_file_list is not shared, plus tasks may live in different mount
namespace.

It was broken by the following commit:
bd4e5d2f restore: prepare shared objects after initializing namespaces

We can't just move clear_ghost_files(), because we need to wait, until
all processes have not opened a ghost file.
We can add one more global barrier or move clear_ghost_files() in
a restore code bellow an existent barrier.

Here is a better sollution, a gost file is deleted by the last user.

v2: Use the type atomic_t and fix a commit message.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 17:59:59 +04:00
Pavel Emelyanov
51133437c9 fd: Remove per-filetype make_gen_id abstraction
It doesn't makemuch sense in pulling this further. The generic genid generation seems to
be enough for eny file type.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-11 22:41:29 +04:00
Pavel Emelyanov
b91445701b img: Introduce generic routine for collecting image entries
On restore we typically read an image and put the entries into
some hash/list/whatever to work on them later. It's handy to have
a generic routine for doing so.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-09 13:16:46 +04:00