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

199 Commits

Author SHA1 Message Date
Stanislav Kinsbursky
225d119e5d namespaces: split UTS and generic code
Generic code will be used for other namespaces.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-31 13:43:28 +04:00
Cyrill Gorcunov
ef57024410 show: Always print process' exit_code
It's suitable not for info only but in debug purpose as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@openvz.org>
2012-01-30 17:39:21 +04:00
Cyrill Gorcunov
5345889886 show: Drop tab'ified empty lines
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@openvz.org>
2012-01-30 17:39:21 +04:00
Pavel Emelyanov
beb158a66e cr: Task creds support
Dumping is simple. All but secbits can be read from proc, secbits
are got from parasite.

Restoring is a bit tricky -- when you change anything on kernel
cred's struct it performs sophisticated checks and can change
some more stuff than requested, so the creds restoration procedure
is carefully commented step-by-step.

Another thing to mention is that creds are restored after everything
else, i.e. right before performing final threads sync and sigreturns.
This is done to avoid potential problems with insufficient caps for
restoring other stuff (e.g. CAP_DAC_OVERRIDE or zero euid is most
likely required for opening any image file and the notorious control
/proc/sys/kernel/ns_last_pid, which in turn is performed till the
very last moment).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-30 13:00:50 +04:00
Pavel Emelyanov
98f4c2e4de ns: Support UTS namespace
Only two fields are modifiable -- hostname and domainname. So
read them on dump and write on restore.

File format is simple --

u32 magic
u32 length of nodename
u8[] nodename string
u32 length of domainname
u8[] domainname string

For OpenVZ we can write the release at the end, but this is later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-26 16:54:22 +04:00
Pavel Emelyanov
3391416a1b crtools: Namespaces support skeleton
New option -n to dump/restore namespaces.

Fork the namespaces dumping task and write a helper for switching a namespace.

Prepare the restorer code for restoring namespaces before root task.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-26 16:54:22 +04:00
Pavel Emelyanov
8e90a9e6d8 crtools: Tossing CR_FD_ bits around
Split the CR_FD_ bits into per-task and global ones and replace
of CR_FD_DESC_NOPSTREE with CR_FD_DESC_TASK, which is explicit
set of per-task bits.

The CR_FD_DESC_NS will appear soon.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-26 16:54:22 +04:00
Pavel Emelyanov
b7de83aaf3 crtools: Interval timers support
Timers are dumped from inside parasite code, the format is plain -- just
3 pairs of interval/value one-by-one.

The restoration occurs in two stages -- first prepare the timer values in
restorer (and check for sanity), then setup the timers in the latest stage
before actually calling the sigreturn.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-24 18:41:49 +04:00
Cyrill Gorcunov
a9fd7583e6 show: Add cmdline args and envirion entries
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-24 18:01:08 +04:00
Pavel Emelyanov
18aaad6164 img: Extend task image with state and exit code
Introduce 3 states we will have to work with:

* alive for tasks sleeping or running
* dead for zombies
* stopped for stopped tasks. We cannot distinguish tasks in this state now,
  but with freezer cgroup this will become possible

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-23 01:43:36 +04:00
Pavel Emelyanov
164ccc095f crtools: R/W API rewrite
Kill all the macros for reading/writing image parts. New API looks like

* write_img_buf/write_img
  Write an object into an image. Reports 0 for OK, -1 for error. The _buf
  version accepts object size as an argument, the other one uses sizeof()

* read_img_buf/read_img
  Reads an object from image. Reports 0 for OK, -1 for error or EOF.

* read_img_buf_eof/read_img
  Reads an object from image. Reports 1 for OK, 0 for EOF and -1 for error.
  This is not symmetrical with the previous one, but it was done deliberately
  to make it possible to write code like

  ret = read_img_bug_eof();
  if (ret <= 0)
	return ret; /* 0 means OK, all is done, -1 means error was met */.

  ... /* 1 means object was read, can proceed */

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-23 01:43:10 +04:00
Pavel Emelyanov
dbf3c1a8cd crtools: Reformat core_entry
Keep task arch-independent fields in one struct (will be extended) in the
beginning of the image and make pads be located separately.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-23 01:43:00 +04:00
Stanislav Kinsbursky
7fc6561c0c show: inet sockets dump parsing support added
Nothing to comment there.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-18 12:39:04 +04:00
Pavel Emelyanov
6babc5c17b files: Show file ID in -s output
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-15 22:37:49 +04:00
Cyrill Gorcunov
893f5099cb show: Drop redundat rendering of process tree
Leftover from merging stage.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-15 22:36:18 +04:00
Cyrill Gorcunov
53d75ad13c show: Fixup nit left after merging
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-13 21:42:18 +04:00
Cyrill Gorcunov
d7121ede0d Merge branch '@xemul-mails' into @xemul
* @xemul-mails:
  crtools: Collect dumping fd parameters into one place
  crtools: Toss dump_one_fd args around
  crtools: Rename fd to lfd in dump_one_fd
  crtools: Sanitize pstree construction
  crtools: Remove unused printk_registers and co
  crtools: Deduplicate file info showing code
  crtools: Merge pstree collecting into showing
  crtools: Remove unused and wrong arrays from pstree image
  crtools: Remove lseeks after prep_cr_ calls
  crtools: Cleanup collect_pstree in cr-show

