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

55 Commits

Author SHA1 Message Date
Andrey Vagin
e63f8c20e9 uts: don't use global fdset for dumping namespace
We are going to replace pid on id in names of image files. The id is
uniq for each namespace, so it's more convient, if image files are
opened per namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:10:57 +04:00
Andrey Vagin
faf7b94868 netns: don't use global fdset for dumping namespace
We are going to replace pid on id in names of image files. The id is
uniq for each namespace, so it's more convient, if image files are
opened per namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:10:45 +04:00
Andrey Vagin
762d932cbb namespace: open images per namespace to show them
It's preparation to replace pid on id in image names.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:10:13 +04:00
Pavel Emelyanov
b18fb09eb9 show: Replace one-line show_foo calls with args array
We have generic do_pb_show() call and tons of show_foo
routines, that just call one with proper args. Compact
the code by putting the args into array and calling
the do_pb_show() in one place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-24 04:00:32 +04:00
Pavel Emelyanov
8af6a39f82 ns: Mark descs array static
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-24 15:30:39 +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
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
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
Pavel Emelyanov
6bf22f8c75 crtools: Get rid of on-stack cr_options
We have global instance of them, that's enough.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-28 21:11:13 +04:00
Pavel Emelyanov
ec50a07727 ns: Add c/r for /proc/$pid/ns/$ids references
Based on work done by Cyrill Corcunov (many thanks for that).

In this commit we implement c/r for files which have opened
/proc/$pid/ns/$ids entries.

The idea is rather simple one

Checkpoint
==========

- Check if the file name is the one of known to be ns ref
- If match then write protobuf entry

Restore
=======

- Read all ns entries from the image
- When criu tries to open one we lookup over process
  tree to figure out which PID should be used in path
  and then just open it

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 04:00:05 +04:00
Cyrill Gorcunov
30936058a0 ns: Extend ns_desc to carry the length of the ns name
This will be needed for fast parsing of procfs ns references.

[ xemul: Add user_ns_desc here ]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 03:36:56 +04:00
Pavel Emelyanov
add21b75c9 show: Remove options args from ->show callback
This thing is global, we can address one explicitly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-08 00:23:42 +04:00
Kir Kolyshkin
41c7ca8218 Fix typos in comments
This is less useful than fixing typos in output messages, but anyway.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-15 12:46:46 +04:00
Andrey Vagin
a520b1b8cd namespaces: close fd on the source netns in restore_ns
It's opened in switch_ns.

CID 996194 (#3 of 5): Resource leak (RESOURCE_LEAK)
11. leaked_handle: Handle variable rst 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:22:36 +04:00
Pavel Emelyanov
6241a057b8 show: Beautify -D mode show
Print delimiters and image names for easier reading of the output.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 11:30:14 +04:00
Pavel Emelyanov
475bb1e775 rst: Evaluate per-task clone mask early
When we've read all pstree-items and their ids we
can get the desired clone-flags early and avoid all
these dances with flag calculations in fork_with_pid
and company.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-19 01:16:19 +04:00
Pavel Emelyanov
792bf0c494 cr: Fix namespaces restore from older images
In old images we had no clue whether the root task is to be
created in new namespaces. Remember using the --namespaces
option for explicitl specification of this fact.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:26 +04:00
Pavel Emelyanov
ac845bd1d8 cr: Obsolete the --namespaces option
It's no longer required to use this option -- two currently
supported cases (tasks on host and tasks in containers) can
be detected automatically. Keep this option for future.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:16 +04:00
Pavel Emelyanov
a46831aee9 cr: Detect namespaces presence automatically
Introduce the current_ns_mask variable, that collects info about
which namespaces tasks being dumped and to be restored live in.

For simlicity all tasks are supposed to live in one set of spaces.
This should be fixed eventually.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:10 +04:00
Pavel Emelyanov
2105e18eee core: Save tasks' namespaces IDs in the ids image
The recent kernels allow to get namespaces IDs by reading proc-ns links.
Use this to generate IDs for tasks' namespaces (I do generate them, since
IDs provided by kernel look ugly :( ).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:18:33 +04:00
Pavel Emelyanov
3a1c7d1d76 ns: Introduce ns descriptors
These are structs that (now) tie together ns string
and the CLONE_ flag. It's nice to have one (some code
becomes simpler) and will help us with auto-namespaces
detection.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-15 23:24:01 +04:00
Andrey Vagin
e3fbb63080 crtools: use a special function for executing external utils
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-28 14:09:58 +04:00
Andrey Vagin
e1b02a48c1 cr-restore: block SIGCHLD for restoring namespaces
Restore of namespaces requires executions of external tools
(ip, tar, etc). We want to know return codes, so we should
block a default sigchld handler. Before we did that for each
command, I suggest to block SIGCHLD, then restore namespace and
unblock SIGCHLD.

