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

106 Commits

Author SHA1 Message Date
Andrey Vagin
3a9c6a3d37 util: use glibc macros to generate device numbers in the dev_t format
Our version of macroses are worng.

Our macros:
#define MINOR(dev)           ((dev) & 0xff)

Glibc function:
return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);

Reported-by: Amey Deshpande <ameyd@google.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-05-07 21:02:35 +04:00
Christopher Covington
5d74f55d80 Don't say /proc in macro errors
It's possible that a procfs mounted somewhere other than /proc
is in use.

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-25 13:25:13 +04:00
Pavel Emelyanov
98fbeb8d0a vma: Vma allocation helper is now function
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-03 17:18:42 +04:00
Pavel Emelyanov
bd7bf7bd39 anon-inode: Don't readlink fd/fd multiple times
The is_foo_link readlinks the lfd to check. This makes
anon-inodes dumping readlink several times to find proper
dump ops. Optimize this thing.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-02 22:14:29 +04:00
Pavel Emelyanov
f9c8e3a2cd pagemap: Factor out pfn retrieving for vdso and zero page
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 23:34:53 +04:00
Pavel Emelyanov
29952618e3 daemon: Write own daemon routine
RPC will start page-server daemon and needs to get the
controll back to report back to caller, but the glibc's
daemon() does exit() in parent context preventing it.

Thus -- introduce own daemonizing routine.

Strictly speaking, this is not pure daemon() clone, as the
parent process has to exit himself. But this is OK for now.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 15:58:41 +04:00
Pavel Emelyanov
839a3c6122 files: Don't call fstatfs twice
When filling fd_parms we do call statfs, no need to call it
again later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-29 20:09:27 +04:00
Kir Kolyshkin
b11f24fd5d criu check: don't run as non-root
In case criu check is run as non-root, a lot of information is printed
to a user, with the only missing bit is it should run it as root.

Fix it.

I still don't like the fact that some other stuff is printed here,
like the timestamp and the __FILE__:__LINE__, but this should be
fixed separately.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 13:58:45 +04:00
Kir Kolyshkin
e49faff1ff fopen_proc(), opendir_proc(): don't print two errors
Both fopen_proc() and opendir_proc() are calling open_proc().
If open_proc() fails, it prints an error message. Before this
patch, a second error message was printed due to missing brackets.
This second message is a bit more specific (it tells the exact
file/dir we failed to open) but it is redundant, because more
generic error was already printed by open_proc(). It is also
can be misleading because for the second message we reuse
the same errno while we should not.

So, let's remove this second error message print by using brackets.

Alternatively, we could leave this as is (just fixing indentation)
and let two errors be printed -- there is nothing wrong with that,
but I think in this case less messages is better.

This is a fix to commit 5661d80.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-21 13:40:35 +04:00
Cyrill Gorcunov
291aa3f6d6 headers: Add extern specificator to functions
We really have a mess of extern/non-extern declaration
of functions in our headers. Always use extern for
unification purpose.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-15 17:00:58 +04:00
Igor Sukhih
647207714a util: Update kdev_to_odev to respect BITS_PER_LONG
Depending on BITS_PER_LONG userspace representation of dev_t
may vary, so we need to choose proper encoding.

