img: Fixup seeks

There's no need in seeking file on core dump.
Fix explicit sizeof(u32)-s in restore seeks.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Use O_DUMP flags for single image opening

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restorer: Round size of area with self vmas up to page size

These chunks of memry, which transit into restorer code gets unmapped one-by-one and thus each of them
should be page-aligned.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: Helper for vmas list remap and copy

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: Don't write to vma image on restore

This is not good to update images while restoring.

Thus, read vma_entry-es once into a list, put opened (when required) fds
in there and make restorer walk the entries in mem, not those read from
the image file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
log: Specify logfile mode when creating one

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

It's unused and wrong.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Add builtin_memcpy helper

We will need it in parasite code where we can't use libc functions.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
types: Add SCM limits

We will need them in file descriptors transfer addressed in further patches.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
util-net: Add declaration of scm_fdset structure

This structure will serve for multiple fds transmission/receive.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
util-net: Switch send_fd/recv_fd to use scm_fdset structure

To be able to use scm_fdset structure the two helpers
added scm_fdset_init_chunk and scm_fdset_init.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
util-net: Itroduce send_fds/recv_fds routines

We will need these helpers to transfer file
descriptors from dumpee to our space.

Also make send_fd/recv_fd to be a wrappers over
send_fds/revc_fds to not duplicate the code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasite: Add interface for file descriptors draining

Just implemented but not yet used in dumping procedure,
this will be addressed in further patches.

Note the space for file descriptors is statically allocated
in 8K arguments area, not on stack.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Use parasite file descriptors draining

Since we're able to simply drain file descriptors
we're interested in, just do that with parasite
help.

This changes the calling sequence a bit

 1) Collect file descriptors before parasite
    get intected the dumpee and remember them in
    local copy.

 2) Ask parasite to drain collected descriptrs
    into our space.

 3) Operate with file descriptors directly via fcntl
    calls and such.

Overall idea is to prepare ground for fowners
dumping which will be addressed in further patches.

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