Commit graph

1014 commits

Author SHA1 Message Date
Pavel Emelyanov
e8bc5ebbbf zdtm: Added maps01 to zdtm script
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 11:33:58 +04:00
Pavel Emelyanov
f212e6fe37 dump: Reformat vma dumping a little
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 11:33:54 +04:00
Andrey Vagin
c3051512f3 crtools: delete CORE_OUT
It's a rudiment from old times, when restore worked via ececve.
Now we modify the core file in place to fixup vma-s.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 11:06:10 +04:00
Andrey Vagin
650be3d2be mm: clean up parasite (v2)
Now it has only one descritor for dumping pages

v2: remove rudiments

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 11:04:17 +04:00
Andrey Vagin
e869c16df5 mm: rework of dumping shared memory
vma_entry contains shmid and all shared memory are dumped in own files.
The most interesting thing is restore.
A maping is restored by process with the smallest pid. The mamping
is created before executing restorer.
We map a full mapping and restore it's conten, then we open a file from
/proc/pid/map_files and store a descriptor in vma_info. The mapping is
unmaped. Now we can map any region of this mapping in the restorer.

We use this trick, because a target process may have this mapping in
some places and the restorer has not function to open proc files.

v2: fix error hangling
xemul: Fixed static-s and args for cr_dump_shmem

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 11:03:55 +04:00
Andrey Vagin
31feef8ab4 mm: s/PAGES_SHMEM/SHMEM_PAGES
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 10:57:23 +04:00
Andrey Vagin
5dda50468b mm: change offset of zero_page_entry to ~0LL
Because 0 is actually a valid value.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 10:57:14 +04:00
Andrey Vagin
37a6c1fc88 mm: move shmid to vma_entry (v2)
It will be used to restore shared mappings

v2: clean up

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 10:56:31 +04:00
Andrey Vagin
7d10875076 zdtm: add new test case for testing shared memory
* map a big memory region
* fork
* unmap the first and tenth pages
* remap one page in another place
* touch a few pages
* check content of touched pages

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 10:55:46 +04:00
Andrey Vagin
5ca347889e crtools: support any format of image path (v3)
Now a name of an image file is hard coded ("smth-%d.img", pid),
but the images of namespaces, shared memery, etc belong to
not one task, so they may have other formats of names, which
will describe objects.

For example a image of shared memory content may have name like
this ("pages-shmem-%ld.img", shmid)

v2: fix comment
v3: rebase

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-19 15:45:12 +04:00
Cyrill Gorcunov
d463b15bc6 restorer: Switch restoring of /proc/pid/exe symlink to new kernel interface
This patch makes crtools to work with new /proc/pid/exe symlink
restoration (the kernel part was reviewed by Oleg).

So this patch is for new shiny kernel only (!), thus I suggest
all developers to move on kernel crtools-3.3 (which can be
found at usual place) and pick up this patch for crtools itself.

(again, with this patch anything but crtools-3.3 will not work)

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-19 15:42:01 +04:00
Cyrill Gorcunov
4b1f8d0840 parasite: Refactor code to follow calling convention
It happened some routines in parasite service code
were not following calling convention so I fixed the
callers and added a comment about adding new code here.

At the same time the 3 error code madness is dropped
as being requested by Pavel -- now we return one error
code only.

The PARASITE_ERR_ codes were dropped as well due to
become redundant.

The status of parasite service routine is set via
SET_PARASITE_RET helper. In case if there is no error --
just return 0. The calling code should not expect to
find anything sane in parasite_status_t because parasite
code might not touch it at all.

Same time, due to this convention the parasite's
dump_socket_queue is getting rid of third @err
member, because it's now returned as a regular
error code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-19 13:53:14 +04:00
Andrey Vagin
94735bbd85 show: expand the field for vma size
Before this patch it may contain only a few megabytes.
I think a real application may have a bigger mappings.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-19 10:34:49 +04:00
Andrey Vagin
0ce623f9f7 crtools: use mremap for remaping shared memory
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-19 10:33:47 +04:00
Pavel Emelyanov
caf860c2ef proc parse: Small sanitation of maps parsing
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-17 01:22:18 +04:00
Pavel Emelyanov
2b9fd6ce17 dump: Formatting of regs dump fixup
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-17 01:02:55 +04:00
Cyrill Gorcunov
9bb93f7e18 net: Fix typo in recv_fd
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-16 20:46:49 +04:00
Pavel Emelyanov
ffacd0f17c image: Open images via openat
Using absolute paths for this is dangerous - while doing c/r we should
be extremely carefully and not change tasks' roots and mount namespaces
too early. Sometimes it will not work -- when restoring containers we'll
be unable to switch to new CT and still have the ability to open images.

