Commit graph

1179 commits

Author SHA1 Message Date
Pavel Emelyanov
46aeebdb07 kcmp: Make ID generation tree work on abstract elements, not fd-entries
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 17:55:20 +04:00
Pavel Emelyanov
fe670c5a59 kcmp: Make IDs tree work on abstract kid_tree, not fd_id_ rb and Co
2nd step in making kid tree generic.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 17:54:35 +04:00
Pavel Emelyanov
14b04465a0 file-ids: Rename fd_id_ to kid_
kid_ stands for kernel id and this is preparation for making the fd_id_
tree generic enough to support any type of kcmp- calls.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 17:44:59 +04:00
Pavel Emelyanov
43367e2545 fdinfo: Rename fdinfo_entry addr to fd
Now we store only real fdtable entries in this file, so it's
time to name the field properly and change type to u32.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 16:18:33 +04:00
Pavel Emelyanov
14e5cdcb04 files: Remove dead desc opening code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 15:59:27 +04:00
Pavel Emelyanov
f560ddea55 files: Use open_reg_by_id helper where appropriate
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 15:57:05 +04:00
Pavel Emelyanov
447f369ba9 fd: Remove fs_is_special
It's no longer required. All the previously special fds are
now scattered over other images.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 15:54:28 +04:00
Pavel Emelyanov
b984eeff9c mm: Move exe file id on mm_entry
This is mm_struct entity, so save one there. Also gets rid
of special FDINFO-s.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 15:52:00 +04:00
Pavel Emelyanov
fe70efad29 mm: Split mm parts from task core image
The mm_xxx bits are per-mm_struct, not per-task_struct in kernel.
Thus, when we support CLONE_VM we'd better have these bits in a
separate image file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 14:51:37 +04:00
Pavel Emelyanov
de66a5d04b fs: Reserve place for task's root dumping
Do not restore it yet -- the logic we're about to apply to
resolve tasks' paths relative to dumper/restorer is not yet
clear to me and it should better be hidden into a couple of
calls (dump_one_reg_file/open_fe_fd). But since we can't
chroot to fd we're about to expose the logic outside of the
open_fe_fd, which is not desirable ATM.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 13:52:42 +04:00
Pavel Emelyanov
e5e57e832b fs: Move info about cwd into separate file
Why? Because one day we'll support various CLONE_ flags and
for fdtable and fs info we'd like to have separate images (since
these objects are separate in kernel).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 13:41:05 +04:00
Pavel Emelyanov
69b3ebd002 vma: Remove FDINFO_MAP fd type
The regfile's ID of a VMA is stored in its shmid field. And the
file itself if sumped into regfiles.img image with 'special'-ly
generated ID (i.e. -- just allocate a new unique one).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 12:57:38 +04:00
Andrey Vagin
363812c9b9 restore: optimize restorer_get_vma_hint
It's an O(n) algorithm.

Now we iterate both lists simultaneously to find a hole.

