2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 13:58:34 +00:00

4636 Commits

Author SHA1 Message Date
Cyrill Gorcunov
b0a9533080 crtools: Make sure there is enough space to hold image path
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-13 17:09:17 +04:00
Cyrill Gorcunov
7a11cfc0b3 restore: No need to track pid of main shmems, open map_files/ via /proc/self
It basically reverts e189efc1763d9cae55e1cafd7aff7ffef6e47303
which was overdone one.

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-13 17:09:08 +04:00
Stanislav Kinsbursky
7eec5a9e0c Sockets: replace macroses concatenation with single one for netlink requests
NLM_F_DUMP is already defined as (NLM_F_ROOT|NLM_F_MATCH)

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-13 16:38:10 +04:00
Stanislav Kinsbursky
7dcf59de2f libnetlink: typo fixed
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-13 16:32:25 +04:00
Andrey Vagin
3b7c1a1c79 zdtm: correct e-mail
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-13 14:09:25 +04:00
Cyrill Gorcunov
3bba868e92 sockets: Allow to reuse fd in run_accept_jobs
Sockets are special and we reuse fds in accept jobs.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-13 13:26:39 +04:00
Cyrill Gorcunov
81d91983d3 util: Move reopen_fd_as to reopen_fd_as_safe
[avagin@: Drop redundant fcntl call, and err variable]
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-13 13:26:28 +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
a9fdf3865e crtools: Collect dumping fd parameters into one place
Introduce the fd_parms structure, that contains all we need to describe
open fd during dump -- its name (int), pos, flags and id. The read_fd_parms
routing fills one once and passes along the stack. This reduces the amount
of arguments significantly.

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
1b247eb6b4 crtools: Toss dump_one_fd args around
Make the dump_one_fd fn accept local fd and integer target fd values
instead of target fd dir and target fd string name.

This saves couple of atoi-s (done once) and makes the next patch simpler.

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
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
a9e2321c38 crtools: Remove unused printk_registers and co
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
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
0d34b2707c crtools: Remove unused and wrong arrays from pstree image
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
Cyrill Gorcunov
e4d21f5a38 dump: Drop appending thread data to a main core file
It's a rudiment from Elf-time code.
Not needed anymore.

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 20:00:01 +04:00
Cyrill Gorcunov
6030463122 sockets: Fix memory leak on relative bind path
In case if relative bind path found we skip such
socket but forget to free previously allocated
memory.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 19:28:46 +04:00
Andrey Vagin
49074a98c4 socket: skipe unsupported sockets (v2)
We collect all unix sockets in the current net namespace, but
a target process uses a few of them, so we may skip unsupported sockets
and if it is used by a target process, lookup_socket returns error.

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-12 19:04:56 +04:00
Andrey Vagin
90fd4bfaf1 netlink: include sys/socket.h
It's workaround for RHEL6, it contains old headers.

In file included from libnetlink.c:2:
/usr/include/linux/netlink.h:34: error: expected specifier-qualifier-list before ‘sa_family_t’

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-12 19:04:56 +04:00
Andrey Vagin
f7688ed7ba files: clean up logic about intersection image fd and target fd
open_fdinfo calls move_img_fd, so other functions should not care about it

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-12 19:04:56 +04:00
Andrey Vagin
ed269b13a8 files: initilize variable
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-12 19:04:56 +04:00
Andrey Vagin
fd04a3029f files: remove unused variable
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-12 19:04:55 +04:00
Andrey Vagin
af41c3f509 files: make messages more informative
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-12 19:04:55 +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
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
Cyrill Gorcunov
f316a79e66 files: Use xmalloc instead of plain malloc
This also catches potential NULL dereference.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 16:46:35 +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
Cyrill Gorcunov
307260df2b Drop TODO file
Everything is on http://criu.org/Todo

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 21:20:11 +04:00
Andrey Vagin
bda3baa373 files: use lseek instead of open
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 18:24:45 +04:00
Andrey Vagin
14e42bb704 pipe: fix error code and message
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 18:24:40 +04:00
Andrey Vagin
9129d4e2a1 restore: don't use char in image struct-s
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 18:24:35 +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
Andrey Vagin
7fde5f061b restore: move file-related stuff to a separate file
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 18:39:39 +04:00
Andrey Vagin
d6a1d20690 zdtm: add test cases for shared sturct file-s
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 18:37:13 +04:00
Cyrill Gorcunov
37782e6e00 test: Update unix sockets
To include dgram bound && connected sockets, for example

CR_FD_UNIXSK: /home/cyrill/crtools/unixsk-2813.img
----------------------------------------
fd    3 type  1 state  1 namelen    0 backlog    0 id  19505 peer  19506
fd    4 type  1 state  1 namelen    0 backlog    0 id  19506 peer  19505
fd    5 type  2 state  7 namelen    0 backlog    0 id  19507 peer      0
fd    6 type  2 state  7 namelen   18 backlog   18 id  19508 peer      0 --> test-socket-bound
fd    7 type  2 state  7 namelen    0 backlog    0 id  19509 peer  19510
fd    8 type  2 state  7 namelen   17 backlog   17 id  19510 peer      0 --> test-socket-conn
fd    9 type  2 state  7 namelen   23 backlog   23 id  19511 peer  19511 --> test-socket-bound-conn
----------------------------------------

The last one is bound and connected.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:38:59 +04:00
Cyrill Gorcunov
dffaab578d sockets: Restore dgram sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-10 17:38:55 +04:00
Cyrill Gorcunov
930432f161 sockets: Make socket name printing similar to vmas
Use same format as we do for VMA names.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:51 +04:00
Cyrill Gorcunov
1a1979cc88 sockets: Show backlog length in "show" procedure
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:51 +04:00