Commit graph

3894 commits

Author SHA1 Message Date
Andrey Vagin
8a6c150223 zdtm: don't write more than buffer size
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 18:28:00 +04:00
Ruslan Kuprieiev
579e55fa0d libcriu: add work_dir support
As we've added work_dir_fd to RPC, lets add support for it to libcriu.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 18:27:20 +04:00
Ruslan Kuprieiev
1775416c4f service: Add work_dir support
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 18:24:35 +04:00
Tikhomirov Pavel
2c7fb879ae chdir: need to check return value
otherwise it won't compile:

util.c: In function ‘cr_daemon’:
util.c:594:8: error: ignoring return value of ‘chdir’, declared
with attribute warn_unused_result [-Werror=unused-result]
   chdir("/");
        ^

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 14:05:35 +04:00
Pavel Emelyanov
d8071ffd1a stats: Fix restore pages stats
We errorneously report nr_compared as total number of restored pages.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 14:03:10 +04:00
Pavel Emelyanov
b745ae83b3 vma: Backward compatible VMA restore
If we've found zero VMAs in MmEntry try to look for
VMAs in vma-.img image file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 12:04:33 +04:00
Pavel Emelyanov
8f7bae2cfc pb: Don't crash when showing empty repeated field
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 11:52:55 +04:00
Pavel Emelyanov
54f4f889a5 mm: Move VmaEntries from separate image into Mm one
When writing VMAs we perform too many small writes into vma-.img files.
This can be easily fixed by moving the vma-s into mm-s, all the more
so they cannot be splitted from each other.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 11:44:05 +04:00
Pavel Emelyanov
72e462ad67 mm: Read mmentry early
We'll merge mm and vma images, so mm should be read in the
same place where vmas are.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 11:44:04 +04:00
Pavel Emelyanov
ed836740ba vma: Don't copy VmaEntry on vma_area
After previous patch is't now possible.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 11:44:02 +04:00
Pavel Emelyanov
eb1ae0a025 vma: Turn embeded VmaEntry on vma_area into pointer
On restore we will read all VmaEntries in one big MmEntry object,
so to avoif copying them all into vma_areas, make them be pointable.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 11:44:01 +04:00
Pavel Emelyanov
6da13c687f dump: Merge mm and vmas dumping functions
The plan is to merge vma images into mm ones (see further
patching), so prepare the dumping code for that.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 11:43:59 +04:00
Pavel Emelyanov
6a5188a2cd vma: Use vma_area_is helper where appropriate (p2)
Lost from c8d5f1a2

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 11:43:22 +04:00
Andrey Vagin
3d8f7b07b3 zdtm: add a bit more messages in error cases
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 00:20:09 +04:00
Andrey Vagin
0ad373ba6c make: config add test for ptrace_peeksiginfo_args
Currently we check PTRACE_PEEKSIGINFO and if it's defined in a system
header, we suppose that ptrace_peeksiginfo_args is defined there too.

But due to a bug in glibc, this check doesn't work. Now we have F20,
where ptrace_peeksiginfo_args is defined in sys/ptrace and F21 where
it isn't defined.

commit 9341dde4d56ca71b61b47c8b87a06e6d5813ed0e
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Sun Jan 5 16:07:13 2014 -0500

    ptrace.h: add __ prefix to ptrace_peeksiginfo_args

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-03 23:36:12 +04:00
Pavel Emelyanov
446fdd7200 rst: Collect VmaEntries only once on restore
Right now we do it two times -- on shmem prepare and
on the restore itself. Make collection only once as
we do for fdinfo-s -- root task reads all stuff in and
populates tasks' rst_info with it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-03 23:35:03 +04:00
Pavel Emelyanov
0786f831d7 mem: Move shmem preparation routine and rename
We'll collect VmaEntries early before fork.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-03 23:34:12 +04:00
Cyrill Gorcunov
c643ed76e7 proc_parse: Speedup VMA range parsing
In /proc/<pid>/smaps/ output we may omit testing
for capital hex letters, since we know the format
kernel provides.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-03 18:26:24 +04:00
Pavel Emelyanov
c8d5f1a215 vma: Use vma_area_is helper where appropriate
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-03 17:22:03 +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
593cb59a63 pagemap: Use pread to read pagemap entries
When reading pagemaps, we read it from specific position. To
do it, we called lseek, then read. Fortunetely, there's a
syscall that does both things in one call -- pread. Since
we don't need to keep pagemap's position for further reads,
it perfectly suits our needs.