[xemul: Discussion making the patch more understandable:

Cyrill:

	If s_vma is the last one on self_vma_list you could break immediately, no?

	And the snippet I somehow miss is -- how the situation handled when

		      hole
		    a      b
	source |----|      |-----|
	target   |----|      |-----|
		      c      d

	the hole fits the requested size but the hole is shifted
	in target, so that you've

	prev_vma_end = a

	and then you find that a - d > vma_len and return a
	as start address for new mapping while finally it
	might intersect with address c.

	Or I miss something obvious?

Andrey:

	Look at "continue" one more time.
	prev_vma_end is returned only if both condition are true

	if (prev_vma_end + vma_len > s_vma->vma.start) {
	....
	if (prev_vma_end + vma_len > t_vma->vma.start) {
	...

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 10:31:00 +04:00
Andrey Vagin
2d4244d033 show: use read_img to read pid-s of children and threads
Because amount of entries are known.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 10:28:18 +04:00
Andrey Vagin
32b5aa76e0 dump: return a negative value in case of error
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 10:28:01 +04:00
Andrey Vagin
fa11d76cab restore: check that a restorer vma doesn't intersect with target vma-s
[ xemul: The fix effectively is -- stop scanning the 2nd vma list
         once we see, that the hint's end hits the next vma ]

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 10:27:44 +04:00
Pavel Emelyanov
7d3a89970e dump: Check for regfile path being accessible
A file pointed by an fd should be not unlinked
and be open-able with the provided path (overmounts
and/or renames coupled with links can screw it up).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-07 00:32:03 +04:00
Cyrill Gorcunov
1f9999a81a make: Fix dependency generation
In case if no goals specified the all
goal is implied so don't forget to generate
deps. This as well fixes a problem where
two "make clean" in a row forced build system
to regenerate deps.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Looks-good-to: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 21:46:49 +04:00
Pavel Emelyanov
28a1474779 usk: The INFLIGHT flag is no longer used
It was required before we switched to socketpair restore
scheme. Now it's not required, sockets just connect to
the peer they want to.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 21:43:19 +04:00
Pavel Emelyanov
705bf5aba6 img: Hide image dir fd into util.c
No image copy occurs since 2b175282, so this
fd can be hidden. Thus fixind the FIXME near it :)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 21:39:10 +04:00
Kir Kolyshkin
f66913baa1 pipes.c: fix English in a comment
"Has not" + noun is obsoleted and very rare English. Fix it.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 21:30:09 +04:00
Kir Kolyshkin
866f829273 pipes.c: fix a typo in a comment
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 21:29:52 +04:00
Andrey Vagin
fff99f56b0 cr-dump: fix double free
rasite_cure_seized frees parasite_ctl

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 21:29:02 +04:00
Pavel Emelyanov
48e5023c2a pipes: Remove unused args from stack
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 21:22:28 +04:00
Pavel Emelyanov
76c2818b95 files: Factor sending fd to peer via temp unix sk
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 21:20:28 +04:00
Pavel Emelyanov
b16293414b files: Generalize file open, get rid of explicit types switch
Introduce and use generic file_desc ops for this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 20:39:48 +04:00
Pavel Emelyanov
3c174a885d files: Generalize fd restore, make file_desc common hash
No need in per-type hash tables and search routines. We can
handle it via generic file_desc structure. Some more thoughts
on unixsk and pipe lists are still required :(

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 20:30:48 +04:00
Pavel Emelyanov
527b67b91f files: Generalize fd restore, introduce file_desc
The struct replaces bare list_head on all of the _info-s we've
introduced recently.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 20:08:48 +04:00
Pavel Emelyanov
c406b0633f pipes: Use file_master instead of list_first_entry
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 19:36:10 +04:00
Pavel Emelyanov
f89170eaae sockets: Remove unused listen hash
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 19:32:41 +04:00
Pavel Emelyanov
b386751697 sockets: Rework unix sockets onto fdinfo scheme
This is a big change, yes. Dump unix sockets in the same manner
as all the other files are done now. A few notes however.

1. We explicitly drop names for connected stream sockets. This is
   done to avoid conflicts with names -- accepted sockets share their
   names with the listening parent. This can be done later by binding
   a socket to a name, them renaming it to some temporary uniq one
   and at the very very end renaming some back to original.

2. Interconnected sockets are restored via socketpair() call. This is
   correct, but names are dropped. Need to bind() sockets after this
   (yes, this can be done), but for this we need to implement the trick
   with renames described before.

3. FD for socket queues is constantly re-opened not to resolve fd
   conflicts. Need to use service fds engine for this later.

4. Some code cleanup is still required, yes (will follow shortly).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 19:27:08 +04:00
Cyrill Gorcunov
87d2ff5ee7 check: We need CAP_SYS_RESOURCE granted to perform testing
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:32:40 +04:00
Pavel Emelyanov
699caabdb9 show: Add pipes string to fdinfo output
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:31:13 +04:00
Andrey Vagin
ed456a1b36 pipe: restore pipe data
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:24:02 +04:00
Andrey Vagin
96be8be2d1 pipe: save all pipe data in a separate file
A pipe buffer has 16 slots. A slot is page, offset and size.
When we use splice and data is not aligned, splice connects
a page from file cache and set offset. For this reason we loose
a part of buffer.

If a data size is more than 15 pages, data will be aligned in a image.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:23:57 +04:00
Andrey Vagin
7b10ef0761 pipes: add functions to restore pipes
[xemul: This check in open_transport_fd should go away once we
        implement opening files with peers. ]

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:23:48 +04:00
Andrey Vagin
373a93248f files: some types of objects want to open transport for masters
For example it's pipe.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:22:42 +04:00
Andrey Vagin
4f2bd37704 pipes: add functions for collecting pipes
pipe_entry is encapsulated in pipe_info.
All pipe_info-s connects in the list pipes.
All pipe_info-s with the same piep_id connects to pipe_list,
it a circular list without a defined head.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:22:16 +04:00
Andrey Vagin
216233d104 files: add some function in files.h
They will be used to restore pipes

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:18:02 +04:00
Andrey Vagin
f9ead29776 pipe: add a separate file for pipe's stuff
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:17:31 +04:00
Andrey Vagin
bdb3932be5 pipe: all pipes are saved in one file (v2)
Information about pipe's file structs saved in one global file and
fdinfo_entry is saved for each descriptor

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:17:24 +04:00
Andrey Vagin
382ebc3063 pipe: remove old code for restoring pipes
[ xemul: I don't know how to make this with incremental changes either,
         and just go with it :( ]

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:17:11 +04:00
Andrey Vagin
a22ecfddf3 zdtm: add a new test case to check that all data can be restored
* create pipe
* write a maximum amount of data
* suspend/resume
* check that all data have been restored

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 20:53:27 +04:00
Andrey Vagin
2fef5cacb5 zdtm: write some data in pipe and read it after suspend/resume
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 20:53:12 +04:00
Pavel Emelyanov
6e562b0c9c files: Remove unused fn
It was used in old code, now it can be dropped

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 20:43:40 +04:00
Pavel Emelyanov
637a95f8d0 sockets: Check for unix being properly interconnected on dump
Add two checks -- that peer exists and it we will be able to
connect to him somehow on restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 18:12:51 +04:00
Pavel Emelyanov
86489a545d sockets: Drop socket name for any bound-to-unlinked case
This maybe not 100% correct in the generic case, but the way unix sockets are
used lets us do this trick.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 17:39:33 +04:00
Pavel Emelyanov
8717463a15 zdtm: Add unix connected streams test
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 17:18:11 +04:00
Pavel Emelyanov
12316c4994 files: Ease the fd collecting
No need in separate per-type fn for doing this. We can just
find the respective fd list and do sorting in the generic code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 16:54:10 +04:00
Cyrill Gorcunov
9e3befe046 check: Add test for /proc/pid/stat extension
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 16:39:35 +04:00