The default sigchld handler is used for catching target processes,
but all this processes (except a current one ) are started after
restoring namespaces.

Currently we forgot to block SIGCHLD before executing "ip",
and this bug was caught.

Reported-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-25 15:59:13 +04:00
Andrey Vagin
91ea3b922b namespace: return -1 if one of ns can't be initilized
[xemul: Added explicit braces into ifs]

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-06 18:36:35 +04:00
Pavel Emelyanov
0a827aa96c net: Basic netns dump/restore skeleton
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 08:06:29 +04:00
Pavel Emelyanov
2d56d1b056 ns: Add ability to save original ns and restoring it back while switcing
This will be required for parasite transport socket creation -- it will
have to be created in a net ns we're putting parasite in and then we'll
have to restore it back to original to go on dumping.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 07:55:05 +04:00
Pavel Emelyanov
95964f1b13 mount: Core for creating mount namespace
Namespace restore goes in two steps -- first, clean old mountpoints
(except root) that are left after clone(CLONE_NEWNS) call. Next,
repopulate the namespace with new mountpoints (except root) read
from the image file.

This patch adds the skeleton for the above -- reading the mountpoints
from current proc and image and calling for mount/umount. The real
action will come in further patches.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-27 20:57:36 +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
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
Stanislav Kinsbursky
41195598cf parasite: remove excessive header deps from parasite.h and friends
The task is not complete - this is just a part of what have to be done. I.e.
looks like a lot of excessive deps can be fixed.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-30 12:50:18 +04:00
Andrey Vagin
8a1337641f namespaces: include namespaces.h
to be sure that all declarations consistent.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-15 13:35:36 +04:00
Pavel Emelyanov
db297a0f97 mnt: Preparations for mountpoints dumping
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-12 03:30:10 +04:00
Kinsbursky Stanislav
35eedb5f1f output: add "0x" to hex prints using sed
Command below was executed several times:

sed 's/\(pr_.*[^%,x,X]\)\(\%[0-9,l,L]*x\)/\10x\2/g' -i *.c

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 12:33:35 +04:00
Pavel Emelyanov
c58abfd03d show: Introduce ->show callback for fdset
Each fdset item now has the callback which will show a contents of a magic-described
image file. Per-task and global show code is reworked to walk the respective fdsets
and calling ->show on each file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 12:01:14 +04:00
Pavel Emelyanov
3858ee4950 fdset: Introduce two fdsets -- task and ns
Write two helpers for opening an fdset for task and one for ns.

This probably can be done with some "generic" macro(s), but this
time it's simpler not to produce more code of that type.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:57:00 +04:00
Pavel Emelyanov
bcf9ee3d1c fdset: Helper for getting fd out of a set
This patch does

s/$fdset->fds[$nr]/fdset_fd($fdset, $nr)/

over the code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:56:59 +04:00
Pavel Emelyanov
7241b9291b fdset: Kill ability to re-use fdset
It's not required any longer. Now fdsets are allocated one-by-one only
when required and there's no need in adding new fds to existing sets.

Thus just remove the last arg from cr_fdset_open.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:56:51 +04:00
Kinsbursky Stanislav
4101487f87 IPC: show semaphores set
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-15 13:33:46 +04:00
Kinsbursky Stanislav
24c4381644 IPC: show message queue dump content
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-14 20:21:30 +04:00
Kinsbursky Stanislav
516099d885 IPC: show shared memory dump content
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-09 13:21:46 +04:00
Kinsbursky Stanislav
9ef1cb99b6 show: add IPC variables to "show all" command
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-09 13:00:03 +04:00
Kinsbursky Stanislav
65e8eb7a2d show: check UTS ns fd before show
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-09 12:58:53 +04:00
Kinsbursky Stanislav
a0ec1002b2 crtools: cleanup fdset initalization
v2: wrappers names become less obfuscating

This patch:
1) Updates function cr_fdset_open() to be suitable for handling fdset creation
for dump and show stages.
2) Replaces cr_fdset_open() by new wrapper function cr_fdset_dump().
3) Replaces prep_cr_fdset_for_restore() by new wrapper function cr_fdset_show().

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-08 21:43:12 +04:00
Stanislav Kinsbursky
8971be17fd checkpoint: namepsaces info to dump log
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-03 21:26:50 +04:00
Cyrill Gorcunov
7197b9467d namespaces: Eliminate uninitialized 'ret' usage
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-01 17:23:44 +04:00
Stanislav Kinsbursky
c75c33cb86 IPC: restore namespace itself
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-31 22:32:22 +04:00
Stanislav Kinsbursky
c826057a9c IPC: dump namespace itself
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-31 22:32:22 +04:00