2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

263 Commits

Author SHA1 Message Date
Andrey Vagin
ce5aa74d10 mount: save local mount point paths on restore
On restore we add a temporary root to a mount point path. It's convinient
for restoring mount namespaces, but real paths are used for restoring
link-remap files.

v2: replace the offset field on a char * field

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:14:15 +04:00
Andrey Vagin
7db1e6b9b9 mount: don't set m->bind if m is already mounted
The m->bind will be used to get the "lowest" mount. A mount is
called "lowest" in the chain of bind-mounts when its m->bind is
NULL. I.e. -- it's the mount of the root dir of an FS, all the
others are bind-mounted from it.

The propagate_siblings() is called for each new mount and sets
the bind field for others. A part of these other mounts can be
already mounted.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:14:14 +04:00
Pavel Emelyanov
9fd793e565 stat: Pass namespace into phys_stat_resolve_dev, not mnt tree
This makes the API simpler.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 10:57:27 +04:00
Pavel Emelyanov
090587e1a1 stat: Pass namespace into phys_stat_dev_match, not mnt tree
This makes the API simpler.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 10:57:25 +04:00
Andrey Vagin
967dba606a mount: add helper mntns_get_root_by_mnt_id
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-05 16:38:19 +04:00
Andrey Vagin
e4e22a00f7 mount: save remapped links on tmpfs (v2)
For that mnt namespaces should be dumped after files.

v2: rework enumeration of namespaces in dump_mnt_namespaces()
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-05 16:35:41 +04:00
Andrey Vagin
8d446a7af4 mount: execute collect shared for all mounts
Currently collect_shared is executed for each mount namespace separately,
so we miss the dependencies between namespaces.

For example, we have two namespaces, the first one contains a tmpfs mount
and the second one contains a non-root bind-mount of this tmpfs. Without
this patch this example can't be dumped.

On restore mnt_build_tree() is called for all namespaces at once, thus
this bug doesn't exist there.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-05 16:35:17 +04:00
Tycho Andersen
51876eea5d Attempt to restore cgroups
During the dump phase, /proc/cgroups is parsed to find co-mounted cgroups.
Then, for each task /proc/self/cgroup is parsed for the cgroups that it is a
member of, and that cgroup is traversed to find any child cgroups which may
also need restoring. Any cgroups not currently mounted will be temporarily
mounted and traversed. All of this information is persisted along with the
original cg_sets, which indicate which cgroups a task is a member of.

On restore, an initial phase creates all the cgroups which were saved. Tasks
are then restored into these cgroups via cg_sets as usual.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-07-10 17:00:28 +04:00
Andrey Vagin
6f45c38c18 mount: parse devpts options
The newinstance options isn't shown in mountinfo. Currently it is
detected in devpts_dump. It is added only for root mounts and it
isn't added for bind-mounts. So mounts_equal(a, b, true) returns false
for such mounts and criu doesn't understand that they should be
bind-mounted.

Reported-by: Tycho Andersen <tycho.andersen@canonical.com>
Cc: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-25 19:51:01 +04:00
Andrey Vagin
44356b37f2 mount: simplify devpts_dump
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-25 19:50:59 +04:00
Andrey Vagin
494c044384 mount: dump one file system only once (v2)
A file system can be bind-mounted a few times and some of these mounts
can be non-root. We need to find one of root mounts and dump it.

v2: don't forget to check pm->dumped and pm->parent
    don't dump a root file system, it's always external for now.

Reported-by: Saied Kazemi <saied@google.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-17 10:40:00 +04:00
Andrey Vagin
697211908a tmpfs: use device number instead of mnt_id in image names
One file system can be mounted a few times, so mnt_id isn't unique for it.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-17 10:39:52 +04:00
Pavel Emelyanov
061d6cfadf mnt: Handle external bind mounts according to --ext-mount option (v3)
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-17 10:36:52 +04:00
Pavel Emelyanov
c7e0042946 crtools: Introduce the --ext-mount-map option (v3)
On dump one uses one or more --ext-mount-map option with A:B arguments.
A denotes a mountpoint (as seen from the target mount namespace) criu
dumps and B is the string that will be written into the image file
instead of the mountpoint's root.

On restore one uses the same --ext-mount-map option(s) with similar
A:B arguments, but this time criu treats A as string from the image's
root field (foobar in the example above) and B as the path in criu's
mount namespace the should be bind mounted into the mountpoint.

v3:
* Added documentation
* Added RPC bits
* Changed option name into --ext-mount-map
* Use colon as key and value separator

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-17 10:36:30 +04:00
Pavel Emelyanov
c3ea0ba06f mnt: Tossing bits around in validate_mounts
Just for simpler further patching.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-17 10:36:02 +04:00
Tycho Andersen
43c96be798 Allow dumping of pstore, securityfs, fusectl, debugfs
These are mounted by default in ubuntu containers, so criu should know about
them and remount them on restore.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-11 15:09:15 +04:00
Pavel Emelyanov
b9c6cf3dd3 mnt: Strip commas from options string
Not all filesystems like it. Other than this options in the
image just look cleaner.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-06-06 12:19:15 +04:00
Pavel Emelyanov
30e95be264 mnt: Fix validation of dumpable mountpoints
This patch consists of 3 unsplittable (from my POV) fixes.

1. Remove messy check from dump_one_mountpoint() -- we have
   validate_mounts to check whether we can dump the tree
   or not.

