files: Real pid on fdinfo_desc is unused

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Users counter is not required on file desc

It's used only to check whether we should do file re-send and verify we've served
all the cliens. This can be replaced with proper list manipulations.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Simplify cr_dump_tasks message printing

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Add case::default in open_fd

Otherwise I'm getting error
 |
 | files.c: In function ‘prepare_fds’:
 | files.c:329:23: error: ‘tmp’ may be used uninitialized in this function [-Werror=uninitialized]
 | files.c:309:6: note: ‘tmp’ was declared here

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restorer: Fix bug in address computation of thread args area

It's wrong to treat restore_thread_exec_start as arguments
area (I managed to overlook this problem in commit
014841825acb14a1d695569b9fe3575f5de6442b) it's rather
a function start address.

The thread arguments area allocated dynamically after the
restorer blob itself.

We didn't hit any problems earlier simply because there
were a few bytes owerwritten in function prologue.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasite: Drop unused PARASITE_COMPLETE_ADDR helper

It has been used when debuggin without PTRACE_SEIZE,
not needed anymore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
sockets: Fix compilation on older kernel headers

Since kernel commit 9c501935a3 the sys/socket.h
should be included prior the linux/netlink.h.

Make it so.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
sockets: Drop unused variables

Otherwise I get

 | sockets.c: In function ‘dump_socket’:
 | sockets.c:467: error: ‘st.st_ino’ may be used uninitialized in this function

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasite, restorer: Cleanup ld scripts

There is no need for specific parasite or restorer
head sections, a general "head" one is enough.

Also .stack section is dropped since it's never used.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restorer: Cleanup - drop always_inline attribute from write_ helpers

This object file will be handled by ld script so .text
sections will be squashed into one common section.
Thus no need to force these functions being always-inlined.

It's a rudiment from time when we were not using ld at
all but #include source code file itself and now this
attribute might confuse code readers since it's
unclear _why_ it's needed at all.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
make: Rebuild objects if headers are changed

At moment no-deps-targets is empty thus changes
in headers do not cause correspond source files
to be rebuilt. Fix it.

Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Read regfiles image in early on restore

Instread of re-reading this image again and again on every fd restore, pull the
reg-files.img in early and store the entries in a hash. This will simplify the
further fd restoring fixes and will allow for dump/restore via a stream (socket).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
inet: Collect inet sockets early on restore

Same as previous patch -- pull inet sockets in and store in the hash for the same reasons.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
unix: Collect unix sockets early on restore

Same as prev 2 patches now for the unix sockets. They are still in per-pid image files, but
this is going to change soon (I hope).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Rework the way fdinfos are collected

Now fdinfos are collected independently from reg files and
sockets. During tihs collect we effectively create the mirroring
list of both by checking which type-IDs are added first.

Fix this by removing the fdinfo_desc and attaching fds directly
to collected reg files and sockets. Pipes and unix sockets will
be reworked in the same manner soon.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Show collected regfiles fd tree

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Simpler regfiles and sockets open

The list_head ptr passed into it can be converted into
the respective _info with container_of, rather than search.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Dup local files on open, not receive

This will be needed for pipes, since we can't keep the pipe's
other end till that for dup.

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