Conflicts:
	cr-show.c

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 22:16:54 +04:00
Pavel Emelyanov
1d21633466 crtools: Deduplicate file info showing code
Print common info once, then append path if required.

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
6de20ba9c1 crtools: Merge pstree collecting into showing
1. There's no need in collecting children list in shower
2. There's no need in reading file twice -- we can collect and
   show everything in one go.

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
759533ce3f crtools: Remove lseeks after prep_cr_ calls
The cr preparation functions to read magic from files and thus this
lseek is not required.

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
3ab4286c55 crtools: Cleanup collect_pstree in cr-show
Rename this into read_pstree and remove unneeded 2nd argument.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 22:09:58 +04:00
Cyrill Gorcunov
9360a73cad crtools: Make close_cr_fdset being safe to be called with closed fd-set
It was being done intentionally to be able to call close_cr_fdset
several times in a row, bring this ability back. Otherwise I'm
getting glibc complains about attemt to free already freed memory.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 21:25:19 +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
Pavel Emelyanov
e710c5c5ef crtools: anitize showing funtions
Remove unneeded path argument (we do know the file data is read from) and
actually bogus show_header boolean.

Also introduce two helpers for showing header and tail.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 18:50:59 +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
a76922ebc0 crtools: Fix lost magic arg from print
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-28 21:15:21 +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
5c7fae1449 show: Fix useless sigaction mask dereference which lead to sigsev
struct sa_entry was converted to native format so
no need for dereference here.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-20 19:52:19 +04:00
Cyrill Gorcunov
62e9851a84 cr-show: Drop unneeded #includes
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 23:20:51 +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
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
Pavel Emelyanov
985990de23 crtools: Show 6 page va-s per line in [Pages] section
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-21 20:33:55 +04:00
Pavel Emelyanov
92a08bb25a crtools: Show shmem dump file contents
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-21 20:23:22 +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
1e7bbd35de restore: Add threads restoration
Now threads restortion (and TLS as well) works.
Threads test reports the following

    2775 (main): Counter value:    3 tls_data =    1
    2775 (main): ( 0) fsgs_base 7f9597aa46f0
    2775 (main): ( 0) fsgs_base        0
    2775 (thr3): Counter value:    4 tls_data =    4
    2775 (thr3): ( 0) fsgs_base 42c57940
    2775 (thr3): ( 0) fsgs_base        0
    2775 (thr2): Counter value:    3 tls_data =    2
    2775 (thr2): ( 0) fsgs_base 42456940
    2775 (thr2): ( 0) fsgs_base        0
    2775 (thr1): Counter value:    4 tls_data =    3
    2775 (thr1): ( 0) fsgs_base 40c62940
    2775 (thr1): ( 0) fsgs_base        0
    2775 (main): Counter value:    4 tls_data =    1
    2775 (main): ( 0) fsgs_base 7f9597aa46f0
    2775 (main): ( 0) fsgs_base        0
    2775 (thr1): Counter value:    5 tls_data =    3
    2775 (thr1): ( 0) fsgs_base 40c62940
    2775 (thr1): ( 0) fsgs_base        0

as expected.

This commits merges all preliminary commits into
the final one (sigreturn branch was always experimental
and forced update).

Still some problems remain:

1) While creating threads with clone() the
   flags are to be revisited. We use some predefined
   set here but it's not really correct.

2) No setup of pids in PCB thread zone.

3) No restore of FPU.

But at least on some basic tasks restore works well.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-12 19:26:40 +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
a8f8eb9c6e show: Print out thread registers as well
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-23 12:43:52 +04:00
Cyrill Gorcunov
3530297a5b show: Fixup typos in printing mm data
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-13 00:31:02 +04:00
Cyrill Gorcunov
4389c021fc dump, kernel: Add some mm structure members into the dump
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-12 18:05:07 +04:00
Cyrill Gorcunov
ce65f2f718 dump, kernel: Add start/end_code data
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-12 16:02:36 +04:00
Cyrill Gorcunov
f7e6e63b44 kernel, dump: Obtain brk value
Also re-make image to be 2 pages in size
which should be enough for basic params we
need to restore tasks.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-12 09:40:02 +04:00
Cyrill Gorcunov
4b7a318322 dump: Prepare for new core_entry layout
core_entry layout is arch dependant.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-11 01:32:39 +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
8f0af4f8a6 Restore task's command line as well
Note binary format for core file is changed.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-01 13:24:34 +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