2. Other than being in the wron place the mentioned check
   is wrong. Comparing of the length of the mp->source-s
   makes no sense -- it should be mp->root, but even this
   would be wrong...

3. ... instead, we should check for bind mount root path
   being accessible from the target mount root path, i.e.
   the bind->root should start with src->root.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-06-04 19:34:54 +04:00
Pavel Emelyanov
3635f2c4b9 mnt: Relax checks for top-mount in validate_mounts
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-06-04 19:34:53 +04:00
Pavel Emelyanov
c75b7ab61c mnt: Devpts options get corrupted on dump (v2)
The memcpy() in devpts_dump() just overwrites part of them.
Fix this and move the whole code into sub-routine for future.

v2: Fix off-by-one error spotted by Filipe.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Filipe Brandenburger <filbranden@google.com>
2014-06-02 13:07:11 +04:00
Andrey Vagin
3a9c6a3d37 util: use glibc macros to generate device numbers in the dev_t format
Our version of macroses are worng.

Our macros:
#define MINOR(dev)           ((dev) & 0xff)

Glibc function:
return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);

Reported-by: Amey Deshpande <ameyd@google.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-05-07 21:02:35 +04:00
Pavel Emelyanov
d4e4e57744 mnt: Get ns temp root path once when collecting data from image
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-23 17:40:39 +04:00
Pavel Emelyanov
8d5822d9cb mnt: Factor out mntns nsid creation on restore
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-23 13:22:12 +04:00
Pavel Emelyanov
aca33ac402 mnt: Add comment why we need criu's mntns mounts for dump
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-23 13:10:21 +04:00
Pavel Emelyanov
8ef1d378bf mnt: Add comments on tricky places
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-23 02:47:42 +04:00
Pavel Emelyanov
3d11c6c0ed mnt: Sanitize prepare_mnt_ns nsids loop
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-23 02:35:04 +04:00
Pavel Emelyanov
68e2841a9b mnt: Turn mntns_get_root_fd into accepting mnt ns_id
The only exception (for now) is the irmap -- it should
operate on ns as well.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-23 02:31:16 +04:00
Pavel Emelyanov
d5e6a51bfe Revert "mnt: Merge two calls to collect_mntinfo on early restore"
This reverts commit f55a0b912c2bb105513b5f6e08a024958968ab9a.

The collected mounts list a) points to nsid and b) should be
put on nsid's mntinfo_tree. Thus is _should_ be done by separate
calls.
2014-04-23 01:49:34 +04:00
Pavel Emelyanov
1435617c40 mnt: Rename _collect_root into _get_root_fd
Nowadays this routine is mainly used for getting an
fd, rather than keeping one for future reference.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-23 01:38:58 +04:00
Andrey Vagin
20003300d8 mount: remove extra calls of mntns_collect_root()
Now mntns_collect_root() should be called each time when we need to get
a root of a specified namespace and we don't need to call it for
initializing the global variable.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:49:43 +04:00
Pavel Emelyanov
4ec63d53e1 rst: Don't lookup ns if current mntns is the same as root's one
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:48 +04:00
Pavel Emelyanov
79f3e90856 rst: Less arguments to restore_task_mnt_ns
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:46 +04:00
Pavel Emelyanov
8472345d0a rst: Don't forget to close nsfd after setns
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:44 +04:00
Pavel Emelyanov
f55a0b912c mnt: Merge two calls to collect_mntinfo on early restore
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:43 +04:00
Pavel Emelyanov
8550f52017 mnt: Move local mntns collecting on restore into prepare_mnt_ns
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:43 +04:00
Pavel Emelyanov
05c02ddcf9 mnt: Move nsmask checking into prepare_mnt_ns
Helper for simpler next patch.

Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:42 +04:00
Pavel Emelyanov
908915889d mnt: Sanitize collect mntinfo error path
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:41 +04:00
Pavel Emelyanov
f818065e48 mnt: Mark fini_mnt_ns as void arg
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:41 +04:00
Pavel Emelyanov
02f7c5c624 mnt: Helper for getting mntns root path
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:40 +04:00
Pavel Emelyanov
169dada873 mnt: Mark create_mnt_roots as void arg
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:39 +04:00
Pavel Emelyanov
f4b7a6fedd mnt: Mark rst_collect_local_mntns as void
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:38 +04:00
Pavel Emelyanov
b08af3a90d mnt: Merge mnt nss dumping and collecting code
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:36 +04:00
Pavel Emelyanov
33b7ec5034 mnt: Move collect and list of pms out of ns dumping routine
This is a helper for the next patch.

Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:35 +04:00
Pavel Emelyanov
88eef43e41 mnt: Mark dump_mnt_ns as static
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:33 +04:00
Pavel Emelyanov
f60109f272 mnt: Check for ns being mnt before dumping
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:26 +04:00
Pavel Emelyanov
d49fd40e55 mnt: Sanitize the code of reading mnt images routine
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:24 +04:00
Pavel Emelyanov
4ffa79695d mnt: Remove unneeded argument from prepare_mnt_ns
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:23 +04:00
Pavel Emelyanov
bc312d3229 mnt: Fix void argument for reading mnt images helper
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:22 +04:00
Pavel Emelyanov
dd43b3c529 mnt: Helper for adding new set of mountpoints into global list
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:21 +04:00
Pavel Emelyanov
1009985e30 collect: Check for ns being mnt before collecting
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-22 23:48:20 +04:00