Even u64 address might consume not greater
than 20 bytes of string so 128 is enough and
safe here.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
If a process continue to run, it may change a state of filesystem.
@gorcunov:
- Drop -k option, it's not needed anymore.
- Allow -c option (continue execution of a
process after being dumped) in dumping procedure.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
If you execute this script without arguments, it will execute
all test cases, which should pass.
Or the first argument may be a path to the test case.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Since we use pure syscalls there is no
need to keep intermediate layer for signals.
Moreover mask entry moved at the end of the structure
so we will easily expand it if it'll be ever needed.
Note it breaks backward compatibility with older image
but since it's development stage it should be safe.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Probably all of you know about "lock inversion". There was a similar
problem on restoring pipes.
One process try to restore pipe1 and waits when another process attached
to it. In this time another process restores pipe2 and waits too.
I know two solves.
1. Open all pipes -> attach to them -> close unnecessary ends.
This method has a problem, if only one end belongs to the process. In
this cases another end occupies a descriptor, which may be needed to
another pipe.
2. Restore pipes in the same order. This patch does that.
A sorted list of pipe entries are constructed.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelianov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This patch removed stange logic about minusers.
Now we calculate foreign users only.
The main idea of this patch, that we bind a pipe ends to correct
descriptos immediately.
When a process X creates a pipe, we have two cases:
1. Both ends belongs to this process. It's simple, we bind both ends
to their descriptors and we go further.
2. Only one end of a pipe belongs to this process. In this case we are
waiting all foreign users and we go futher.
In second case we should wait, because a end which doesn't belong to
this process occupies a file descriptor, which may be used by another
pipe.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelianov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CWD is saved as file descriptor with number -1.
v2: use dump_regular_file
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Now I try to restore CWD and a relative path will be invalid.
Add new options -D to set image files directory.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Probably all of you know about "lock inversion". We have a similar
problem on restoring pipes.
This test case creates two process and two pipes.
process 1:
11: pipe1 (w)
12: pipe2 (r)
process 2:
11: pipe2 (r)
12: pipe1 (w)
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
There is no such file at all and it forced build
process to re-build every make command passed.
Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Added
- ability to parse every single file crtools
understands via magic number
- dumped memory pages can be rendered in two
modes -- as a simple set of pages' virtual addresses
or in hexdummp fashion (via -c command line key).
For example
./crtools -s -c -f pages-2557.img
CR_FD_PAGES: pages-2557.img
----------------------------------------
7fffb44ace20: 00 00 00 00 00 00 00 00 00 00 00 74 65 73 74 2f |. . . . . . . . . . . t e s t / |
7fffb44ace30: 74 65 73 74 2d 73 69 67 61 63 74 69 6f 6e 00 48 |t e s t - s i g a c t i o n . H |
7fffb44ace40: 4f 53 54 4e 41 4d 45 3d 6c 6f 63 61 6c 68 6f 73 |O S T N A M E = l o c a l h o s |
7fffb44ace50: 74 2e 6c 6f 63 61 6c 64 6f 6d 61 69 6e 00 54 45 |t . l o c a l d o m a i n . T E |
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
The standard descriptors may be redirected.
crtool dumplicates stderr in rlimit.maxfileno-1 and this descriptor
is inherited by all children and will be closed before sigreturn.
Known issues:
- The logging descriptor may be used by a target process and
a resume will fail.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Since we operate with syscalls directly we are
to convert signal's structures between image and
kernel formats, without intermediate glibc layer.
Note this involves chaging sa_entry::flags to u64
(since it's long int value in kernel).
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
It's needed to keep singnal handlers on
disk with predefined format.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
After all the child/threads stuff is moved to helpers it is
possible to remove some unneeded code paths and local variables.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Move all the parsing of /proc/pid/children into a helper to be symmetrical
with the threads parsing.
Error from xrealloc is ignored as well.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Move the whole code dealing with parsing threads at collect_pstree
stage into one function.
The nr_threads calculation is performed inside it based on the amount
of directories in /proc/pid/task, not the Threads: count in status.
Error from xrealloc is ignored by now.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
If a task is sleep in syscall, it should be restared.
This logic is moved from kernel do_signal().
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This test suite contains many small test cases for different subsystems.
Example of execution:
# make busyloop00.pid
# ../../../../crtools -d -t `cat busyloop00.pid`
# kill -9 `cat busyloop00.pid`
# ../../../../crtools -r -t `cat busyloop00.pid`
# cat busyloop00.out
PASS
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
sigactions are restored before memory and if a parent get a signal
which has a handler, it will get segmentation fault.
This problem will disappear, when we add a freezer, because
all processes will be resumed after restoring.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
A file destriptor is opened for read-only and mmap with PROT_WRITE fails.
We don't need PROT_WRITE for this case, because a file contains up to date
data.
lr-x------ 1 root root 64 Dec 1 19:10 20 -> /usr/lib64/gconv/gconv-modules.cache
pos: 0
flags: 0100000
41155 mmap(0x7f2c3d6cf000, 28672, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, 20, 0 <unfinished ...>
41155 <... mmap resumed> ) = -1 EACCES (Permission denied)
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
v2:
- Pavel reported there is no need to lock/unlock
last-pid file in cycle, just lock it once before
threads creation and unlock at the end.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
This also depends on kernel's inteface being changed,
so kernel/ is updated as well.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
The patch "sysctl: Add the kernel.ns_last_pid control" is not
yet handled by crtools, still it's staged here to not loose
it and collect all Acks in place.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
If I understand correct, they don't differ in linux.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
pipe_loop00 passed with this patch.
When we restore a regular fd (not pipe) we do use flags
directly in open() call.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
It's work for /dev/zero, /dev/null and other simple devices.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
It's because this mask will be restored as rt_sigframe->uc.uc_sigmask.
uc_sigmask will be set as current->blocked in sigreturn, so we should
dump SigBlk in this case.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>