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

4661 Commits

Author SHA1 Message Date
Andrey Vagin
f1b4c5ea9f mount: use per-ns list of mount-points in clean_mnt_ns and free_mnt_ns
We are going to dump nested mount namespaces, so we move the mountinfo
list on the namespace structure.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:40:03 +04:00
Andrey Vagin
26a0dc91dd mount: add a function to get a temporary root for mntns
On restore all mount namespaces are restored in the root mntns and
sub-namecpeaces are restored in temorary places.

This function allows to get paths to these places.

It will be used in open_remap_ghost(), because it's called in the root
task, when other tasks are not forked yet.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:59 +04:00
Andrey Vagin
4e6e60a828 irmap: mntns_collect_root in irmap_lookup
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:58 +04:00
Andrey Vagin
3e50d70cd9 mounts: mntns_collect_root in __open_mountpoint
We are going to support nested mount namespaces,
file descriptors can be from different namespaces,
so a namespace root must be updated for each of them.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:56 +04:00
Andrey Vagin
1b3fa9bc25 mount: set nsid for each mount point
We want to look up mntns by mnt_id.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:50 +04:00
Andrey Vagin
5418938ec3 resotre: collect mounts of current mntns
It's required for restoring in the current mntns.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:46 +04:00
Andrey Vagin
e827a695f3 mount: separate collect_mnt_ns from dump_mnt_ns
We are going to support nested mntns, so the global mntinfo_tree
variable are useless and information about tree should be connected
to a proper namespace.

But when we don't dump mntns, we need to collect mounts for the current
mntns.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:41 +04:00
Andrey Vagin
9625ebe596 mount: move dump_mnt_namespaces in mount.c
It will fill mntinfo list and this is internal logic of mount.c

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:39 +04:00
Andrey Vagin
cc1fd5760a mount: save mount tree for each namespace
We are going to support nested mount namespaces and each NS has own
tree. The mount tree is used for checking that a file is reachable.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:34 +04:00
Andrey Vagin
de4326a382 mount: return descriptor from mntns_collect_root
We are going to support nested mount namespaces, so files can be opened
from more than one namespace and a root must be collect for each file.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:32 +04:00
Andrey Vagin
36a9f31665 restore: close PROC_FD_OFF before calling sigreturn
mntns_collect_root() uses PROC_FD_OFF, so we need to close it.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:30 +04:00
Andrey Vagin
22d384536d files-ids: generate id-s accoding with mnt_id, st->st_dev and st->st_ino
One device can be mounted a few times, so files are identical only,
if they have the same mnt_id.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:28 +04:00
Andrey Vagin
6639464503 files: save mnt_id for reg files
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:25 +04:00
Andrey Vagin
87b1f5408c files: save mnt_id on fd_param
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:18 +04:00
Andrey Vagin
9ea2baa2db zdtm: reexec the mountpoints test in a target mntns
Otherwise it will have external files (from another namespace,
which isn't dumped).

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:17 +04:00
Andrey Vagin
15a457bde8 zdtm: Mark all mounts as private with one call
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:38:52 +04:00
Andrey Vagin
0721626902 namespaces: dump mount namespaces before tasks (v2)
because we want to check, that all files are reachable.
For that we need to collect all mounts from all namespaces.

v2: dump mntns separately
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:38:47 +04:00
Andrey Vagin
c51e91f6ec zdtm/mountpoints: test nested mount namespaces
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:38:38 +04:00
Andrey Vagin
d2012883ab criu: rename current_ns_mask to root_ns_mask (v2)
Now we supports sub-mntns, so root_ns_mask sounds more correct than
current_ns_mask.

v2: typo fix
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:38:33 +04:00
Andrey Vagin
4067f4bb7e mount: allow to dump and restore nested mount namespaces (v3)
v2: another attempt to write readable code:)
v3: clean up
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:38:23 +04:00
Andrey Vagin
3a291e33ff crtools: restore nested mount namespaces (v2)
Known issue:
* currently only namespaces with the same root is supported
* nested namespaces can be dumped and restored only if the root task
  has own mount namespace.

All nested namespaces are restored in a root namespace in temporary
directories. All mount points restored in one tree and then they are
divided into namesaces.
The task with minimal pid for each namespaces unshared mntns and
then it makes pivot_root in a proper temporary directory. All other
tasks makes setns to enter into a mount namespace of the task with
minimal pid.

