This was required when pages were stored in elf files for
exec. Now we can stop reading it on eof.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Since now we have local copies of a remove FDs we can dump socket queus without entering
a parasite code. This makes the code MUCH simpler.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
We have two checks for fd being a chrdev:
One to skip stdio-s that are termilans and
The other one for any fd being a /dev/null or other special device.
Clean this a little bit.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The statfs is not required, we now check for fd being a socket with S_IFSOCK.
The 2nd stat is just not needed, the caller provides stat info.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This structure is actualy an fd parameter, so put it there. This will also
help with future patching.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
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>
This contains reg-files and sk-queues images, as they contain data
which is potentially generated by every task, so keep it open all
the time dump goes.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Write two helpers for opening an fdset for task and one for ns.
This probably can be done with some "generic" macro(s), but this
time it's simpler not to produce more code of that type.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
It's not required any longer. Now fdsets are allocated one-by-one only
when required and there's no need in adding new fds to existing sets.
Thus just remove the last arg from cr_fdset_open.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Move the fdset allocation inside dump_one_task and do it only for
non-zombies.
This makes sure we don't need to re-use an fdset, since we do allocate
it only when required.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This fd is global, so make it such. It will stop being just a global
variable soon.
Plus, remove the pid arg from format.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This routine is used for dumping tasks, threads and zombies. For the
last two the whole fdset is not allocated thus it will be better to
use single fd in this case.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Pid number is redundant - this file is one for the whole tree.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Since now on the fdinfo image only contains plain fdinfo_entry-es.
The tpye == FDINFO_REG files are described by regfiles.img entries
and are matched by te ID in both.
At dump stage each new ID generated results in a new entry in the
regfiles.img. At restore stage open_fe_fd should open a regfile by
the fdinfo's ID. Now this is done in suboptimal way, need to improve.
Show shows both images separately.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Make fdinfo_entry carry only the minimal info describing a file
descriptor -- the fd value itself, the fd type (regular file, exe
link, cwd, filemap and it will be pipes, sockets, inotifies, etc.)
and the describing file ID.
The mentioned ID will identify the type-d object, e.g. for regfiles
this ID is already generated with file-ids.c code.
The other part of this structure describes a regfile (i.e. a file
opened with open syscall). I put this new entry at the end of the
fdinfo_entry just to make the patching simpler. Soon this entry
will be dumped into its own file.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The unique id is 32 bit and consists only of the subid value. This
is _really_ enough. The genid part is just a hint for the tree-search
algirythm to avoid unneeded sys_kcmp calls.
Plus, generate IDs for special files. This will make it easier to
move the regfiles into into separate files (see the respective patch
for details).
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Hide the structure - it's not required.
[ xemul: Ranem long id into u32 id and adopt to current tree ]
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This is a cleanup patch. This tree is merged only once. So it's image file can
be opened by opne_image() call and dumped right after collect stage.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The core image now contains only core per-task stuff.
The new file resurrects Tula magic number removed earlier.
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
vma_entry contains shmid and all shared memory are dumped in own files.
The most interesting thing is restore.
A maping is restored by process with the smallest pid. The mamping
is created before executing restorer.
We map a full mapping and restore it's conten, then we open a file from
/proc/pid/map_files and store a descriptor in vma_info. The mapping is
unmaped. Now we can map any region of this mapping in the restorer.
We use this trick, because a target process may have this mapping in
some places and the restorer has not function to open proc files.
v2: fix error hangling
xemul: Fixed static-s and args for cr_dump_shmem
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
It will be used to restore shared mappings
v2: clean up
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
No need in checking the pid in every task loop cycle, just dump it
at the beginning and that's it.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cr_dump_tasks does assign ret = -1 by default but
dump_namespaces does shadow this variable with own
error code so that if any subsequent calls will fail
we will not notice the error.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This is a cleanup patch. Use file entry type variable for special files
instead of file entry addr variable.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>