2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 05:18:00 +00:00

71 Commits

Author SHA1 Message Date
Pavel Emelyanov
fbafe2db15 crtools: Rename fd to lfd in dump_one_fd
This variable is actually a local fd, so reflect this in its name.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 22:09:59 +04:00
Pavel Emelyanov
02dbadb46f crtools: Sanitize pstree construction
Rename find_pstree_entry into add_<one> (since it doesn't find it)
and move list adding into it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 22:09:58 +04:00
Pavel Emelyanov
6b83aef6a1 crtools: Merge fdset free into close
The same as previous patch -- no need in two separate calls.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 18:51:21 +04:00
Pavel Emelyanov
871b73674d crtools: Merge fdset allocation into prep
They always go in pairs so there's no need in two calls.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 18:51:13 +04:00
Pavel Emelyanov
15209d3fe9 crtools: Make fdset be an array of file descriptors
Path is not needed there -- we can call the get_image_path() in prep_cr_fdset_
routines and in parasite-syscall.c when required.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 18:51:06 +04:00
Cyrill Gorcunov
76ef79a081 dump: Fix stack data written to image
I case if there is no file id provided we
might be writting stack data to image. Better
put zeros there.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 14:09:54 +04:00
Andrey Vagin
d6a1cd0fbc restore: Learn to work with shared struct file-s
Some process can share one struct file-s, we may find them by "object IDs".
A file descriptor is opened in one process and send to other via unix socket.

The procedure of restoring files contains four stages.
* Collect data about all file's descriptors
  On this stage we find process which will restore a file descriptor and
  create a list of processes, who should get this descriptor.

* Create datagrams unix sockets
  If a file descriptor should be received, a unix socket is created
  instead of it.

* Open file descriptors
  A process with the least pid opens a file and sends this file
  descriptors to all one who wait it.

* Receive file descriptors.

When we were thinking up this algoritm, we wanted to minimize a number
of context switches. A number of context switches is proportional of a
number of processes.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 16:01:44 +04:00
Pavel Emelyanov
b5cc5fc3e1 crtools: Sanitize parasite_ctl pass to parasite_cure_seized
Remove excessive checks and keep it a pointer.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 14:00:06 +04:00
Pavel Emelyanov
a49e30722a crtools: Kill constant arg from parasite_infect_seized
The mmap hint is always NULL.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 13:59:54 +04:00
Pavel Emelyanov
73633d5505 crtools: Kill constant arg from parasite_dump_pages_seized
The last one is always CR_FD_PAGES.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 13:59:41 +04:00
Pavel Emelyanov
0ca9ccc3e4 crtools: Sanitize the tasklist states switch
Introduce a helper for walking the list and sending signals.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 13:59:15 +04:00
Cyrill Gorcunov
843747de55 net: A few changes in headres to follow c99
Since we're not system library

 - no underscopes in functions name until really needed
   and known to not clash with posix namespace
 - empty line between system headers and own headers
   for readability
 - extern for function prototypes

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 14:26:13 +04:00
Pavel Emelyanov
c5eb61e866 Unix sockets initial support
Currently it can only work with stream sockets, which have no skbs in queues
(listening or established -- both work OK).

The cpt part uses the sock_diag engine that was merged to Dave recently to
collect sockets. Then it dumps sockets by checking the filesystem ID of a
failed-to-open through /proc/pid/fd descriptors (sockets do not allow for
such tricks with opens through proc) against SOCKFS_TYPE.

The rst part is more tricky. Listen sockets are just restored, this is simple.
Connected sockets are restored like this:

1. One end establishes a listening anon socket at the desired descriptor;
2. The other end just creates a socket at the desired descriptor;
3. All sockets, that are to be connect()-ed call connect. Unix sockets
   do not block connect() till the accept() time and thus we continue with...
4. ... all listening sockets call accept() and ... dup2 the new fd into the
   accepting end.

There's a problem with this approach -- socket names are not preserved, but
looking into our OpenVZ implementation I think this is OK for existing apps.

What should be done next is:

1. Need to merge the file IDs patches in our tree and make Andrey to
   support files sharing. This will solve the

	sk = socket();
	fork();

   case. Currently it simply doesn't work :(

2. Need to add support for DGRAM sockets -- I wrote comment how to do it
   in the can_dump_unix_sk()

3. Need to add support for in-flight connections

4. Implement support for UDP sockets (quite simple)

5. Implement support for listening TCP sockets (also not very complex)

6. Implement support for connected TCP scokets (hard one, Tejun's patches are not
   very good for this from my POV)

Cyrill, plz, apply this patch and put the above descriptions onto wiki docs (do we
have the plans page yet?).

Andrey, plz, take care of unix sockets tests in zdtm. Most likely it won't work till
you do the shared files support for sockets.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 23:25:04 +04:00
Cyrill Gorcunov
3c929e540c dump: Adopt dumping children for new format
Kernel has a new format for process children
(ie /proc/<pid>/task/<tid>/children) so adopt
crtools for it.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 02:24:46 +04:00
Cyrill Gorcunov
894a626a52 dump: parse_threads - Pass single struct pstree_item instead of a few parameters
Parsing children will require to know the number
of threads found so in a sake of consistency pass
single struct pstree_item here as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 02:24:37 +04:00
Cyrill Gorcunov
ff954f655f dump: Drop unneeded #includes
This as well forces to move ptrace
definitions into ptrace.h, otherwise
freshly fetched kernel headers become
conflict with existing ptrace constants.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 23:18:17 +04:00
Cyrill Gorcunov
2e3c4e3692 Move everything related to ptrace into ptrace.[ch]
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 21:57:59 +04:00
Cyrill Gorcunov
32ac78a499 util: Drop ptrace seize helpers declaration from the header
Already defined in seize.h

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 21:19:28 +04:00
Cyrill Gorcunov
8a90464cc9 Drop some duplicated #include
And rearrange the rest.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 21:05:37 +04:00
Cyrill Gorcunov
950e788b1c Dump: Add missing ending new lines to pr_perror
pr_perror is not the same as perror and requires
new line at then end.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-10 12:49:55 +04:00
Cyrill Gorcunov
6701296f5a dump: Be ready for absence of output from /proc/pid/children
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-09 11:45:55 +04:00
Andrey Vagin
4c479da259 Dump and restore current work directory (v2)
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>
2011-12-07 17:16:41 +04:00
Cyrill Gorcunov
d924a240ff make: Drop redundand dependency on parasite.h
There is no such file at all and it forced build
process to re-build every make command passed.

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-05 20:36:57 +04:00
Cyrill Gorcunov
485c4b50d1 show: Rework show procedure
Added

 - ability to parse every single file crtools
   understands via magic number

 - dumped memory pages can be rendered in two
   modes -- as a simple set of pages' virtual addresses
   or in hexdummp fashion (via -c command line key).

For example

  ./crtools -s -c -f pages-2557.img

CR_FD_PAGES: pages-2557.img
----------------------------------------
    7fffb44ace20: 00 00 00 00 00 00 00 00  00 00 00 74 65 73 74 2f  |. . . . . . . .  . . . t e s t / |
    7fffb44ace30: 74 65 73 74 2d 73 69 67  61 63 74 69 6f 6e 00 48  |t e s t - s i g  a c t i o n . H |
    7fffb44ace40: 4f 53 54 4e 41 4d 45 3d  6c 6f 63 61 6c 68 6f 73  |O S T N A M E =  l o c a l h o s |
    7fffb44ace50: 74 2e 6c 6f 63 61 6c 64  6f 6d 61 69 6e 00 54 45  |t . l o c a l d  o m a i n . T E |

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-05 15:59:01 +04:00
Cyrill Gorcunov
da61f73263 dump: Test errors on xrealloc result
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2011-12-05 13:36:08 +04:00
Cyrill Gorcunov
29e66613cb dump: Drop redundant pr_debug
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-05 13:21:43 +04:00
Pavel Emelyanov
ec8cdcd7cf crtools: Cleanup pstree entry code
After all the child/threads stuff is moved to helpers it is
possible to remove some unneeded code paths and local variables.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-02 18:39:35 +04:00
Pavel Emelyanov
8340bff864 crtools: Cleanup children stuff parsing
Move all the parsing of /proc/pid/children into a helper to be symmetrical
with the threads parsing.

Error from xrealloc is ignored as well.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-02 18:39:22 +04:00
Pavel Emelyanov
5e47e233df crtools: Cleanup threads stuff parsing
Move the whole code dealing with parsing threads at collect_pstree
stage into one function.

The nr_threads calculation is performed inside it based on the amount
of directories in /proc/pid/task, not the Threads: count in status.

Error from xrealloc is ignored by now.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-02 18:37:59 +04:00
Andrey Vagin
04f36aed0a Set descriptors to restart a current syscall
If a task is sleep in syscall, it should be restared.
This logic is moved from kernel do_signal().

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-02 17:50:55 +04:00
Cyrill Gorcunov
63fea93076 dump: Switch to /proc/$pid/children parsing to obtain children set
This also depends on kernel's inteface being changed,
so kernel/ is updated as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2011-12-01 18:51:40 +04:00
Cyrill Gorcunov
6661b555b9 dump: Don't forget to close opened file on error path
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:30:53 +04:00
Andrey Vagin
146735f933 Dump direcory descriptor as a file descriptor
If I understand correct, they don't differ in linux.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:04:24 +04:00
Andrey Vagin
6949e0f09f Dump memory character devices as a file.
It's work for /dev/zero, /dev/null and other simple devices.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:04:16 +04:00
Andrey Vagin
7553620298 Dump SigBlk instead of SigCgt
It's because this mask will be restored as rt_sigframe->uc.uc_sigmask.
uc_sigmask will be set as current->blocked in sigreturn, so we should
dump SigBlk in this case.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:04:12 +04:00
Andrey Vagin
25434884e1 Dump and restore sigactions (v2)
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>
2011-11-30 22:04:09 +04:00
Andrey Vagin
bc1f9d728a Skip a standard destriptor only if it's tty (v2)
ZDTM tests redirect standart descriptors to /dev/null

v2: * Skip tty only if it's a standard descriptor.
    * No strcmps on names.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:04:00 +04:00
Cyrill Gorcunov
122cae2111 dump: Add -k (kill dumped) option
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-22 22:09:28 +04:00
Cyrill Gorcunov
0fd17a08cb Bring some order in usage of VMA entries helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-15 17:12:29 +04:00
Cyrill Gorcunov
bb15450d98 image: Drop tls_array from the image
We use registers set anyway

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-15 14:57:39 +04:00
Cyrill Gorcunov
1c5f981e51 cleanup: dump -- Add warning on unexpected VMA
Instead of simply dropping this dead code, put
a warning here, just to be on a safe side.

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-14 18:51:36 +04:00
Cyrill Gorcunov
ba63496330 dump: Update comment
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-14 17:22:17 +04:00
Cyrill Gorcunov
db2064811d dump: Add missing newline in error message
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-09 13:00:12 +04:00
Cyrill Gorcunov
0a26593a3b dump, restore: Add blocked signals mask
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-09 00:29:41 +04:00
Cyrill Gorcunov
0355f1d23a dump: Don't fail on dumping paths for anon shared mappings
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 13:25:15 +04:00
Cyrill Gorcunov
da8f61c1c8 dump: Add GS-TLS handling
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-07 17:44:00 +04:00
Cyrill Gorcunov
8a8850d146 dump: Dump TLS via sys_arch_prctl
As such -- no need for kernel patch.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-07 16:29:36 +04:00
Cyrill Gorcunov
2cc7488de2 dump: Make VMA parsing to handle absence of map_files
Needed in testing purposes. Also make free_mappings
being a global one (will need it in restorer).

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-26 22:48:10 +04:00
Cyrill Gorcunov
20ff379ee4 dump: Append threads to the core file
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-24 23:01:42 +04:00
Cyrill Gorcunov
26857cc4e5 util: Move various helpers there
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-24 13:43:21 +04:00