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

97 Commits

Author SHA1 Message Date
Cyrill Gorcunov
cf8b39d4aa util: Drop jerr macros
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-16 22:05:40 +04:00
Pavel Emelyanov
82a8a8ff95 sockets: Decode kernel dev_t into stat's one
Unix diag and stat report dev_t-s in different formats. Cast one to
another when comparing in unix dumping.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-08 16:11:27 +04:00
Kir Kolyshkin
fa5ce3112f Annotate printk with printf attribute
This way gcc will be able to catch invalid format bugs.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-31 15:56:33 +04:00
Kir Kolyshkin
6ce8d8ab93 Make BUG_ON() clang-compatible
When trying to compile the beast with clang, it complains:

====
./include/lock.h:33:2: error: indirection of non-volatile null pointer will be deleted, not trap
        BUG_ON(ret < 0);
        ^~~~~~~~~~~~~~~
In file included from restorer.c:18:
./include/util.h:118:27: note: instantiated from:
#define BUG_ON(condition)       BUG_ON_HANDLER((condition))
                                ^
./include/util.h💯4: note: instantiated from:
                        *(unsigned long *)NULL = 0xdead0000 + __LINE__; \
                        ^
====

Make clang happy again by adding 'volatile'.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-31 15:56:23 +04:00
Kir Kolyshkin
0b237ae9f2 pr_perror(): print error at the end of line
This is a standard convention to print error message (i.e. strerror(errno))
at the end of line, like this:

        Cannot remove file: Permission denied

So pr_perror is fixed to follow this convention (using GNU extension
%m helps a lot here). Unfortunately, due to this we have to make
pr_perror() print a new line character, too, so we had to strip it
from the all pr_perror() invocations.

That (appending a newline) also makes pr_perror() a black sheep
in the herd of pr_* helpers, but what can we do? Worst case scenario
is an extra newline after an error message, not too harmful.

An alternative approach (stripping the newline from the passed format
string and re-adding it) was discussed thoroughly, and it was decided
that such a hack looks a bit too dirty.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-31 15:49:15 +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
Cyrill Gorcunov
e1c1ca3c46 util.h: Cleanup, no func changes
Just drop a couple of spaces and
add a comment.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-18 18:38:47 +04:00
Pavel Emelyanov
8836f20c64 util: Print message when read size is bad
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-18 18:31:57 +04:00
Andrey Vagin
31fb055220 restorer: make BUG_ON more informative
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-17 18:08:03 +03:00
Andrey Vagin
f05e2dcc1f restorer: don't use printk in restorer
BUG_ON_HANDLER from util.h may be used in restorer.
E.g. #include <util.h>
     #include <lock.h>

Now the process will be segfaulted and you can find a line
number in assemgler code. We will print messages a bit late.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-17 18:08:03 +03:00
Cyrill Gorcunov
976c092c3f show: Drop redundant \n in pr_img_tail
Before

# ./crtools -s -f unixsk-12713.img

CR_FD_UNIXSK
----------------
fd    8 type  2 state  7 namelen   17 backlog   17 id  79422 peer      0 --> test-socket-conn
fd    9 type  2 state  7 namelen   23 backlog   23 id  79423 peer  79423 --> test-socket-bound-conn

----------------

After

# ./crtools -s -f unixsk-12713.img

CR_FD_UNIXSK
----------------
fd    8 type  2 state  7 namelen   17 backlog   17 id  79422 peer      0 --> test-socket-conn
fd    9 type  2 state  7 namelen   23 backlog   23 id  79423 peer  79423 --> test-socket-bound-conn
----------------

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-15 22:36:27 +04:00
Pavel Emelyanov
12d4c85410 crtools: Move proc parsing routines to one file
Start with /proc/pid/maps parser

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-14 02:00:26 +04:00
Cyrill Gorcunov
1c96c5cff0 Merge branch '@xemul' into dev
* @xemul:
  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-dump.c
	include/sockets.h
	sockets.c

The conflicts are mostly because of commit
995ef5eca3b8d74cf192e41c307f5329d93f9795

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-13 21:39:14 +04:00
Cyrill Gorcunov
995ef5eca3 Use openat() helper intensively when opening /proc/pid/X files
This allows us to get rid of open-coded "/proc/pid/X".

Based-on-patch-from: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-13 18:29:18 +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
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
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
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
00e14f0448 make: Add DEBUG=1 option
This allows to use pr_debug and dprintk helpers.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 02:28:12 +04:00
Cyrill Gorcunov
4c0fb12e11 util: Make pr_warning to report file and line as well
For easier debugging. We can zap it at release time.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 02:28:02 +04:00
Pavel Emelyanov
bf7a74d47e Helper for moving image fd
When opening an fd at a position where the current image fd sits
the latter one should be moved.

Introduce a helper for this.

Signed-off-by; Pavel Emelyanov <xemul@parallels.com>

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 21:53:44 +04:00
Cyrill Gorcunov
f5a87742a0 util: Add BUG_ON helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 15:54:03 +04:00
Cyrill Gorcunov
3e45e04050 util: Add fopen_fmt helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 02:24:27 +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
83fd63d3fe Add missing extern to function prototypes
Regardless that we link all things in one executable
better declare them so from the very beggining.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 21:46:03 +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
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
dc883fe49f util: Drop unused inline_memcpy
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 16:13:04 +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
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
9eeb003766 util: Add K/M/G bytes helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-24 15:07:03 +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
35781a8c6d util: Drop redundant vma_area->vma.status assignment
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-15 13:37:17 +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
fa56125d16 util: Move memcopy helper into the header
Since we will need it in parasite and restorer
code rename it to inline_memcpy to avoid name
collision.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-26 18:05:32 +04:00
Cyrill Gorcunov
0d20dd0b41 util: Add hex_dump helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-26 10:10:19 +04:00
Cyrill Gorcunov
ea0f8eac1d util: Add open_fmt_ro helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-24 13:56:03 +04:00
Cyrill Gorcunov
f8ad351f4d util: Make open_fmt being more general
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-24 13:51:41 +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
Cyrill Gorcunov
6c4798fd44 util: Rename objzero to memzero_p
More natural name

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-23 12:30:28 +04:00
Cyrill Gorcunov
5f53dc21d9 util: Change read_safe_eof and introduce objzero and memzero
Should be more convenient to use

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-23 12:30:17 +04:00
Cyrill Gorcunov
a0e37e779d util: Add xstrdup helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-23 12:01:39 +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
401464d22a Add close_safe helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-09-27 18:28:09 +04:00
Cyrill Gorcunov
523de23624 Initial commit
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-09-23 12:00:45 +04:00