Signed-off-by: Igor Sukhih <igor@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-01 17:40:54 +04:00
Pavel Emelyanov
b978c6f873 util: Introduce buffer size for carrying /proc/self/fd/N path
There's ... a number of places where we want to do something
with /proc/self/fd/%d path. Each time we guess buffer size
that is enough for this. Make standard constant for this and
save some space on stack and drop args for some functions.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-15 13:59:59 +04:00
Pavel Emelyanov
8ff15e5c41 util: Make set_proc_mountpoint static
And rename it to better reflect what it does.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-11 20:02:33 +04:00
Pavel Tikhomirov
d8be68f3d1 posix-timer: Add restore structures
Signed-off-by: Pavel Tikhomirov <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-01 16:19:30 +04:00
Andrey Vagin
653053b40c proc: use vma flags for determing vmas with MAP_GROWSDOWN
When a kernel didn't show vma flags, we set MAP_GROWSDOWN for stack
vmas, but it's not reliable. E.g. thread stacks are mapped without
MAP_GROWSDOWN.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-21 19:03:57 +04:00
Pavel Emelyanov
e75148dc03 util: Move user-per-sec constant into util.h header
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 13:50:09 +04:00
Cyrill Gorcunov
6a0f92577c headers: util.h -- Move memory helpers to xmalloc.h
To reuse them outside of crtools code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 21:15:27 +04:00
Cyrill Gorcunov
1525447752 headers: Add err.h header
Instead of bloating util.h lets move ERR_
helpers to own err.h header. This allow
to reuse it where needed without util.h
inclusion.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 20:27:51 +04:00
Andrey Vagin
d274025e42 util: encode and decode errno into pointer
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-28 18:23:17 +04:00
Cyrill Gorcunov
401b4b89f1 util: Add read_fd_link helper
To fetch name of file opened from procfs.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-21 00:45:44 +04:00
Cyrill Gorcunov
19cc8a5eb2 Move BUG_ONs to include/bug.h
We will need futexes to use in PIE code but futex.h
uses BUG_ON helper, so to diet inclusions move BUG_ONs
code to include/bug.h.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-27 15:43:31 +04:00
Cyrill Gorcunov
fdfef4b485 headers: Change "../protobuf/" to "protobuf/"
No need to walk up the directories if we need
to include protobuf file. This was always a bad
use of ability to walk the filesystem from other
headers.

Same time we don't need -I$(SRC_DIR)/protobuf/
in general makefile anymore.

[xemul: Small fixlet in head Makefile, since patch
 it out-of-order]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-15 17:33:06 +04:00
Andrey Vagin
ce4c8c1d31 crtools: don't prevent to dump memory mappings on /dev/zero (v2)
Oracle has such mappings.

v2: add check, that a file is a character device

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:46:33 +04:00
Alexander Kartashov
6f61488f21 x86: moved x86-specific files into the directory arch/x86.
* The following files goes into the directory arch/x86/include/asm unmodified:
  - include/atomic.h,
  - include/linkage.h,
  - include/memcpy_64.h,
  - include/types.h,
  - include/bitops.h,
  - pie/parasite-head-x86-64.S,
  - include/processor-flags.h,
  - include/syscall-x86-64.def.

* Changed include directives in the source files that include the headers
  listed above.

* Modified build scripts to reflect the source moves.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:02:47 +04:00
Cyrill Gorcunov
830d92b0f0 headers: Unify include guards (in comments) and a few fixes
- fix names in comments
 - add empty lines where needed
 - fix rbtree.h
 - fix syscall-types.h

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-25 22:40:24 +04:00
Pavel Emelyanov
b4c2160449 hdrs: Fixup reinclusion preprocessor constants
Make them look like __CR_<smth>_H__ with

sed -e '1,2s/#\(ifndef\|define\) _\?_\?\(CR_\)\?/#\1 __CR_/' -e '1,2s/_H_\?_\?.*$/_H__/'

on every header file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-24 15:36:14 +04:00
Pavel Emelyanov
1a7c7d0404 fd: Consolidate . and .. checks in various readdir callers
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-29 21:12:51 +03:00
Pavel Emelyanov
ddf68b7940 restorer: Use the simple logging engine
Remove the restorer-log and link log-simple into restorer
blob. Now we can use the normal pr_foo API.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-07 21:11:49 +04:00
Andrey Vagin
cd2be93ba4 util: add a function for executing an extrenal tools (v2)
For executing an external tools we need to block a SIGCHLD
and to juggle file descriptors.

SIGCHLD is blocked for getting an exit code.

A problem with file descriptors can be if we want to set 2 to STDIN,
1 to STDERR, 0 to STDOUT for example.

v2: use helpers reopen_fd_as and move_img_fd

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-28 14:09:57 +04:00
Andrey Vagin
8e90ed8c4d util: add a function for running scripts
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:05:39 +04:00
Andrey Vagin
7a65c70158 util: add ability to change a file descriptor on procfs (v2)
When a pidns is dumped, crtools uses procfs from this pidns
for getting information about zombies.

v2: Use close_proc() instead of restore_proc_fd().
    A current proc will be opened again, if it's required.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-07 19:16:34 +04:00