This removes 75% of lseek calls when dumping basic container.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-03 00:30:02 +04:00
Pavel Emelyanov
608db864a3 vmas: Don't call stat on vm file twice
When parsing mappings in proc, we fstat vm file, later,
when dumping it, we stat it again to fill fd_parms.
The 2nd stat is not required, we can keep the stat in
vma_area.

This removed 35% of all stat calls on dump of basic container.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-03 00:18:32 +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
e4a2618724 pb: Number PB_ constants
For easier logs-to-constant eyes mapping.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-02 01:20:49 +04:00
Pavel Emelyanov
ba58e4704a protobuf: Use writev for writing image entries
Two writes are slower. This halves the amount of write syscalls
and reduces dump time of a basic container on 5%.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-31 20:51:32 +04:00
Pavel Emelyanov
740eb9c101 proc-parse: Don't open and stat every single map_files link
Quite a lot of VMAs in tasks map the same file with different
perms. In that case we may skip opening all these files, but
"borrow" one from the previous VMA parsed.

There's little sense in seeking more that just previous VMA,
as same files are rarely (can be though) mapped in different
locations.

After this on a basic Centos6 container the number of opens and
stats in this function drops from ~1500 to ~500.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-31 20:31:06 +04:00
Pavel Emelyanov
bbab13ebdb proc: Helper for opening vma's file
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-31 20:30:47 +04:00
Pavel Emelyanov
446ab1fc64 irmap: Don't let proc-parse free handle's mem before caching
Bug was introduced by on-disk-irmap-cache patch. The proc-parse
routine allocates memory for handle, calls ->cb then frees handle.

The problem is that the cb in case of pre-dump saves the handle
for future reference. So, in this future handle's mem happen to
be corrupted.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-31 08:50:28 +04:00
Pavel Emelyanov
c4b5a9d5b0 vma: Don't close socket's inode as fd
The vm_socket_id is union with vm_file_fd and calling
close on it is wrong.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-31 03:14:46 +04:00
Andrey Vagin
7051e2e92d util: apply PME_PFRAME_MASK to get pfn
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-31 15:11:28 +04:00
Pavel Emelyanov
a90613cf9d mem: Fix zero_page_pfn type
It is compared to u64, so should be such as well

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-31 00:08:47 +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
fe1d6d2b2d irmap: Try to load irmap cache from parent as well
If we make workdir coincide with images dir, the irmap
cache will be put in parent images for subsequent dump-s.
Try to load it from there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 17:00:21 +04:00
Pavel Emelyanov
ab57e56202 stats: Add irmap resolve time
It's useful to know this value.

W/o cache (first pre-dump) on minimal container the irmap
resolve time is ~0.2 sec. With cache (next pre-dumps or
final dump) on the same container the irmap resolve time
is 10 times less.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 16:20:16 +04:00
Pavel Emelyanov
cc918897b0 irmap: Introduce irmap on-disk cache
When dumping fsnotifies we may go to irmap to get inode->path
mapping. The irmap engine scans FS (in hinted locations) to
get one and it is slow even though we scan only part of the FS.

