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>
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>
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>
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>
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>
A parasite code dumps all sigactions in sigact.pid.
v2: remove hard code for sizeof(sigset_t)
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Threads are better to be restored in serialized
way otherwise if some error happened an error
message will be screwed.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
pstree file is a single one for all processes and
threads so skip non-matched entries correctly.
This brings testee test back to life.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Wasted a couple of hours trying to resolve this non-obvious
issue. It's because bootstrapping the restorer code might
requre more memory than 16K on stack. Strictly speaking
we need a compile time constant here and BUG_ON.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Since VMA areas are allocated with page granularity
better to reflect this in mmap request. This would
allow the restorer to do munmap on page boundaries.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>