Andrey Vagin
0ae2bad0c6 mm: mark a vma as stack, if a value of sp is in it
/proc/PID/maps can contains not up to date information about a stack vma.
A kernel marks a VMA as stack, if thread_struct->usersp is in it,
but usersp is updated, when a process calls a syscall.

This problem is occured, when we try to dump/restore a process in a loop.
When a restorer resumes a process, a restorer vma will be marked as stack.

A thread stack should not be marked as stack, because its vma is mapped
w/o MAP_GROWSDOWN.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-07 18:21:04 +04:00
Cyrill Gorcunov
d25520da35 log, restorer: Make write_ log helpers to honor logging level
Make restorer-log.c to be more similar to general log code.

 - Use current_logfd/current_loglevel variable names
 - Add ability to filter out messages which log level
   is not requested

For example, if a program get restorer without any log
level specified -- we restore it silently not printing
even a single message (if no error happened of course).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-05 17:16:38 +04:00
Andrey Vagin
67b6748f68 util: add ability to release a last piece from a shared pool (v2)
v2: s/shfree/shfree_last

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 17:23:27 +04:00
Pavel Emelyanov
9554b482c2 util: Introduce the shmalloc helper
This one allocates a memory, that will be shared (MAP_SHARED)
between all the subsequent children. This can now be just used
for fd resote, later it will be required at inet socket port
binding.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-16 20:41:34 +04:00
Stanislav Kinsbursky
f64633bd7d protobuf: service helper for show routine introduced
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-14 14:46:47 +04:00
Pavel Emelyanov
64149b40f2 code: A little but more checkpatch fixes over code
There are more in test/ (and checkpatch.pl crashes in the middle =),
but seem to be all.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-11 22:19:34 +04:00
Cyrill Gorcunov
4806e1395f protobuf: Convert vma_entry to PB format v3
v2:
 - Use regular uint types in message proto
 - Use PB engine for "show"
v3:
 - drop usage of temp. variable in prepare_shmem_pid

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 12:43:36 +04:00
Pavel Emelyanov
c69d18eada util: More traditional xfree macro
Using do { } while (0) for statemets macro like this is a good practice.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-11 14:45:08 +04:00
Pavel Emelyanov
57095eb946 util: Helper for reading a string from image
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-27 20:57:35 +04:00
Andrey Vagin
4ebc875995 util: add ability to change a proc mount point (v2)
v2:  rework this by using openat() and service fds for proc root.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:17:16 +04:00
Andrey Vagin
0eb0391ce0 util: do a control shot from BUG_ON
SIGABRT may be blocked. We do that in the restorer.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-01 18:44:16 +04:00
Stanislav Kinsbursky
41195598cf parasite: remove excessive header deps from parasite.h and friends
The task is not complete - this is just a part of what have to be done. I.e.
looks like a lot of excessive deps can be fixed.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-30 12:50:18 +04:00
Cyrill Gorcunov
62ee701c89 Use /proc/pid/smaps for VMA parsing v2
This allows us to detect nonlinear mappings.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-11 17:41:05 +04:00
Pavel Emelyanov
50ff1438b0 anon: Factor out checking for anon inode link types
Funny, but kernel reports some of them with []-s and some (well,
ok, inotofy only) without...

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 14:22:18 +04:00
Cyrill Gorcunov
9ea069d2c9 proc: Add parse_mountinfo helper
To restore inotify we need to know the
mount point device numbers, so this helper
parses /proc/pid/mountinfo file for that.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 14:00:28 +04:00
Cyrill Gorcunov
49166b206b util: Add is_anon_inode helper
Will need it for eventpoll/eventfd/inotify.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 13:59:43 +04:00
Cyrill Gorcunov
6e7c9ea84d util: Extend reopen_fd_as_safe
Our loggin engine prints file:line only at invoke point,
so it's unable to see where exactly reopen_fd_as_safe is
failed.

With this patch the output is more human readable

 | Error (util.c:96): fd 7 already in use (called at files.c:359)

Ideally we need full backtrace here, but it's different task.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 12:35:51 +04:00
Pavel Emelyanov
14451ed3ce util: Add fn for copying file from one fd to another
Will be required to dump completely unlinked files.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 17:52:35 +04:00
Pavel Emelyanov
488790b677 util: Remove dead code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 21:17:44 +04:00