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

1528 Commits

Author SHA1 Message Date
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
Pavel Emelyanov
fc416d8694 mount: Build mount points tree out of a plain list
Build a tree of mountpoins that can be (u)mounted in a straight
(forward or backward) order without EBUSY errors.

The tree is built in two steps -- first create hierarchy based
on mount iDs. Next -- resort siblings in the path depth order.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-27 20:57:34 +04:00
Pavel Emelyanov
8f288a0c51 mount: Dump fstype
Encode it in u32 since we have to check filesystem name anyway
(not everyone ie easily migratable).

Dump _any_ root fs as we need the root entry on restore though
do not mount it then -- it should be provided before crtools
restore start.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-27 20:57:32 +04:00
Pavel Emelyanov
54f42f2bfe mount: Basic mount points dumping
Dumping is straightforward -- just copy all the mount_info
fields into the new image file. Dump everything but fstype,
this one will come in a separate patch.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-27 20:57:31 +04:00
Pavel Emelyanov
e0cb53a19f mount: Rename struct proc_mountinfo into mount_info
This structure will be used on restore and will be created
from the image, thus the name proc_ is not suitable.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-27 20:57:30 +04:00
Pavel Emelyanov
b580345518 mount: Allocate mountinfo strings dynamically
On the restore path this structure will be used and it
will be better to have them char * rather than char[64].

When scanning proc use the %ms specifier for this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-27 20:57:29 +04:00
Andrey Vagin
c74fb299d8 parasite: remove the useless BUG_ON
It's not required more, because parasite_status_t was removed.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-27 14:52:27 +04:00
Andrey Vagin
3b8b68464a parasite: remove parasite_status_t, a return code is enough
In olden times, when people didn't know how to write,
they sent a courier with a letter.

Now we can write messages from parasite, so SET_PARASITE_RET may be dropped.

Signed-off-by: Andrey Vagin <avagin@openvz.org>

Looks good to me as well. Maybe we will refine messages to be able
to identify where exactly parasite failed (say line). But it better
to do in another patch.

Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-27 14:52:01 +04:00
Andrey Vagin
97a08a801a parasite: return exit code from parasite
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-27 14:50:44 +04:00
Cyrill Gorcunov
3f6f291668 pipes, show: Fix tail message in show_pipes_data
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-25 18:25:53 +04:00
Cyrill Gorcunov
3c18a9f47e Beautify files.h
- add argument names
 - align members
 - add extern kw
 - group struct decl. on top
 - make file_desc_ops::type being unsigned
   integer similar to fdtype_ops::type

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 17:03:13 +04:00
Cyrill Gorcunov
cb74aa3e48 files: Drop redundant declarations from files.h
These are declared in files-reg.h, so get rid of
them and add files-reg.h inclusion where needed.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 17:02:23 +04:00
Andrey Vagin
16c7adecdd zdtm: add two test cases for tty-s
* check, that pseudoterminals are restored
* check, that a control terminal is restred

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:17:54 +04:00
Andrey Vagin
24074a9dbb zdtm: add new test case for checking that SID is restored
2     2 session00
    4     4  \_ session00		# {NEWSID, },
    2     5  \_ session00		# {0, },
    8     8  \_ session00
    2     9  |   \_ session00           # {CHANGESID, }
   10    10  \_ session00
   11    11      \_ session00
    2    12          \_ session00	# {DOUBLE_CHANGESID | CHANGESID, }
    2     3 session00			# {DETACH, },
    6     7 session00			# {DETACH|NEWSID, },

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:15:30 +04:00
Andrey Vagin
a4685cd30c restore: check own sid instead of parent's one
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:15:23 +04:00
Andrey Vagin
1264a7a9c6 restore: fail restore if pgid or sid are not restored
Don't fail if a root non-init task has another sid, because
it's inherited from parent and can't be restored and
it's expected behaviour, when a subtree is dumped.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:15:03 +04:00
Andrey Vagin
325ff7b4ab dump: don't check xids
Now crtools can restore sid in all cases.
A restore of pgid will be added soon and now it will fail on restore.

It's prevent testing of restoring SIDs.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:14:35 +04:00
Andrey Vagin
8c4017d933 restore: print message about sid only if it's restored
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:14:14 +04:00
Andrey Vagin
9b8a206729 restore: restore sid of task which isn't leaders and isn't a child of init (v4)
It's sign, that a parent has been changed sid after forking a child.
We should know a sid with which a process was born, because in a processes
chain, more then one process might change SID.

v2: fix names of variables
v3: prevent rewriting of born_sid
v4: Abort the restorer with error message if a born_sid can't be determing.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:13:58 +04:00
Andrey Vagin
2c412fa6ac restore: restore sids of tasks, which have been reparented to init (v3)
* Create helpers for processes which have been reparented to init.
* Insert helpers in a process tree.
* Helpers will exit after constructing a process tree.

v2: fix variables names and check errors
v3: add comments in code

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:13:26 +04:00
Andrey Vagin
eb9a6f2015 restore: add interface for creating helper tasks (v3)
They will be used for restoring sid. For example, if a session
group leader is absent, a helper process is created with this id
and it will die after restoring all other tasks.

Before this patch restore failed if anyone exited.
Now we should skip helpers, which exited successfully. It's a bit tricky.
All children are collected in sigchld_handler, but we have a point,
where we want to wait all helpers. For that waitpit is used and ECHLD
is ignored, because it signs that a helper exited and has been waited in
sigchld_handler.