v2: clean up

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:38:17 +04:00
Andrey Vagin
e7e9c2ee6e mounts: create a temporary directory for restoring non-root mntns (v2)
All non-root namespaces will be restored as sub-trees of the root tree.

This patch adds helpers to create a temporary directory and mount tmpfs
in it, then create directories for each non-root mount namespace.

tmpfs is quite useful here to simplify destroying this construction,
we don't need to unmount each namespace separately.

v2: add a comment why MNT_DETACH is not dangerous here
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:38:12 +04:00
Andrey Vagin
fa14bd83f6 mount: Read multiple mntns images (if any) on restore
read_mnt_ns_img() is splited on two parts. The first part enumirates all
namespaces and call the second part, which read a proper image file.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:38:08 +04:00
Andrey Vagin
898335ba32 mounts: Make sure all namespaces has the same root source
Currently we support nested mount namespaces, only if all of them have
the same path to the root.

crtools doesn't mount root, so it should be bind-mounted for all namespaces.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:38:06 +04:00
Andrey Vagin
1edfe53b71 mounts: Connect sub-root to the main root as children
Each sub-namespace is restored as sub-tree of the root mntns, so
the parent of sub-mntns root is the root of the root mntns.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:38:03 +04:00
Andrey Vagin
84c48e6244 mounts: Mark ns' roots in the list of mount points (v2)
When we'll restore nested mount namespaces, all but root ones (sub-namespaces)
will be restored as sub-mounts in the root mount namespace. So mi->mountpoint
will be not '/' even if a mount is root for its mntns.

v2: s/is_root/is_ns_root/
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:37:57 +04:00
Andrey Vagin
eac462922c restore: add mount id-s in the ns_ids list (v4)
Currently ns_ids list is filled only on dump. Soon we'll need this
list for mount namespaces on restore, e.g. to know which tasks share
the namespaces.

v2: merge the patch "namespace: add a function to search an ns_id
item by id" into this one.
v3: add prefix rst_ to add_ns_id
v4: look up namespace by two values -- type AND ID

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:37:52 +04:00
Andrey Vagin
0989d3fdf9 mounts: allow to customize root path for cr_pivot_root (v2)
We are going to restore nested mount namespaces and we will need to
change root for each of them.

v2: don't call chdir in a second time, because a path may be relative
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:37:49 +04:00
Andrey Vagin
d738cf3e0f mounts: initialize root before dumping mount namespace
Currently it's initialized for the root mount namespace, but we are
going to dump nested mount namespaces.

It's used in open_mountpoint(), which is used in dump_tmpfs() and in
other callbacks.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:37:45 +04:00
Andrey Vagin
67456e90ac mount: Close old service descriptor in mntns_collect_root
We're about to collect root several times in a row, so keeping
the old one isn't required.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:36:53 +04:00
Pavel Emelyanov
e8ac085af8 Revert "crtools: close all desriptors only for the root task"
We have a race. Consider we have 3 tasks, A, B and C. A and B
share fdtable, C -- does not. Then we might be in a situation
when A is restoring memory reading mem images, and B -- forking
the C child. In that case descriptors held by A (for mem restore)
will be inherited by C and will not get closed.

This reverts commit d36e07aabe073993d8ae9695e33f6e45b2eb6a21.
2014-04-21 14:48:05 +04:00
Andrey Vagin
4bd119ddf6 ns: clean up dump_namespaces
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-18 19:17:10 +04:00
Andrew Vagin
ee9258e80f mount: take into account btrfs workaround for converting st_dev to phys_dev
BTRFS returns subvolume dev-id instead of superblock dev-id

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-18 15:02:04 +04:00
Andrew Vagin
b664bb142b mount: fill fstypes for btrfs mounts on restore
BTRFS returns subvolume dev-id instead of superblock dev-id,
so we need to know which mounts are btrfs.

The mi->fstype->name is "unsuppoerted" here, because the fstype->code
is saved in an image

{
.name = "unsupported",
.code = FSTYPE__UNSUPPORTED,
},
{
.name = "btrfs",
.code = FSTYPE__UNSUPPORTED,
}

