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

120 Commits

Author SHA1 Message Date
Andrey Vagin
e027f116e4 plugin: add a function to get a descriptor to the image dir
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-19 21:49:39 +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
Andrey Vagin
4850fd94a8 crtools: move cr_options in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 18:17:52 +04:00
Andrey Vagin
0d1dfc2e08 crtools: move all stuff about vma together
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 12:43:49 +04:00
Andrey Vagin
824403a009 crtools: create new header for servicefd stuff (v2)
v2: generate patch relative to the official git.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 12:43:02 +04:00
Pavel Emelyanov
297360ef7d rst: Switch shmalloc allocator to use rst-malloc
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-02 01:04:07 +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 Emelyanov
cdce5d216d util: Make set_proc_fd report success/error only
Returning the new proc fd value is useless.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-11 19:51:02 +04:00
Cyrill Gorcunov
73c5a0f965 dump: Introduce "post-dump" script action
This is usefull if one needs to do some final action before checkpoint
is complete. For example in case of online migration one may provide
a script which would check the restore procedure on remote note
ended without errors, thus the script returns zero code and criu
simply kills running instance of application.

In turn, if migration failed, the script can return nonzero code
and criu won't kill the application but continue its execution
instead.

https://bugzilla.openvz.org/show_bug.cgi?id=2583

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-22 19:35:28 +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
Cyrill Gorcunov
9cdb9102fa util: Make read_fd_link to return the length of the link read
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-07 22:42:57 +04:00
Cyrill Gorcunov
1ead3d79f7 util: Check for overflow in read_fd_link
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-07 22:42:14 +04:00
Kir Kolyshkin
abe3c594de Fix CRTOOLS_SCRIPT_ACTION name
... in quite a few places.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-02 22:48:07 +04:00
Cyrill Gorcunov
921dbf23de Don't use \Newline in pr_perror
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-02 22:44:24 +04:00
Kir Kolyshkin
41c7ca8218 Fix typos in comments
This is less useful than fixing typos in output messages, but anyway.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-15 12:46:46 +04:00
Kir Kolyshkin
d90d4b1b88 Fix typos in log messages
Someone has to do it, right?..

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-15 12:46:25 +04:00
Cyrill Gorcunov
4dac517b00 util: read_fd_link -- Drop redundant \n in pr_perror message
pr_perror adds \n on its own, fix this typo.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-10 01:23:15 +04:00
Cyrill Gorcunov
6140f67326 util: Use read_fd_link helper in is_anon_link_type
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-21 00:45:45 +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
Andrey Vagin
bce89dba4b restore: reserve the service descriptor for a control tty
I'm really lucky.

prepare_ctl_tty:
	e->fd           = get_service_fd(CTL_TTY_OFF); // -1 as fd is not set