v2: check that me isn't NULL in the sig handler
v3: move code about waiting helpers in a separate function

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:12:26 +04:00
Andrey Vagin
acacc6049e restore: calculate a maximum value of PID-s
It will be used for allocating PIDs for helper tasks

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:11:41 +04:00
Andrey Vagin
8075dc60a5 pstree: rename fields in struct pid
s/pid/virt/
s/real_pid/real/

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:09:44 +04:00
Andrey Vagin
9b3b059bdc crtools: add "pid" to the --namespaces cmdline option arguments (v3)
to require dumping pid namespace. Dump and restore will be failed if
a tress doesn't contain a process init.

pid namespace will be created implicitly if a process init in the tree.

v2: fix comments from Pavel
v3: Restore of pidns should be approved by user

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:08:57 +04:00
Pavel Emelyanov
57b1e94522 files: Sanitize transport creation
Current if/if/else scheme is ... not so easy to understand. Here's an
attempt to make it more readable. Bonus: free comments.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-21 17:37:10 +04:00
Pavel Emelyanov
3d24b7d54e files: Don't lookup fle by itself
When creating transport we have to find the corresponding fle. Currently
this is done by desc list scan %) but this is an overkill -- the required
fle is already at our hands.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-21 17:36:25 +04:00
Pavel Emelyanov
a842cfe68f files: Don't lookup fdesc twice
In the open_fdinfo we need to get a file_desc associated with the given
fdinfo_list_entry. This is done by searching the hash of descs, but this
can be speeded up by saving the desc pointer on the fdinfo at the time
of collecting them.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-21 17:32:56 +04:00
Andrey Vagin
338bc1349c crtools: add comments to fields of struct pid
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-21 12:19:58 +04:00
Andrey Vagin
278e975ed3 dump: rename dump_tid_addr to dump_tid_info
because now it cares about tid_addr and thread id.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-21 12:18:50 +04:00
Andrey Vagin
b11785212b zdtm: remove unused code from sockets_dgram
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Victor konyashkin <vkonyashkin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-21 12:17:25 +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
Andrey Vagin
ebb8066599 zdtm: fix adding test cases to the list
bash returned the error : No such file or directory
and doesn't add three test cases to the list.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-21 12:05:29 +04:00
Pavel Emelyanov
60bd133e53 sk: Do not lookup a socket twice
The socket_desc is being looked up in dump_unix/dump_inet. In
the dump_socket this desc is only required to obtain a family,
which in turn can be done with a getsockopt.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-20 19:24:49 +04:00
Pavel Emelyanov
49da2834a5 fd: Cleanup in dump_one_file
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-20 19:24:48 +04:00
Pavel Emelyanov
9ca95b5d3a fd: Remove ID from fd_parm
It's only required for making pipe_id, but making it is better to
be done in place and using the st_ino only.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-20 19:24:46 +04:00
Cyrill Gorcunov
582954685b Escape using unsafe sprintf helper
Util it's very critical for speed we should
not use unsafe sprintf helper, we're root-granted
program and must be as safe as possible.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-20 15:04:51 +04:00
Evgeny Antyshev
d25f5348ae zdtm: uptime_grow test
new testcase important for rebootless update testing:
we query system timer CLOCK_MONOTONIC continuously
and fail in case it stepped backwards

Signed-off-by: Evgeny Antyshev <eantyshev@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-20 15:02:53 +04:00
Andrey Vagin
606ad446ec zdtm.sh: execute all test in NEW_PIDNS in addition (v2)
Now the most part of test cases may be executed in pidns.
By default all test cases are executed in current pidns, then
they are executed in new pidns again.

v2: remove the hard coded path to  test_init

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:19:34 +04:00
Andrey Vagin
d4a5938d8f zdtm: add a test init for executing tests in PIDNS
Add a small program, which clones a process in new PIDNS and executes
a test.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:18:23 +04:00
Andrey Vagin
b8e12c4829 restore: mount proc for a new pid namespace
Create a tmp directory and mount proc from a target pid ns.
This proc will show pid-s from the target pid ns.

crtools uses map_files for restoring sharing mappings.

the tmp directory is removed after restore.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:17:32 +04:00
Andrey Vagin
bdfb0d80fa shmem: used open_proc_rw to open proc files
open_proc_rw knows that proc may be mounted not in /proc,
it's used for restoring tasks in pid ns.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:17:24 +04:00
Andrey Vagin
4ebc875995 util: add ability to change a proc mount point (v2)
v2:  rework this by using openat() and service fds for proc root.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:17:16 +04:00
Andrey Vagin
0ee0b197bd dump: split real_pid and pid in struct pid (v2)
Now pid is dumped from pid ns, it's gotted from parasite.

v2: fail if a zombie is in PIDNS

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:17:07 +04:00
Andrey Vagin
634dd10b32 namespaces: dump_namespaces get a struct pid as argument
It uses pid for create image file and real_pid for dumping ns-s.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:16:54 +04:00
Andrey Vagin
c48bcbdb60 dump: move check_xids to dump_pstree
because in collect_pstree we don't know pid-s of processes inside pidns

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:16:44 +04:00
Andrey Vagin
20d2c780ce cr-dump: dump pstree after tasks
because a pid in a target pid ns is got from parasite.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:16:33 +04:00