An a second reason is that pocesses can be migrated from smth to btrfs.
This all can happen _only_ for the root mount and for bind mounts of
the root mount...

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-18 15:01:57 +04:00
Tikhomirov Pavel
e01dc7faa6 v2 mem: if no parent image persists, can't rely on it
here was bug cause if e.g.: iterative snapshots are made and
between two of them new process in process tree was created,
it can have pages which are non dirty, and won't save them
into image. but there is no parent image for it.

pages which are non soft-dirty appear if process with some pages
in non dirty state forks, child will inherit those pte's
and if child don't write to those pages, they will be still in non
soft-dirty state when next dump comes.

also this bug was not catched because of error in zdtm, look 3/3

v2: simplify, add more justification in commit message.

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-18 13:50:06 +04:00
Andrey Vagin
8df879941d mount: save relative path in mi->mountpoint
"relative path" is absolute path with dot at the beginning.

We already use relative paths on restore. In this patch we add "."
on dump too. It's convinient, because we needed to add dot each time
when we want to access this mount point.
Before this patch we had to created a temporary copy.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-17 12:05:58 +04:00
Andrey Vagin
946eadd598 mount: open_mount uses __open_mountpoint instead of own logic
Now we have two funсtions which do mostly the same, so this patch merges
them.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-17 12:03:15 +04:00
Andrey Vagin
d07ed2049e mount: fix comparison of stat.st_dev and mount_info->s_dev (v2)
st_dev and s_dev have different formats.
st_dev is (MAJOR(dev) << 8) | MINOR(dev)
s_dev is (MAJOR(dev) << 20) | MINOR(dev)

so we need to convert one of them

v2: use kdev_to_odev
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-17 12:03:13 +04:00
Andrey Vagin
81999b709c mount: open_mountpoint returns a file descriptro
Only one function use DIR, so I don't see reason to return it

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-17 12:03:12 +04:00
Andrey Vagin
87a49bdfaf servicefd: add a service fd for current root
It's already used for dumping files and it will be used for restoring,
so it should be service fd to avoid intersection with restored
descriptors.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-17 12:03:11 +04:00
Pavel Emelyanov
302591aa05 rlimits: Reshuffle new and legacy restoration code
Do the same as was done with timers.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-17 12:01:10 +04:00
Pavel Emelyanov
1d438db66d rlimits: Move entries from top-core into task-core
This appeared after latest 1.2, so it's still possible
to do this move.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-17 12:01:08 +04:00
Pavel Emelyanov
35e560de00 timers: Reshuffle new and legacy restoration code
Make explicit checks and helpers for legacy images.
This should facilitate its removal some day in the
future.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-17 12:01:06 +04:00
Pavel Emelyanov
87da9b83ce posix-timers: Clean restore code flow
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-17 12:01:04 +04:00
Pavel Emelyanov
d48d6c7267 posix-timers: Helper for freeing proc parsed data
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-17 12:01:02 +04:00
Pavel Emelyanov
b54e340945 core: Move posix timers on core entry
This as well gives us minus one image per-task and
allocates more space on core task entry.

One thing to note -- the amount of posix timers is
not easily accessible at the core entry allocation
time, so the respective array is allocated on demand.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-17 12:00:54 +04:00
Pavel Emelyanov
dfd5a62f38 core: Move itimers on core
This allows to have one image less per-task, which in turn
reduces live migration time a little bit.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-17 12:00:52 +04:00
Pavel Emelyanov
0c06ad9d2c core: Introduce task_timers_entry
This one will hold all info about timers in the core_entry.
Since timers are always per-task, this one is on task core
entry.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-17 12:00:48 +04:00
Cyrill Gorcunov
9359084da9 make: protobuf -- Fix deps generation on generated sources
There are a few nits in protobuf generation (which in most
cases are harmless but somethime may cause building procedure
to fail)

 - Deps files over generated sources should be produced only
   when _all_ .proto files are handled, because we include headers
   which are autogenerated as well, thus simply wait until everything
   is complete then use compiler to generate deps files

 - typo in non-clean targes, i rather should use proto-obj-y objects

Reported-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-15 11:32:52 +04:00
Tikhomirov Pavel
72dd148a44 zdtm: add --track-mem to final snapshot
otherwize it won't use/check parent snapshots, only last one
on restore.

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-14 18:37:55 +04:00