Rework the images opening via openat and keep the image dir fd open all
the time as the service fd (introduced earlier).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-16 20:45:50 +04:00
Pavel Emelyanov
3dd8f2e659 fds: Introduce service fd-s
These are the fds that help us to do c/r. We want them not to intersect
with any "real-life" ones and thus store them close the the file rlimit
boundary. For now only the logfd one is such.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-16 20:45:42 +04:00
Cyrill Gorcunov
177fbd88d0 parasite: Drop builtin_strlen, it's unused
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-16 20:00:51 +04:00
Cyrill Gorcunov
c19c447729 parasite: No need to compute heap size, it's immutable
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-16 19:58:34 +04:00
Stanislav Kinsbursky
8b7497a5ef dump: dump pstree outside tasks loop
No need in checking the pid in every task loop cycle, just dump it
at the beginning and that's it.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-16 15:40:40 +04:00
Andrey Vagin
adce8197c4 crtools: don't redeclarate the variable
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-16 15:26:23 +04:00
Cyrill Gorcunov
c6d1ff903e parasite: Add missing BUILD_BUG_ONs for arguments
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-15 23:42:43 +04:00
Cyrill Gorcunov
59890c3b28 parasite: Drop unneeded PARASITE_CMD_PINGME command
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-15 20:30:43 +04:00
Cyrill Gorcunov
7766e7f4f4 parasite: Drop unused struct mem_array
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-15 20:29:35 +04:00
Cyrill Gorcunov
5fc142d9c5 parasite: Drop unneeded heap_size variable
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-15 20:27:01 +04:00
Cyrill Gorcunov
45b76a9a9a dump: Don't shadow the ret code with dump_namespaces
cr_dump_tasks does assign ret = -1 by default but
dump_namespaces does shadow this variable with own
error code so that if any subsequent calls will fail
we will not notice the error.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-15 20:19:46 +04:00
Cyrill Gorcunov
ea1ec9f619 restore: Don't close pstree_fd several times
There is a scenario when pstree_fd may be tried
to close several times -- if we start crtools
with "detach" option.

So simply make restore_root_task to close opened
file descriptor, this also simplifies the code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-07 18:31:20 +04:00
Cyrill Gorcunov
644e4fec6b restore: Don't close LAST_PID_PATH descriptor if it was not opened
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-06 17:02:57 +04:00
Kinsbursky Stanislav
fe1cf26085 dump: add const qualifiers where possible
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-06 17:00:42 +04:00
Kinsbursky Stanislav
c1999ec58e dump: use fd_params->type for cwd and exe magic
This is a cleanup patch. Use file entry type variable for special files
instead of file entry addr variable.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-06 16:59:28 +04:00
Cyrill Gorcunov
fede33e047 log: Simplify log_init
- drop redundant current_logfd assignment
 - assign new_logfd at the beginning

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-05 19:27:29 +04:00
Pavel Emelyanov
a544b6842c sockinfo call indentation fix
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-04 17:07:00 +04:00
Pavel Emelyanov
7b7f09e4f0 sanitize vma types parsing
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-04 17:06:36 +04:00
Pavel Emelyanov
446b6526be optimize thread-less restore a bit
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-04 17:03:19 +04:00
Cyrill Gorcunov
351537c4f4 cr-restore: Fix typo in restorer_get_vma_hint
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 23:21:51 +04:00
Pavel Emelyanov
85f18ef02f restorer: Pass self-vmas via memory, not temp file
Reserve more mem for bootrstrap code and put all self vmas at its tail.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 21:31:35 +04:00
Pavel Emelyanov
471d3c429c restore: Cleanup mem variables usage
Just prepare the code for smoother further bootstrap areas allocation.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 21:31:35 +04:00
Pavel Emelyanov
fc225709b0 proc: Make parse_maps return the amount of them found
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 21:31:35 +04:00
Pavel Emelyanov
e94c85fe6e restorer: Fix bootstrap allocation
There are three bugs in this code.

1. self vmas list is released before get-hint is called
2. get-hint code wrongly detects the hole (just bugs, no details)
3. exec hint is mapped without MAP_FIXED, but should

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 21:31:35 +04:00
Pavel Emelyanov
b107d838cf zdtm: Remove socket_loop00 test
It's broken. Stas will fix it soon.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:43 +04:00
Pavel Emelyanov
1c12a31893 udp: Restore UDP sockets
Reuse the TCP socket restore, just add connect() and sanity checks
for protocol.

This is OK, since UDP connect doesn't go to network for connection
and (unlike unix sockets) doesn't require peer to be "online". It
just puts the peer's creds on socket and returns.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
bad126e7a5 sock: Add dst creds to socket structs
These are required for inet sockets, but were not added since listen
sockets do not have them.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
ba562bc272 show: Fix inet sockets show "loglevel"
Showers should use pr_msg to avoid loglevel issues.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
b198d76e40 udp: Allow dumping udp sockets
Just a small fixlet in can_dump_inet_sk.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
625c45ea79 udp: Collect socket with diag
Partially reuse the existing TCP code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
1ff1a46a6e zdtm: Test for udp sockets
Create two of them, bind both and connect one end to the other.
Then check that send and sendto work and recv(from) receive proper
message from proper address.

Queues are expected to be dropped while test according to protocol
constraints, thus all sends happen after restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
1bf89633ff zdtm: Raize loglevel to maximum
Otherwise logs look poor on failures.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
ba64f87bfa log: Fix logfd screwup
Broken by 7aa8e4b6 -- log was not moved to higher fd values.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00