Commit graph

5633 commits

Author SHA1 Message Date
Andrew Vagin
6d52d6ee21 zdtm: check a test result for static/different_creds
CRIU should not affect process states when it can't dump them.

Cc: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-05 13:13:21 +03:00
Andrew Vagin
16923109c6 ptrace: don't stop a process if it was not in the stopped state (v2)
v2: fix one more place

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Cc: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-05 13:12:48 +03:00
Andrew Vagin
a973e6fcb3 net: dump ipv6 routes
"ip route dump" dumps only ipv4 routes.

Reported-by: Ross Boucher <boucher@gmail.com>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-05 13:11:31 +03:00
Cyrill Gorcunov
3ffad59e2e piegen: Allow to compile piegen tool in cross environment
To build piegen tool with different compiler/linker than
gcc/ld -- simply run make as

	HOSTCC="host-compiler" HOSTLD="host-ld" make

where host-compiler/ld is appropriate program needed.

https://github.com/xemul/criu/issues/63

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-05 13:09:33 +03:00
Cyrill Gorcunov
a755ece2f0 piegen: Use shorthand for target
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-05 13:09:21 +03:00
Cyrill Gorcunov
0516001f91 restore: Report error if write into last pid failed
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-30 12:32:03 +03:00
Pavel Emelyanov
80b66ee15d mnt: Don't include fake root entry in every mnt tree
This entry is only required if we have it, i.e. -- at restore stage
in the tree we _built_. All other cases, in particular, local tree
collection on restore, do not need such.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@odin.com>
2015-09-30 12:31:32 +03:00
Pavel Emelyanov
e55236f586 ghost: Fix off-by-one when printing ghost path
The rfi->path doesn't contain the leading /, neither does the ghost->rpath,
so when attaching it to root don't forget to include one there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@odin.com>
2015-09-30 12:31:25 +03:00
Tycho Andersen
97cb181cbc irmap: don't leak irmap objects in --irmap-scan-path
v2: use struct irmap directly in irmap_path_opt

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 22:02:51 +03:00
Andrey Vagin
6c62aa8a35 page-server: wait when a socket will be closed only if it isn't external
External socket can be used for other purpose.

Reported-by: Adrian Reber <adrian@lisas.de>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Adrian Reber <adrian@lisas.de>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 22:02:18 +03:00
Andrew Vagin
baed9dd946 zdtm: check restoring of sockets in the TCP_CLOSE state
(00.004456) Error (sk-inet.c:188): Name resolved on unconnected socket
(00.004466) Error (cr-dump.c:1255): Dump files (pid: 7944) failed with -1
(00.004680) Error (cr-dump.c:1617): Dumping FAILED.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 22:01:36 +03:00
Pavel Emelyanov
ee6fbf7c2f inet: Check for supported protocol earlier
If we try to dump inet socket with unsupported proto we may fail
with strange error from get_unconn_sk(), since the socket will
not be found in hashes.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Reported-by: Julian Andres Klode <jak@jak-linux.org>
2015-09-28 22:01:13 +03:00
Pavel Emelyanov
efa7dcf7c2 ghost: Remove ghost files if restore fails
Issue #18. When restore fails ghost files remain there. And
to remove them we have to know their list, paths to original
files (to construct the ghost name) and the namespace ghost
lives in.

