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

119 Commits

Author SHA1 Message Date
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
Andrey Vagin
1494dbdf63 files: correct message
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-17 11:50:39 +04:00
Andrey Vagin
feae91fe9d files: restrict number of fdinfo_list_entries
We allocate only one page for fdinfo_list_entries.
In the future we will be able to resize this memory.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-17 11:50:20 +04:00
Andrey Vagin
c1e69464dc file: remove crap from prepare_fdinfo_global
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-17 11:49:57 +04:00
Andrey Vagin
fd4b542e01 files: typo fix
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-17 11:48:29 +04:00
Pavel Emelyanov
139a2ee27b fdinfo: Rewrite fd prep/open/recv via switch-base state-machine
Yet again -- this makes code easier to understand from my POV.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-16 23:52:19 +04:00
Pavel Emelyanov
7f5da73198 fdinfo: Remove unused variables from receive_fd
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-16 23:51:53 +04:00
Pavel Emelyanov
a2d5b88150 fdinfo: Open special fdinfos in a separate helper
Makes code easier to read.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-16 23:51:33 +04:00
Pavel Emelyanov
d1b3fd09b3 fdinfo: fd_is_special helper for maps and cwd
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-16 23:51:12 +04:00
Pavel Emelyanov
e2d8aec7f5 files: Named constant for cwd fdinfo
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-16 23:50:50 +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
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
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
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
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