Commit graph

1045 commits

Author SHA1 Message Date
Pavel Emelyanov
159d3bdfd5 fdinfo: Sanitize types in fdinfo_entry
The namelen is u16, to cover the PATH_MAX u8 is not enough.
The pos is u64, since file offset is that long indeed.
The id is u32 as per previous patch.

Fix printf-s respectively.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-25 21:00:35 +04:00
Pavel Emelyanov
af57e42e03 files: Sanitize fd logging
Don't print namelen (it's useless) and type (the code being patched
works with FDINFO_REG only).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-25 20:59:11 +04:00
Pavel Emelyanov
c92c9e234e file-ids: Enlighten ID generation and storage
The unique id is 32 bit and consists only of the subid value. This
is _really_ enough. The genid part is just a hint for the tree-search
algirythm to avoid unneeded sys_kcmp calls.

Plus, generate IDs for special files. This will make it easier to
move the regfiles into into separate files (see the respective patch
for details).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-25 20:58:19 +04:00
Pavel Emelyanov
5b44cbd890 restore: Restore cwd with fchdir
Use the open_fe_fd everywhere to obtain an fd from image.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 19:56:13 +04:00
Pavel Emelyanov
fb6f22749e dump: Remove 2nd mappings free call
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 17:07:53 +04:00
Pavel Emelyanov
308f6150c2 file-ids: Fix collect genid type
It is u32 and that is it :\

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 17:00:06 +04:00
Pavel Emelyanov
ed67491c45 file-ids: Show collected subtree at the end of dump
Just for debugging. Useful to know how the tree was built

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 16:52:09 +04:00
Pavel Emelyanov
ab1c83b9a5 file-ids: Fix subnode linkage
The subtree node should be linked with common rbtree procedure. Otherwise
the very first subtree insertion results in an infinite loop in the rb
linking and balancing code.

Plus, mark the root as static and add the subroot node initialization check.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 16:51:00 +04:00
Pavel Emelyanov
9e47a06cef zdtm: Extend file_shared test
Check for files with equal paths are handled"

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 16:05:13 +04:00
Pavel Emelyanov
57c4e73625 show: Dont't print path len
It's actually useless for user, this field is for crtools only to
find out when one fdinfo entry ends and the new one starts.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 15:41:39 +04:00
Pavel Emelyanov
18cf145cc5 show: Print fdinfo types as names, not numbers
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 15:38:18 +04:00
Pavel Emelyanov
7a451ff108 rst: Open exe link fd early
Open the exec link at fd restore stage as yet another service fd,
then pass it to restover via args and just call prctl on it.

This is good for several reasons -- the amount of code required for
this is less and opening files should better happen before we switch
to restorer (opening will be complex and it's MUCH easier to open all
we need in one place).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 15:30:20 +04:00
Pavel Emelyanov
e079bf1e36 restorer: Fix ret usage in prctl macro
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 15:28:36 +04:00
Pavel Emelyanov
65ebd845e5 check: Fix peek_off getting
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 15:28:10 +04:00
Stanislav Kinsbursky
12c5801749 dump: files tree - return id upon collect instead on inner structure
Hide the structure - it's not required.

[ xemul: Ranem long id into u32 id and adopt to current tree ]

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 00:40:52 +04:00
Stanislav Kinsbursky
b68b3d5dd5 dump: convert fd types into enum
This is a precursor patch. Macro for max possible fd type will be required.
And it's easier to use enum in this case.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 00:31:58 +04:00
Pavel Emelyanov
7a98cd2bf4 files: Sanitize fd restore state machine again
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-23 12:19:35 +04:00
Pavel Emelyanov
ebc1ac8bc5 files: Factor out transport name generation
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-23 12:19:24 +04:00
Pavel Emelyanov
a3ed9db82a show: Fix timers names
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 21:17:57 +04:00
Pavel Emelyanov
488790b677 util: Remove dead code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 21:17:44 +04:00
Pavel Emelyanov
d5f83530bd rst: Cleanup pstree walkthrough
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 21:06:41 +04:00
Pavel Emelyanov
5f788993a5 dump: Remove dead find_vma_by_addr
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 21:01:02 +04:00
Pavel Emelyanov
1b5c403241 dump: Sanitize pstree dumping
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 20:51:47 +04:00
Stanislav Kinsbursky
3e8e358d82 dump: merge collect and dump stage for processes tree
This is a cleanup patch. This tree is merged only once. So it's image file can
be opened by opne_image() call and dumped right after collect stage.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 20:24:08 +04:00
Pavel Emelyanov
3ad95b3706 shm: Fix one task shmem remaps restore
Since the collect_shmems updates start address for vmas, for
two shared mappings in one task we'll try to dup() the 1st
restoration attempt, since the si's start will be set to the
2nd one, which is not yet restored.

Thus we should map-and-open the first one being restored, not
the one with matched address and dup() all the rest.

[avagin@: There's no such thing, since the collect stage checks
for pid being less _or_ _equal_ and this only the first vma's start
will be saved. But anyway, this makes it more obvious.]

Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 14:01:49 +04:00
Pavel Emelyanov
8e47df998c shm: Sanitize ret val checks in shmem_wait_and_open
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 14:00:53 +04:00
Pavel Emelyanov
6faac3a39e rst: Factor out vma fd fixup
Just make the fixup_vma_fds read and write vma images and
those called by it provide and fd for this.

Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 14:00:27 +04:00
Pavel Emelyanov
29e07fa24f rst: Remove extra calls when fixing up maps fds
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 14:00:09 +04:00
Pavel Emelyanov
8639776154 shm: Use read_img in fixup_vma_fds
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 13:59:45 +04:00
Pavel Emelyanov
97a1d8bb1c mm: Dump vmas into separate image file
The core image now contains only core per-task stuff.
The new file resurrects Tula magic number removed earlier.

Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 18:17:12 +04:00
Cyrill Gorcunov
309b2c1877 parasite: Rename gen_parasite_saddr @pid to @key
This routine will be used more widely and we will
be generating sockets with name based on some predefined
unique value rather than 'pid', so name argument this
way.

No change on functional level.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 14:40:25 +04:00
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