For the latter we keep the restore task namespace at hands
till the final stage and setns into it to kill ghosts.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 22:00:37 +03:00
Pavel Emelyanov
a7c9f3011d mnt: Read mount images early
Mappings from mount id to namespace will be required to
remove ghosts on restore failure.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 22:00:36 +03:00
Pavel Emelyanov
b0e23c3d4f files: Collect ghosts and regilfes early
Info about ghosts presence and paths will be needed to
remove the ghosts itself and thus are needed in criu.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 22:00:35 +03:00
Pavel Emelyanov
4f7c8af0cb remaps: Move code into helper and rename global list
This list is used to roll-back the link remap files on dump. I
plan to re-use it to roll-back ghost files on restore, so clean
the code a little bit towards this change.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 22:00:14 +03:00
Pavel Emelyanov
152222a6b7 remap: Sanitize ghost file path printing
First -- avoid two memory copies by printing ns root directly, and
second -- remove extra argument from create_ghost, the mnt_id value
we need there can be found on the ghost_file object.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 21:59:45 +03:00
Pavel Emelyanov
6cf77f6726 remap: Rename fields for easier grep
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 21:58:28 +03:00
Pavel Emelyanov
7ca6cc1eb2 mnt: Clean roots yard from criu process
So here it is. If root task dies on restore the roots yard
dir remains unrmdired :( Since we already know its name, we
can remove one from criu. By the time we get to this place
the sub mount namespace(s) are already dead and yard dir
is empty. But umounting should be done by tasks after
successfull restore, so keep depopulation there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 21:57:35 +03:00
Pavel Emelyanov
3e7c92ed02 mnt: Renames around roots yard
Same thing as in previous patch -- we have too many generic
clean_ and fini_ prefixes over the code. And we need more (see
next patch), so let's specify what exactly we clean or fini.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 21:57:21 +03:00
Pavel Emelyanov
a180a75c7a mnt: Uninline clean_mnt_ns
Just to get rid of clean_something name. We have too
many cleaners out there already :\

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 21:57:06 +03:00
Pavel Emelyanov
c5c65fe17a mnt: Create roots in criu context
In case root task restore failure we'll have to remove the
roots yard dir from criu, so we have to create one by
criu to at least have the dit name.

It's OK to do it in criu, since the yards is created in
the opts.root which is the same for any mnt ns we deal
with on restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 21:56:51 +03:00
Pavel Emelyanov
e3f5ba3c37 ns: Prepare namespaces before tasks
There's already two things we do in criu namespaces before
forking the init task (start unsd and keep netnsfd for back
reference). Next patches will introduce the 3rd action for
mount namespaces, so have a special pre-call for all this
stuff.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 21:56:26 +03:00
Pavel Emelyanov
9b3189fed1 util: Add make_yard helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 11:32:18 +03:00
Pavel Emelyanov
c5054f959d mnt: Factor out external check in validate_mounts
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 11:32:10 +03:00
Pavel Emelyanov
4e0276340a mnt: Rename collect_shared and remove unused for_dump argument
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-28 11:32:02 +03:00
Pavel Emelyanov
3dc209e216 sk: Print socket protocol when searching
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-25 18:31:22 +03:00
Andrew Vagin
cbf2c22d37 zdtm: show errors from dump logs
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-25 18:17:31 +03:00
Andrew Vagin
1a9f0b852b net: handle old or new images where a number of sysctls is differ
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-24 13:14:32 +03:00
Cyrill Gorcunov
e8e675bdd6 seize: Add missing newline
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-24 13:11:18 +03:00
Pavel Emelyanov
addd7f686a cgroup: Print cgroup values being restored
We have many complains about errors restoring cgroup props, so
print the exact values we restore _before_ doing this, not only
after successful restore :)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-24 13:11:11 +03:00
Andrew Vagin
bb45f832bf A superblock can be remounted only from the root userns.
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-23 18:02:33 +03:00
Andrew Vagin
7ae72c651f lib: don't use uninitialized value "m"
*** CID 150397:  Memory - illegal accesses  (UNINIT)
/lib/criu.c: 696 in criu_local_add_irmap_path()
690
691             return 0;
692
693     err:
694             if (my_path)
695                     free(my_path);
>>> >>>     CID 150397:  Memory - illegal accesses  (UNINIT)
>>> >>>     Using uninitialized value "m".
696             if (m)
697                     free(m);
698
699             return -ENOMEM;
700     }
701

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-23 15:40:22 +03:00
Andrew Vagin
aab2d1e8fa zdtm: check read-only tempfs mount
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-23 15:34:39 +03:00
Andrew Vagin
84cc1e12ac mount: don't merge mnt and sb flags if only one contains MS_RDONLY
Reported-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Tested-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-23 15:34:38 +03:00
Pavel Emelyanov
9353051ba7 ns: Check ns type with type field
Actually make use of the ns->type field and remove all getpid()'s
and other strange/inconsistent checks.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 12:15:28 +03:00
Pavel Emelyanov
22b7256612 ns: Introduce ns type
We (may) have 3 types of namespace objects in criu -- criu's one,
root task's one and others. All of them sometimes make sense and
we differentiate them in a weird way -- by checking the ns->pid
field against getpid() or by comparing with root_item's.

The proposal is to mark ns_id objects explicitly with type field.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 12:14:07 +03:00
Pavel Emelyanov
1c34b284f3 mnt: Move read_mntns_img into populate routine
We don't need the read tree earlier.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 12:13:48 +03:00
Pavel Emelyanov
2847089378 mnt: Reshuffle MntEntries reading code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 12:13:25 +03:00
Pavel Emelyanov
c1a25fc1bd mnt: Add mi->root resolving helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 12:13:21 +03:00
Pavel Emelyanov
259374f6b1 mnt: Add mi->mountpoint resolving helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 12:13:09 +03:00
Pavel Emelyanov
d7696a42b3 files: Enlighten the rollback link-remap routine
When we don't do unlink no need to lookup for ns root-fd

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 12:12:41 +03:00
Tycho Andersen
85ebf0a83b usernsd: also pass pid of process that made the req
We'll use this in the next patch to correctly write sysctls.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 12:01:01 +03:00
Tycho Andersen
72ff44d0dc usernsd: move MAX_MSG_SIZE to namespaces.h
We'll use this size in the next patch to avoid having to do some dynamic
allocation.

v2: call it MAX_UNSFD_MSG_SIZE instead
v3: fix all uses of MAX_MSG_SIZE :)

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 11:57:40 +03:00
Andrew Vagin
459fb8b7da zdtm: don't run file_locks* tests simultaneously
/proc/locks can contains the same locks twice, if someone
releases a lock when we are reading this file.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 11:56:38 +03:00
Andrey Vagin
0ee52669ac zdtm: check read-only bind mounts
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 11:55:40 +03:00
Andrey Vagin
5cff834ae7 mount: handle old images where sb and mnt options were not separated (v3)
Currently we have only one common flag. It is MS_READONLY and it's
interpreted as a super block flag to not change old behaviour.

v2: add a comment
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 11:55:36 +03:00
Andrey Vagin
1174a2ad0f mount: handle mnt_flags and sb_flags separatly (v4)
They both can container the MS_READONLY flag. And in one case it will be
read-only bind-mount and in another case it will be read-only
super-block.

v2: set mnt and sb for one call of mount() when it's posiable
v3: return a comment which was deleted by mistake
v4: Fix the sentense about restoring mnt flags
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 11:55:17 +03:00
Andrey Vagin
b7d393ff63 proc_parse: search the uid/gid options only for sb opts
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 11:53:24 +03:00
Pavel Emelyanov
e9bb16265b img: Add text for known flags
Currently there are open flags on reg-files and vma
flags and prot.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-21 11:52:14 +03:00