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

52 Commits

Author SHA1 Message Date
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
Andrey Vagin
255cd497bd util: print warning if a image file is absent
It may be legal. E.g. for zombie

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-27 15:10:38 +04:00
Pavel Emelyanov
af3616d0ce util: Sanitize get_image_path
Make it shorter and simpler and use one in open_image_ro_nocheck.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-16 13:43:33 +04:00
Pavel Emelyanov
8c9c575ab4 util: Move get_image_path to util.c
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-16 13:43:23 +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
Andrey Vagin
eac52b6090 util: reopen_fd_as to return an error if destination descritor is busy
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-10 16:55:02 +04:00
Cyrill Gorcunov
a14ceb4950 util: Fix parse_maps to handle anonymous shared mappings
In commit 99eb3d09c5c42200b230783e793b778882ce8dd6
we started to use self-contained shared memory
region but it revealed the problem that anonymous
sgared mappings might be parsed by parse_maps incorrectly,
so fix it and be ready to get anon-shared mappings.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:36:56 +04:00
Pavel Emelyanov
5f7d677fad crtools: Sanitize collect_mappings path buffers usage
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-30 16:25:42 +04:00
Pavel Emelyanov
96f92ee612 crtools: Cleanup open_image_ro
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-29 19:56:34 +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
Pavel Emelyanov
99cc87949f reopn_fd_as return code fixlet and cleanup
Nobody cares the returned fd, so just make it 0/-1 and clean up the callers.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 21:53:36 +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
8a90464cc9 Drop some duplicated #include
And rearrange the rest.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 21:05:37 +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
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
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
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
Andrey Vagin
555efbb374 Set MAP_GROWSDOWN flag for stacks
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:04:29 +04:00
Cyrill Gorcunov
4dc0736697 dump,restore: Dump and restore vDSO area from userspace
There is no need to force kernel to remap vDSO area, we
can do that from the user-space as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-29 16:39:48 +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
Pavel Emelyanov
47b7404d73 crtools: Don't save vma's inode info in image
This one isn't used on restore process, since the file mapped is
stored in the fdinfo part of the images.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-23 14:03:24 +04:00
Pavel Emelyanov
9299d53d32 crtools: Don't show vma fd in --show output
This entry is for restorer only. In image the fd is -1 always.

Signed-off-by; Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-23 14:03:20 +04:00
Pavel Emelyanov
fb44c9d82b crtools: Don't hold pid on vma image
It's pointless. All vmas are stored in the per-pid image file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-23 14:03:14 +04:00
Cyrill Gorcunov
c704fc272e util: Make VMA proto being printed with 8 char width
Fancy output.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-22 00:13:04 +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
bbabbe89a7 util: Use vma_entry_len helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-15 14:02:00 +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
3542220a00 util: Split long line
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-15 13:32:09 +04:00
Cyrill Gorcunov
929e316f5f util: VMA area flags might exceed 4 symbols
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-15 13:28:56 +04:00
Cyrill Gorcunov
54b1455e8a util: Move maps buffer into routine stack
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-15 11:34:11 +04:00
Cyrill Gorcunov
dd4d829d61 util: Add error messages into files/dirs open helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-15 11:29:33 +04:00
Cyrill Gorcunov
83c209ef07 Move vma prot setup into parsing helper
To shrink restorer code.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 13:54:01 +04:00
Cyrill Gorcunov
b9d0883d76 dump: Anonymous shared mappings should have MAP_ANONYMOUS flag
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 12:19:43 +04:00
Cyrill Gorcunov
099c9c0016 dump: Don't forget to save MAP_ANONYMOUS if it was there
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-08 00:39:21 +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
0d20dd0b41 util: Add hex_dump helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-26 10:10:19 +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
a0f463c27d Move seize related functions into seize.[ch]
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-13 19:18:43 +04:00
Cyrill Gorcunov
c2bd177330 dump: Add comments on task seizing and stopping
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-13 18:57:13 +04:00
Cyrill Gorcunov
cecd0ef138 utils: Inability to open map_files/ is fatal error
Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-13 16:07:34 +04:00
Cyrill Gorcunov
94789dcfc9 util: Show heap area
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-12 13:33:02 +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
e672d1a87f restore: Make reopen_fd_as to print error
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-09-27 18:39:56 +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