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

1467 Commits

Author SHA1 Message Date
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
Andrey Vagin
c8e6be95e4 restore: create pid namespace
A pid namespace is created if a pid of the first task is 1.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:16:19 +04:00
Andrey Vagin
83e6d14efd cr-dump: split collect_dump_pstree to collect and dump
When we dump pid ns, dump_pstree is called after dump_tasks

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:16:10 +04:00
Andrey Vagin
772edd462c parasite: add ability to get pid and tid
If we try to dump a process from another pid ns,
we have not another way to get its pid.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:16:01 +04:00
Andrey Vagin
4b48849c32 ctrools: prepare to dump pid namespace
Add struct pid and use it everywhere. This struct contains
two fields: pid and real_pid.

real_pid is a pid outside of the target pid namespace.
pid is in the target pid namespace

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:13:52 +04:00
Cyrill Gorcunov
2adbbcba89 pipes: Don't forget to init pipe_info::create
Otherwise its value might be taken from heap (it's xmalloc'ed).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:45:18 +04:00
Cyrill Gorcunov
70b65c9a50 pipes: Don't call for restore_fown if open failed
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:33:09 +04:00
Cyrill Gorcunov
6b06c744db pipes: Style tune up for pipe_info members
- align members
 - comment with empty line

No func changes.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:32:14 +04:00
Cyrill Gorcunov
f973fcabb9 pipes: Shrink pipe_should_open_transport to want_transport
It's static function near the file_desc_ops,
no need for a long name.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:30:36 +04:00
Cyrill Gorcunov
61e289f184 pipes: Reorder functions
Checkpoint and restore do use fdtype_ops
and file_desc_ops intensively so reorder
pipes functions, this allow us to make
them static and drop additional declarations.

No func changes.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:30:03 +04:00
Cyrill Gorcunov
f3c93470e1 pipes: Get rid of dangling line in dump_pipe
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:29:24 +04:00
Cyrill Gorcunov
28cd2a7633 pipes: Add missing void into func arguments
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:28:53 +04:00