Commit graph

1224 commits

Author SHA1 Message Date
Cyrill Gorcunov
ccdca9e3d1 dump: Add missing new lines
Otherwise output looks like

Dumping core (pid: 16953)
----------------------------------------
Dumping GP/FPU registers ... OK
Obtainting personality ... OK
Obtainting task auvx ... Dumping path for 1 fd via self 19 [/home/crtools/test/legacy/test-inotify]
Dumping header ... ----------------------------------------

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 15:22:06 +04:00
Pavel Emelyanov
f379e2ccf5 test: Add tar + bzip2 testsuite
Generate a pseudorandom tree of files, run tar cjf on it
to create referenced tarball, then run the same again on
the background, wait for a while, then checkpoint and restore
it and compare that two tarballs do not differ.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 15:20:15 +04:00
Cyrill Gorcunov
794d3fba40 zdtm: Extend file_own test for both pipe ends
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 14:32:02 +04:00
Cyrill Gorcunov
2d19a8750e pipes: Set fowners for both pipe ends
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 14:31:28 +04:00
Cyrill Gorcunov
6177c92bac pipes: Drop unused find_pipe(int id)
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 14:19:06 +04:00
Pavel Emelyanov
1a1a1861dd tests: Add new "real-life" test suit
The intention is to put here tests, that check how real apps
work. Initially I test that make -j4 works. This test is very
basic (uses sleep to wait for make to fork everybody) and a
syntetic .c file (quite big though).

Extend and use.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 13:33:24 +04:00
Cyrill Gorcunov
956d28bb65 zdtm: Extend file_own test for sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:31:58 +04:00
Cyrill Gorcunov
a8840ba721 fowners: Add checkpoint/restore for sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:31:33 +04:00
Cyrill Gorcunov
df6d5cfb23 zdtm: Add file_own test case
Tests for pipes fowners checkpoint/restore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:29:25 +04:00
Cyrill Gorcunov
318535db97 fowners: Restore for regular files and pipes
The base idea is trivial, once file descriptor
created the owner is read and set up.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:28:51 +04:00
Cyrill Gorcunov
44492851e1 fowners: Add regular files/pipes owners dumping
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:28:34 +04:00
Cyrill Gorcunov
ff3471f726 fowners: Prepare ground for dump and restore
Just show implemented and stubs added to image
(regular file and pipes).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:28:15 +04:00
Cyrill Gorcunov
d29f3bc02f types: Add F_GETOWNER_UIDS opcode
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:27:54 +04:00
Pavel Emelyanov
b53c42a50b zdtm: Test for pgids and sids
If I'm not mistaken this covers all the if-s in the
restore_pgid and restore_sid code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:13:43 +04:00
Pavel Emelyanov
814bd5d321 xids: Dump and restore tasks' pgid and sid
This is preriquisity for terminals handling and just a good
practice to save and restore everything we can :)

Not all combinations are supported. All the problems we still
have come from the inability to attach to group/session with
ID no tasks own as its PID.

This can be workarounded by fork()-ing this pid temporarily,
but we'd rather think in the direction of modifying the kernel
to give us direct syscall for this (oh my...)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:11:41 +04:00
Pavel Emelyanov
6f67bb8fc3 xids: Save pgid and sid on pstree_Item and pstree_entry
I store them on _entry since sids can only be inherited or
set to current's pid. Thus the best we can do it restore sids
at fork time, thus save them in the image we use to fork.

Maybe when we submit patches that will give us ability to set
arbitrary pgid and sid we'll change this, but this is in the
future.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:10:09 +04:00
Pavel Emelyanov
6ed9f87269 proc: Make small stat parsing read pgid and sid
They are just two next in this file, so extend. This is
required for pgid/sid early read, see next patches for
details.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:09:12 +04:00
Pavel Emelyanov
2a0c526b6d dump: Save pstree_item's parent on item, not ppid
This is trivial change, but is required to check for pgid/sid
are in 'restorable' state, see for respective patch/code for
details.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:07:47 +04:00
Pavel Emelyanov
b17c49aa99 rst: Wait till everyone completes forking on restore
New stage CR_STATE_FORKING. This is required to restore pgids
properly -- we need to make sure a task with pid whose pgid we
are about to enter is alive. And this task is not necesserily
our parent, thus wait for everyone to appear.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:06:36 +04:00
Pavel Emelyanov
b63451e58d log: Open log file with O_APPEND
Otherwise multiple writers can screw each-other's messages.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:06:00 +04:00
Pavel Emelyanov
1e6d32276a parasite: Cure task in case any dump failed while infected
Wile the task is infected we cannot just detach from it and go away. The victim will die after this.
So, call the parasite_cure_seized on any error handing between infect and cure.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 15:25:03 +04:00
Pavel Emelyanov
1e9ccd2bbd dump: Don't kill tasks after failed dump
This is not very good practice :) Just leave them in the state they've been to before
dumping. Plz note, that tasks segfault for some reason after unseizeing, but this is
another story.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 15:17:26 +04:00
Pavel Emelyanov
13ee53a098 sockets: Save and restore fd flags for sockets
For regfiles this is done at open() time, for pipes thit is done with fcntl. Use
the same fcntl approach for sockets.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 13:20:03 +04:00
Cyrill Gorcunov
827f1a2f0b files: Don't call for run_unix_connections if there error happened earlier
It doesn't make sense to try to connect sockets if error
happened previously.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:54:49 +04:00
Cyrill Gorcunov
611343a50c files: Print the state of files restoring transition
It's confusing to see the output like

 | Got fd for 3
 | Got fd for 3