Since the above scanning is done while tasks are frozen the
freeze time goes up :(

Improve the situation by generating irmap cache in working dir
at pre-dump when tasks get unfrozen.

The on-disk irmap cache is PB file, it sits in -W directory
and can be loaded on dump/pre-dump start in memory. When
resolving the inode->path mapping irmap may meet these entries,
revalidate them and potentially save time.

After pre-dump the (re-)collected irmap data is written back
to irmap cache image. Typically entries written back are the
same read in on cache load.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 16:20:16 +04:00
Pavel Emelyanov
cc731cb6da irmap: Revalidate irmap entries if required
We will load some irmap entries in cache from image file,
thus producing potentially stale data in irmap cache. To
handle this, make it possible to mark the entries with
need-revalidation mark and do fstat + numbers comparison
when meeting the entry in cache.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 16:20:16 +04:00
Pavel Emelyanov
529f1a099e img: Needed declarations for irmap-cache image file
The irmap-cache is PB-file (like the stat-* ones).
See commtns in next patches for more details.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 16:20:15 +04:00
Pavel Emelyanov
751856c8b8 files: Pre-dump file descriptors
We will generate some info about file-descriptors at that
stage. For now these pre-dumped ones would be fsnotifies,
so the pre-dump of a single fd is written as simple as
possible, but enough for that type of FDs pre-dump.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 16:20:15 +04:00
Pavel Emelyanov
84ebc64b1f pre-dump: Collect mount info, root and nsmask
Well, we want to pre-dump files (fsnotifies), for that we
will need mountinfo-s and root, and for the latter -- the
current ns mask.

The problem with current ns mask is that its generation is
incorporated into ns IDs generation and dumping. And since
the ids dumping is not performed on pre-dump, let's just
provide a helper for ns-mask generation.

Strictly speaking, the whole ns-mask idea is not great, but
it's to be fixed later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 16:20:15 +04:00
Pavel Emelyanov
c18c733b7c proc-parse: Parse pid's fdinfo entries
The existing code opens "self" and parses what's in there,
just twist the code a little to accept generic pid.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 16:20:15 +04:00
Pavel Emelyanov
28ec90b20f service: Implement pre-dump request support
This works as multi-req thing -- caller issues the
pre-dump request, criu serves it and sends result back.
Then service waits for the next request on the same
session, client doesn't have to re-connect back.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 15:58:48 +04:00
Pavel Emelyanov
0091f81906 service: Start page-server request implementation
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 15:58:46 +04:00
Pavel Emelyanov
9753501297 rpc: Introduce CLI's --action-script analogue
Service shouldn't call client provided scripts, as it
creates a security issue (client may be unpriviledged,
while the service is).

In order to let caller do what it would normally do with
criu-scripts, make criu notify it about scripts. Caller
then do whatever it needs and responds back.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 15:58:45 +04:00
Pavel Emelyanov
3587dc1ff7 rpc: Add more stuff to RPC messages
This includes pre-dump and page-server actions and
arguments for memory tracking and page-server.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 15:58:44 +04:00
Pavel Emelyanov
f200b7a990 page-server: Start using new cr_daemon routine
After this the called of cr_page_server gets controll
back with the server's pid.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 15:58:43 +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
040fe7712f pre-dump: Enforce track-mem and leave-running in cr_pre_dump_tasks
Service will call the pre-dump routine, so this is factoring out
enforcin options for CLI and RPC.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 15:58:39 +04:00
Pavel Emelyanov
e7ed1bc31a service: Helper for sending generic RPC errors
We'll need such further.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 15:58:30 +04:00
Andrew Vagin
066609769a zdtm: add more logging messages
Tests fail sometimes, but logs don't contain enough information:
Execute zdtm/live/static/umask00
./umask00 --pidfile=umask00.pid --outfile=umask00.out --mask=0345
make[3]: *** [umask00.pid] Error 1
ERROR: fail to start zdtm/live/static/umask00

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 15:12:56 +04:00
Andrey Vagin
10bfe8fae8 maps007: check "stop" with "delta"
We don't need to wait if a stop signal has been received.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 15:12:19 +04:00