2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-28 12:57:57 +00:00

136 Commits

Author SHA1 Message Date
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
Pavel Emelyanov
7c73b4c141 crtools: Remove use_mask from fdset
This one is required on allocation -- it's already there as an argument.
It's also required on free, but we can check for fd being >= 0.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 18:50:51 +04:00
Pavel Emelyanov
ee13367486 crtools: Remove tmpl pointer from fdset
All the places we need one in can use the direct reference on template.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 18:50:36 +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
Pavel Emelyanov
329d8aa662 The pid == 0 is enough.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-28 21:16:02 +04:00
Pavel Emelyanov
d4fd91046f crtools: Remove duplicate show_single_file boolean
It duplicates the show_dump_file pointer.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-28 21:15:55 +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
8e5dc8a198 crtools: Allow to not specify a pid if to show a file contents
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-20 19:47:06 +04:00
Cyrill Gorcunov
344ccb365c crtools: Make sure pid is specified in command line
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-20 19:26:37 +04:00
Cyrill Gorcunov
6e6a820bcf crtools: Drop unneeded headers
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 22:29:30 +04:00
Cyrill Gorcunov
d6eab944e3 Move logging functions to log.c
Instead of keeping all unrelated to
C/R procedure helpers in util.c move
logging related helpers to log.c.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 18:52:50 +04:00
Cyrill Gorcunov
3023837da9 crtools: Return negative number on error
In a sake of consistency.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 18:23:14 +04:00
Cyrill Gorcunov
08faefd6bb crtools: Use safe strncpy in get_image_path
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelianov <xemul@parallels.com>
2011-12-19 15:37:05 +04:00
Cyrill Gorcunov
03a5e05a65 Rename 'name' member of cr_fd_desc to 'path'
It might contain working directory path as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelianov <xemul@parallels.com>
2011-12-19 15:31:14 +04:00
Cyrill Gorcunov
bcba2f734a crtools: Update help message
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelianov <xemul@parallels.com>
2011-12-19 15:26:51 +04:00
Cyrill Gorcunov
f65c75c78a crtools: Move global image_dir to the top of the file
Better to have global vars gathered.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelianov <xemul@parallels.com>
2011-12-19 14:58:50 +04:00
Andrey Vagin
b84babe630 get_image_path: calculate size of string correctly
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-16 16:26:48 +04:00
Cyrill Gorcunov
739ca109c6 crtools: Fix getcwd return value test
getcwd returns NULL on error, fix it.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-13 15:07:06 +04:00
Cyrill Gorcunov
c1350f9ab1 Make error codes returned being a negative value
We have a mess in our return codes:
some functions return negative values,
while others -- positive.

Sanitize the return codes and make error
condition to return negative values.

Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-13 15:03:33 +04:00
Andrey Vagin
335639dc7c crtools: kill all dumped processes by default
If a process continue to run, it may change a state of filesystem.

@gorcunov:
 - Drop -k option, it's not needed anymore.
 - Allow -c option (continue execution of a
   process after being dumped) in dumping procedure.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-09 12:37:08 +04:00
Andrey Vagin
650318f4b2 crtools: add options to specified a log 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-08 18:55:13 +04:00
Andrey Vagin
d261cf7958 Use absolute path for image files
Now I try to restore CWD and a relative path will be invalid.

Add new options -D to set image files directory.

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:37 +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
Andrey Vagin
2c237b6973 Don't use standard descriptors for logging
The standard descriptors may be redirected.

crtool dumplicates stderr in rlimit.maxfileno-1 and this descriptor
is inherited by all children and will be closed before sigreturn.

Known issues:

 - The logging descriptor may be used by a target process and
   a resume will fail.

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-05 12:07:52 +04:00
Cyrill Gorcunov
8324db69ee Fix comment on CR_FD_SIGACT
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 23:33:28 +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
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
b712182308 Gather file names formats in one place
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-15 18:35:55 +04:00
Cyrill Gorcunov
9ab6e9fe5c crtools: Use %d format for pir_t
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-15 13:12:27 +04:00
Cyrill Gorcunov
c28f9a2eae crtools: Use memzero_p
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-23 12:30:42 +04:00
Cyrill Gorcunov
118180451e crtools: Switch to getopt facility
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-13 19:43:52 +04:00
Cyrill Gorcunov
640e5c46be dump: Call fsync only if needed
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-13 13:41:13 +04:00
Pavel Emelyanov
d48706328e Add comments on fd set
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-13 13:33:32 +04:00
Cyrill Gorcunov
609e431376 Add cr_options structure
We will need more options since the
tool should support both cgroups freezer
and a regular task stop/dump/restore/continue
transition.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-04 01:50:19 +04:00
Cyrill Gorcunov
a00ef142f8 Use pr_err for error printing
To follow kernel style

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-09-30 14:37:12 +04:00
Cyrill Gorcunov
523de23624 Initial commit
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-09-23 12:00:45 +04:00