send_fd_to_self:
if (dup2(fd, dfd) != dfd) { // tries to install sfd, but -1 == -1

tty_restore_ctl_terminal:
	if (!is_service_fd(fd, CTL_TTY_OFF))
		return fd == get_service_fd(type); // -1 = -1

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-18 23:04:09 +04:00
Alexander Kartashov
3bb6d9f4fb cr: use the length modifier %z to print an integer of the type size_t
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:38 +04:00
Alexander Kartashov
3c16edc0bd cr: generalized format strings
This patch replaces the format specifier %ld with PRIx64
in the following places:

* the format string argument of the functions scanf() and printf(),
* in the macros GEN_SYSCTL_*_FUNC.

We need explicit specification of the integer size there.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 19:20:08 +04:00
Andrey Vagin
f2a46c3d00 util: check that stdin are unused before closing
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-15 18:52:59 +04:00
Andrey Vagin
4ea6214391 crtools: add ability to create and close a service fd (v3)
A service fd should be created, otherwise get_service_fd returns -1.

This patch removes this functionality from other subsystems and
allows to clone service descriptors.

v2: rename open_service_fd to install_service_fd
v3: two patches were merged for bisecting

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-12 00:54:37 +04:00
Andrey Vagin
e6106956af util: clone service descriptors, if fd tables are shared for tasks (v3)
It looks like a namespace for service descriptors.
It will be used for restoring tasks with shared fd tables.
Service descriptors should be own for each process.

v2: clone_service_fd doesn't know about sub-systems like log, proc, etc
v3: Don't try to find a free name-space.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-12 00:54:36 +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
Pavel Emelyanov
86886b6376 util: Fix vma printing message (pass 2)
Remove the ?: ladder, replace it with opt string directly
get from status flags.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-29 18:16:00 +03:00
Pavel Emelyanov
15cfa1b053 util: Fix vma printing message (pass 1)
Use %#x for hexademical fields, fix names to more human-readable.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-29 17:54:44 +03:00
Andrey Vagin
13a7498c2a crtools: add EOL to error messages
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-23 16:43:33 +04:00
Pavel Emelyanov
3246f2399a util: Fix vma shmid printing format
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-02 14:46:51 +03:00
Andrey Vagin
d33d2290bd files: rework a function for closing all descriptors (v2)
It reads /proc/PID/fd and close all descriptors except service fds.

v2: s/is_one_of_service_fds/is_any_service_fd

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-29 11:01:53 +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
Cyrill Gorcunov
45cc85eea4 Speed up service-fd retrieval
We're using get_service_fd in file engine,
better to make it fast. This patch caches
the limits system provides us, instead of
calling getrlimit() every time.

This patch introduces is_service_fd helper
which will be used instead of get_service_fd
where it make sense.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 14:45:06 +04:00
Andrey Vagin
c627c03714 mm: taking into account a gurad page to find a space for a restorer vma
Actually a gurad page is a part of a stack vma and we don't want to remap
it by a restorer vma.

The crtools on restore find a place for a restorer vma, which will not
intersect with other VMAs. A guard page is a part of a stack VMA, if
we don't take into account it, we can place the restorer VMA on it and
that case is a bug.

Would not this lead to situation where we expand stack manually? Every new
c/r cycle add one page to the bottom of stack, no? No:

strace:
mmap(0x5f4d0e0cc000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_GROWSDOWN, -1, 0) =
0x5f4d0e0cc000

/proc/PID/maps:
5f4d0e0cd000-5f4d0e0cd000 rw-p 00000000 00:00 0
.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-10 14:35:38 +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
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
Pavel Emelyanov
12a0462f7e util: Shorten array for anon_inode link checking
Strictly speaking the fd link can point to PATH_MAX string, but for the sake of
is_anonfd_link 32 bytes is enough -- even if the target string is longer it will not
match the required anon_inode:xxx string.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-11 12:58:46 +04:00
Pavel Emelyanov
611b97248b img: Move all the img files management code to image.c
And clean util.c and crtools.c from image manupulation code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-28 03:12:08 +04:00
Cyrill Gorcunov
582954685b Escape using unsafe sprintf helper
Util it's very critical for speed we should
not use unsafe sprintf helper, we're root-granted
program and must be as safe as possible.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-20 15:04:51 +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
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
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
Konstantin Khlebnikov
0ff0943eb4 Drop <sys/user.h> to fix PAGE_SIZE declaration
On some systems PAGE_SIZE is declared as sysconf(_SC_PAGESIZE) in <sys/user.h>
this is non-constant expression, so it cannot be used in type declarations.

This breaks compilation with a very non-obvious error message:

  CC       parasite-syscall.o
In file included from parasite-syscall.c:30:0:
./include/parasite.h:90:8: error: variably modified ‘fds’ at file scope

crtools doesn't uses anything from <sys/user.h>, so we can drop its usage.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 14:38:49 +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
Kinsbursky Stanislav
231db3f80d output: add "0x" to hex prints manually
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 12:34:01 +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
705bf5aba6 img: Hide image dir fd into util.c
No image copy occurs since 2b175282, so this
fd can be hidden. Thus fixind the FIXME near it :)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 21:39:10 +04:00