protobuf: Return -1 on error in do_pb_read_one

Better to stick with the convention we're trying
to follow in general -- negative codes for error.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
protobuf: Drop dangling \Space

No func change.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Update futex-rl test for thread leader

Don't forget to test thread leader as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: check_core -- Move core->ids check under separate if() statement

We will need to extend non-zombie tests.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: check_core -- Add missing test for thread_info in non-zombie task

Otherwise we might get nil dereference in sigreturn restore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
protobuf: Add @blk_sigset to thread_core_entry

It will hold the blocked signals for threads.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasite: Rework init/fini to reserve/free space for per-thread data

The per-thread information requires own space in parasite data.
In particular we will keep the blocked signals bound to thread
pids.

For this sake the caller need to provide the parasite how many
threads will be used to calculate space.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasite: Add [init|fini]_thread helpers

These helpers will be needed to save a blocked signals
mask for dumpee threads.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasite: Switch parasite thread leader to use thread helpers

 - the init() now calls for init_thread() to save blocked
   signals mask in per-thread data

 - the fini() now calls for fini_thread() to restore the
   blocked signals, note: we could use thread_leader directly
   but i think calling for fini_thread() is more generic

 - dump_misc() now uses per-thread data

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasite-syscall: Add parasite_[init|fini]_threads_seized helpers

We will use them from crtools code to save and restore blocked
signals mask of threads.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasite: Rename parasite_dump_tid_info to parasite_dump_thread

We will need to extend the structure to keep not only tid/tid_addr
but blocked signals as well, thus rename it to more generic
parasite_dump_thread.

The command PARASITE_CMD_DUMP_TID_ADDR renamed to
PARASITE_CMD_DUMP_THREAD for the same sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasite: Declare @tid as pid_t in parasite_dump_thread

Just to be consistent with types we're using.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Save and remove per-thread argumens in parasite

This patch starts using parasite_init_threads_seized and
parasite_fini_threads_seized helpers to save per-thread
data in parasite and remove it on cure procedure.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Checkpoint per-thread blocked signals

I've moved dump_thread helper a bit lower in file
since I've to call for find_thread_state helper.
After all this groups all thread related functions
in one slab.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Show blocked signals when dumping

For debug purpose.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Fix message in thread dumping

And add missing new line in message.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: Add restoration of the blocked threads signals from the image

To unify the code for both thread leader and regular threads
we move blocked signals for thread leader into threads argument
area and use restore_thread_common() helper.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Add new pthread01 test

To test threads blocked signals restoration.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
check: Set error log level before checking

Not to spoil screen with false warnings.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: Introduce a macro to get restorer symbol address

This makes code more readable, saves one ptr on stack and
lets us jump into restorer code using tags.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>