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

37 Commits

Author SHA1 Message Date
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
Andrey Vagin
ba0d5fb226 dump: handle overmounted devices (v2)
"init" in LXC opens /dev/null and then mounts devtmpfs in /dev,
so crtools can not resolve the path to the origin /dev/null.

crtools with the option --evasive-devices will check the origin
device and a new device are the same and if it's true, crtools will
dump a new path.

v2: add a description for the option

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-07 19:33:49 +04:00
Pavel Emelyanov
b1b0a39a58 pb: Rewrite object reading to use pb-descs
The pb_read thing is no longer a macros. This will allow to
factor out objects collecting on restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-07 19:22:00 +04:00
Pavel Emelyanov
2398c55e41 pb: Rewrite object writing to use pb-descs
The pb_write thing is no longer a macros.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-07 19:21:59 +04:00
Cyrill Gorcunov
e4d5ad236b files-reg: Drop redundant double semicolon
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-06 18:28:27 +04:00
Andrey Vagin
c69be631e1 mntns: crtools: stat pathes relatively of a mntns root
If we dump tasks with mntns, we should look at pathes from point of a mntns root.

Now we support a situation when a root of an init task has the same root as the
mntns root, because we have not another way to get a root of mntns.

A path to an unix socket is copied, because the origin copy will be gone
out from the function, where it was created.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-01 07:00:48 +04:00
Cyrill Gorcunov
9d0875a813 files-reg: Use close_safe for fd variable
This makes compiler happy.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-31 14:09:49 +04:00
Pavel Emelyanov
9fc1d6bbeb fdinfo: Make fdinfo.type be an enum
This types specifies a strict set of what is hidden behind
the fd. Thus these numbers should be in the description of
the fdinfo message.

Plus protobuf makes shure nothing else will be there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 10:18:37 +04:00
Cyrill Gorcunov
0468355c12 protobuf: Drop fown_t type
We are ready to use FownEntry everywhere,
so drop fown_t type and clean up source code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 09:39:00 +04:00
Cyrill Gorcunov
1d484b713a files-reg: Use pb_ helpers to shrink the code
Use recently introduced pb_ helpers to shrink the code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-17 07:25:38 +04:00
Cyrill Gorcunov
98acfbec28 protobuf: Use RemapFilePathEntry instead of struct remap_file_path_entry
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-17 07:18:58 +04:00
Cyrill Gorcunov
5364592157 protobuf: Use GhostFileEntry instead of struct ghost_file_entry
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-17 07:17:51 +04:00
Cyrill Gorcunov
8041eac0e5 protobuf: Use RegFileEntry instead of reg_file_entry structure v3
This patch switches reg_file_entry structure with RegFileEntry
protobuf entry. Note that there a few nits remains

 - old fown_t structure doesn't scale well with FownEntry from
   RegFileEntry, so to not mess with rest of crtools code
   I've added a couple of opencoded copy operands, will clean
   this aspect up once rest of code is converted

 - the "show" procedure doesn't print fown for same reason

v2:
 - rename fown_t to fown_entry in .proto
v3:
 - don't print nil symbol on show

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-17 07:17:02 +04:00
Pavel Emelyanov
e21885b0de regfile: Fix regular file open and lseek on restore
1. Seeking should be done for real files only , for fifos using the
   same code -- shouldn't. Thus -- move the lseek to proper place;
2. It's nice to print error on file open error;
3. It's nice to handle lseek error.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-12 08:37:39 +04:00
Pavel Emelyanov
a135b40ba2 ghost-files: Merge dump and restore helper structs
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-01 06:25:34 +04:00
Pavel Emelyanov
3b8fef5227 fifo: Sanitize fifo restore
Don't push open cb onto reg_file_into, pass it into regfiles engine
as an argument.

Note: I haven't merged the fifo zdtms yet, thus this patch is untested.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Tested-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-07-01 21:47:24 +04:00
Cyrill Gorcunov
ea1ce8e472 fifo: Add checkpoint restore for fifos v4
Checkpoint and restore of fifo is similar to
pipes c/r except the pipe end-points are named
file.

Because the fifo has a name we use regular files
facility for fifo path c/r.

Still there is a trick used to "open" fifo:
the opening procedure migh sleep if a fifo's peer
is not yet opened, so before doing a real open
we yield a fake open procedure (with O_RDWR flag)
which prevents us from sleeping even if peer
is not yet ready. Also we need writable fifo
end to restore data queued.

v2:
 - add open/priv members to reg_file_info
 - make open_fifo_fd to use open_fe_fd
 - comment on pipe_id
 - make sure the fifo data is not restored twice

v3:
 - drop useless fixme comment and add sane one
v4:
 - Use restore_data flag to escape data restore duplication
 - Use S_ISREG for file contents copying

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-01 17:15:48 +04:00
Cyrill Gorcunov
18145c50c1 files-reg: Create fifo ghost node if needed v2
Allow file path remap engine to create fifo nodes.
Note for fifos the copy_file is not called since
we will restore fifo data via pipe-data engine.

v2
 - no need for dev in mknod
 - don't reopen local copy on fifo files

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-01 17:14:32 +04:00
Pavel Emelyanov
57095eb946 util: Helper for reading a string from image
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-27 20:57:35 +04:00
Cyrill Gorcunov
d53a820b37 files-reg: Eliminate memory leak in open_remap_ghost on errors
xmalloc'ed gf and gf->path are not freed if something failed.
Not a big deal since we're ususally interrupt program execution
on error and do exit, but anyway.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-21 12:13:05 +04:00
Cyrill Gorcunov
9478974680 files-reg: Align and reorder structure members
This eliminates holes in structures. No func changes.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-21 12:12:04 +04:00
Cyrill Gorcunov
47506e8d2d files-reg: Add missing new line before open_reg_by_id helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-21 12:11:32 +04:00
Cyrill Gorcunov
4a85120cbf files-reg: Use stack variable in dump_one_reg_file
No need to carry static per-file variable, we need
it in one non-recursive function only so make it
stack based instead.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-21 12:11:15 +04:00
Cyrill Gorcunov
4140c9e4ec files: Move regular files handling code to files-reg
Instead of spreading regular files handling code over
files.c and cr-dump.c move it to files-reg.c.

This allows to extend regular file handling code in
future without disturbing other source files and
make code logically coupled, where files.c is mostly
a place for general file handling code unrelated to
file type specifics.

While mostly it was code tossing there is some change
I have to notice -- the structure ghost_file was previously
declared in two paces cr-dump.c and files.c, in cr-dump.c
it was used for dumping while in files.c it was used
for restore. The structure had different members.

So to resolve this conflict the ghost_file structure
was renamed to ghost_file_dumpee.

Nothing else is changed.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-21 12:10:13 +04:00