2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00
Commit Graph

1856 Commits

Author SHA1 Message Date
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
Pavel Emelyanov
9e84bd1083 pb: Introduce pb message types and cr-descriptors
The protobuf-c generate plain routines for entries manipulations, but
we want to have some "generic" way of working with messages. Collect them
all in an array of descriptors (similar to image files descriptions) and
do full typechecking while this.

Such thing will allow to simplfy code later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-07 19:21:58 +04:00
Andrey Vagin
8bff4c7fca restore: consolidate restoring of a root task in one blob
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-06 18:37:13 +04:00
Andrey Vagin
703a322cc0 restore: mount_proc return a result instead of exit
In addition it fixes error handling.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-06 18:36:59 +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
Andrey Vagin
4c88cafe43 restore: fix clean up in PIDNS
When processes are restored in PIDNS, the controll process (crtools)
don't know a real pid of processes, but it knows a pid of init.

crtools can kill init and all other processes will be killed too.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-06 18:31:39 +04:00
Andrey Vagin
a5dff04d6a socket_listen: interrupt a parent if a child exited
When a child exited, SIGCHLD is sent to parent,
if SIGCHLD has handler without SA_RESTART, the current
syscall will be interrupted.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-06 18:30:45 +04:00
Cyrill Gorcunov
c60661051d doc: Update -n option
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-06 18:30:02 +04:00
Cyrill Gorcunov
25b35f13b6 help: Add mnt and net options into the list
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-06 18:29:53 +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
Cyrill Gorcunov
750324af65 mount: Cleanup readlinkat calling
- Use sizeof instead of PATH_MAX constant
 - Place EOS exactly after read data end

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-06 18:28:12 +04:00
Pavel Emelyanov
f345fc8f10 parasite: Don't pull opts through the stack
Revert and tune 9eda83b7. Andrey reminded me that we have
global instance of cr_options.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 16:25:52 +04:00
Andrey Vagin
bd4e5d2f9d restore: prepare shared objects after initializing namespaces
On this stage crtools unlink old socket files, create ghost files and etc,
so we should be in a correct namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 16:08:06 +04:00
Andrey Vagin
420325dca6 restore: add an option for changing a root file system (v2)
The option is -r|--pivot-root and an argument is a path to new root.
A root task will make pivot_root. LXC CT does that, so we need that
for restoring.

v2: s/pivot-root/root/

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 16:07:43 +04:00
Andrey Vagin
3cb5969b25 pstee: fix memory corrupation
The pstree_item for helpers is allocated without rst_info.
Before this patch prepare_fd_pid was executed for such items and
touched rst_info.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 15:54:54 +04:00
Pavel Emelyanov
ce25c67b90 zdtm: Wire signalfd00 in
The kernel patch is in 3.5 branch, so we can make this test
run automatically.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 12:49:51 +04:00
Pavel Emelyanov
f289ac2c1a zdtm: Signalfd testing
It's not in zdtm.sh yet, since kernel patch is not yet
committed. When kernel is updated, the zdtm.sh will be too.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 12:28:16 +04:00
Pavel Emelyanov
da2d59a2e7 signalfd: Checking code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 12:27:45 +04:00
Pavel Emelyanov
da409cc641 signalfd: Dumping and restoring
Only the fact of the fd presence, its flags and fown and the sigmask.
The sigpending state is tightly coupled with the task's sigpending
state which is not yet supported.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 12:26:35 +04:00
Pavel Emelyanov
8097a8dc09 signalfd: Add proc fdinfo parsing facility
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 12:25:18 +04:00
Pavel Emelyanov
0401664144 signalfd: Add protobuf descriptions
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 12:24:27 +04:00
Pavel Emelyanov
92e739e9b6 mount: Reset mountinfos when mntns recreated
The list of mounts is used by inotify to restore a watch with open-by-handle. The problem
is that after the clean_mnt_ns is done the mntinfo list is no longer relevant.

Fix it by freeing the old one and initializing the new with the read-from-image stuff.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 09:54:22 +04:00
Pavel Emelyanov
d8a6ecc630 zdtm: Netns basic test
Only checks for lo, one simple ifaddr and two routes are handled. Sanity
test and nothing more.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 08:32:06 +04:00
Pavel Emelyanov
a6439860cd net: Routes dump and restore
Same here -- run ip tool and that's it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 08:31:46 +04:00
Pavel Emelyanov
fc1eb96783 netns: Ifaddrs dump and restore
Just run the ip addr save and ip addr restore respectively.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 08:26:43 +04:00
Pavel Emelyanov
0b9b1bd91a netns: Introduce a routine that runs ip tool for dump/restore
The thing is that the ip utililty is very likely to have support
for ifaddrs and routes dumping and restore (rtnl messages are
symmetrical wrt dump/restore and this can be easily dump in there).