Better to point what is going on

 | Got fd for 3 (state -> 0)
 | Got fd for 3 (state -> 1)

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:54:29 +04:00
Cyrill Gorcunov
a83ad7b813 files: Drop redundant lseek in prepare_fds
No need to obtain MAGIC_OFFSET from current position,
the files have predefined structure.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:54:12 +04:00
Pavel Emelyanov
b0aa868d47 zdtm: Add test for close-on-exec bits
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:38:03 +04:00
Pavel Emelyanov
05e3c4d2c9 fd: Handle close-on-exec bits
This bit is not per-file, but per-fd, thus put it on the fdinfo_entry.
Draing these bits from parasite together with the fds themselves, save
into image and restore with fcntl F_SETFD cmd where applicable.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:36:59 +04:00
Pavel Emelyanov
30224abcb6 util-net: Make send/recv fds carry fd flags in message
The flags are only one bit in the kernel (close-on-exec, all the rest are not per-fd, but per-file),
but for simplicity I save it in a char field.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:36:13 +04:00
Pavel Emelyanov
e8cdf57f40 syscall: Add fcntl syscall and F_GETFD cmd
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:35:54 +04:00
Pavel Emelyanov
f999b8cfb5 dump: Rename fd dumping functions
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:17:26 +04:00
Pavel Emelyanov
adca8809fd sockets: Pass fd_parms into sockets dumping fns
This is required for proper close-on-exec handling (coming soon) and for fowners (coming soon
as well) and for file flags (yes, yes).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:10:19 +04:00
Pavel Emelyanov
6af08c3326 fd: Sanitize fd_parms fd_name field
It used to be ulong, but it can be int now (no mapping addresses there). And the
name fd is better than fd_name (reason is the same).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 17:49:39 +04:00
Pavel Emelyanov
9a39482875 dump: Remove unused brk on-stack var from dump_task_core_all
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 15:43:13 +04:00
Pavel Emelyanov
38ea98aa8b dump: Toss code withing dump_task_core_all
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 15:41:16 +04:00
Pavel Emelyanov
a9930c7fdc dump: Move dump-personality logs into dumper fn
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 15:39:21 +04:00
Pavel Emelyanov
d71e5e44f1 dump: Factor out dump-regs logging
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 15:38:33 +04:00
Andrey Vagin
dcc37a09e0 log: don't fail if a log descriptor is reopened
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 23:50:33 +04:00
Andrey Vagin
c4458cb50d log: don't close STDERR
reopen_fd_as closes old descriptor.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 23:49:42 +04:00
Andrey Vagin
492da1c363 log: change a logging descriptor when it was initialized
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 23:48:28 +04:00
Pavel Emelyanov
8b80a1e30c files: Remove obsolete fmap_fd structure
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 19:09:50 +04:00
Pavel Emelyanov
1d6578bbd5 kcmp: Dump task's objects shared with CLONE_ flags
Just dump their IDs and check they are not shared. For future.
IO and SEMUNDO is not there since tasks may have NO such objects
and currently we cannot detect whether they have them equal or
both don't have.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 18:02:00 +04:00
Pavel Emelyanov
3386535491 kcmp: Introduce generic object ID generator
Just move the patched code from file-ids.c to kcmp-ids.c and
make the former one be client for the latter.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 18:01:18 +04:00
Pavel Emelyanov
51af25757d kcmp: Generalize tree showing code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 17:56:36 +04:00
Pavel Emelyanov
817b13fad2 kcmp: Make ID generation code return ID, not pointer on tree element
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 17:55:58 +04:00
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