Thus, the best we can do it just use this tool for that and carry
the "raw" images with ifaddrs and routes dump.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 08:21:19 +04:00
Pavel Emelyanov
4943eb43fd netns: Basic link dump, restore and show
Only support the lo device. This is not final yet (much more
stuff is to be handled for a link) but is rather a skeleton
showing how to do it and letting us check the LXC container
early.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 08:17:27 +04:00
Pavel Emelyanov
f006545a0a parasite: Switch netns before creating transport socket
If the target task sits in another netns the sockets will
not be able to interconnect unless we create the host-side
one in the same netns. Thus do it and then roll back the
namespace.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 08:10:22 +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
9eda83b74a parasite: Pull cr_options down (or up) to transport sock creation
We'll need to check whether the socket is to be created in a net
namespace (since we can't detect this automatically yet). Thus the
namespaces flags are required there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 07:53:02 +04:00
Pavel Emelyanov
38431fb161 img: Introduce the notion of a raw image
Raw images are supposed to be files with non-crtools contents.
E.g. tarballs with tmpfs contents or iptables-save output. Another
example is -- ip tool addr and route dumps we're about to merge
soon.

Having these type of images allows to use the open_image and the
cr_fdset engine easily.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 07:42:41 +04:00
Pavel Emelyanov
7b7e4826dc netlink: Fix NLMSG_ERROR handling
This type of message is also reported for NLM_F_ACK is requested
and no necessarilly indicates an error. The error code is in the
message body.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 07:36:12 +04:00
Pavel Emelyanov
b0cf603b18 netlink: Pass argument through do_rtnl_req engine
Will need it int netns dumping callbacks later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 07:36:12 +04:00
Pavel Emelyanov
cffe1ea172 netlink: Remove handmade rtnl macros/definitions
All we need is (should be) in rtnetlink.h

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 07:36:12 +04:00
Pavel Emelyanov
b7b5bfdd28 libnetlink: Move the rtnl req routine into libnetlink.c
The function that does socket collecting is actually a rtnl
request sending one. It will be usefull for netns dump/restore,
so move it to generic place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 07:36:12 +04:00
Andrey Vagin
2e9ddccdb9 restore: rework logic about temporary proc
We need proc for restoring processes. The existent /proc may be not suitable.
E.g. If processes are in pidns.

crtools mounts procfs in a temporary directory, but it should be
umounted at the end. Before this patch crtools did that, but
it doesn't work if processes in a mount namespace.

Actually this logic can be simplified and this patch does that.
* create a tmp dir
* mount procfs
* open this directory and save a file descriptor.
* detach procfs
* remove the tmp dir
* access to proc via openat, statat and so on.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-01 15:01:13 +04:00
Pavel Emelyanov
2f272fa187 parasite: Don't recreate host-side transport socket
When dumping a net namespace we'll have to create the transport
socket in the target namespace. In order to do this we'll have
to call setns swice -- before and after socket() call.

I don't want to do it for every single task to dump, let's cache
the socket instead.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-01 10:17:14 +04:00
Pavel Emelyanov
6cf65d0fe0 parasite: Remove the connect-tsock command
Do init and transport sockets interconnections in one
switch to parasite.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-01 09:48:02 +04:00
Pavel Emelyanov
bc21b29ba6 fdinfo: Report miss of required entries on parse
Otherwise dump succeeds but is inconsistent.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-01 07:41:19 +04:00
Andrey Vagin
1fef842025 zdtm.sh: dump mount namespace for test_init
* s/pidns/ns/
* Add option --namespace mnt to "crtools dump"

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-01 07:01:36 +04:00
Andrey Vagin
9c1fa58c9d test_init: add support of mount namespaces
A part of code has been copied from mountpoints.c

This code umounts all points except /proc and /

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-01 07:01:29 +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
Andrey Vagin
3a60163b71 zdtm: open a file in mountpoints.c
We need to check that opened files can be restored in mntns
[xemul: s/slabinfo/meminfo as in 9dc050fd]

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-01 06:57:20 +04:00
Andrey Vagin
368d7ac0e6 zdtm: test_init exits, if all children died
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-31 15:48:16 +04:00
Andrey Vagin
a954120154 zdtm: close a write end of a status pipe in a parent process
Otherwise a parent hangs if a child died, because
it reads from a status pipe.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-31 15:47:15 +04:00
Andrey Vagin
44c2ac9310 zdtm: test_init creates a pid file
Before this patch we use pidof to get a pid of a test process.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-31 15:47:07 +04:00
Konstantin Khlebnikov
9dc050fde0 zdtm: /proc/slabinfo not present in container
PCLIN-31078

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-31 15:45:57 +04:00
Victor Konyashkin
2fe7ed666b zdtm: It's need define CLONE_NEWIPC for redhat-el5
The patch allows define CLONE_NEWIPC for redhat-el5.

Signed-off-by: Victor Konyashkin  <vkonyashkin@parallels.com>
Acked-by: Andrey Wagin <avagin@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-31 15:08:25 +04:00
Victor Konyashkin
fc3a5ebd3d zdtm: It's need define CLONE_NEWPID for redhat-el5
The patch allows define CLONE_NEWPID for redhat-el5 to avoid error:
test_init.c:114: error: 'CLONE_NEWPID' undeclared (first use in this function)

Signed-off-by: Victor Konyashkin  <vkonyashkin@parallels.com>
Acked-by: Andrey Wagin <avagin@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-31 15:07:07 +04:00