This helper will cause BTRFS engine to collect all subvolumes.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
If we fail in xmalloc the function occasionally return
0 meaning that everything is fine. Don't do that, wait
until routine complete.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
We will need it for additional handling once parsing
of mount entry is complete (in particular btrfs requires
additional processing to figure out subvolumes names).
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
crtools.h is too heavy to be included in many sources
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This vma looks like VSYSCALL on x86. We don't need to dump and restore it.
Currently this vma is dumped and restored as a private vma, but it is not
remmaped in a correct place:
Restore
--- dump/pipe00/6392/1/dump.maps 2013-09-23 12:49:19.436816192 +0000
+++ dump/pipe00/6392/1/restore.maps 2013-09-23 12:49:20.276766356 +0000
@@ -6,5 +6,6 @@ e05000-e26000
4009d000-4009f000
400a0000-400aa000
400b8000-401e7000
+b6d6f000-b6d70000
be838000-be859000
ffff0000-ffff1000
ERROR: Sets of mappings differ:
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parse_thread allocated a buffer for threads and then it initialized read
pid for each thread.
Now we want to use it on restore and in this moment we already have
a buffer with initialized virt pid-s, so we need to initialize read
pid-s only.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
It will be used in cr-restore.c for stopping threads on the exit from
sigreturn.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The kernel logic is described in v2.6.36-rc1-161-g7798330:
"If we've split the stack vma, only the lowest one has the guard page."
https://bugzilla.openvz.org/show_bug.cgi?id=2715
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
timer is not freed in case of eof.
CID 1042301 (#1 of 1): Resource leak (RESOURCE_LEAK)
15. leaked_storage: Variable timer going out of scope leaks the storage it points to.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parse_posix_timers should not call ferror if fopen returned NULL.
Reported-by: Adrian Reber <adrian@lisas.de>
Cc: Pavel Tikhomirov <snorcht@gmail.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
1st stage is -- creating the timers. It may fail if kernel
allocated IDs in a manner we don't expect or runs out of
memory.
2nd stage is -- arm the timers. It cannot fail, since we've
validated the timespecs in advance and should happen after
we've waited for all the other tasks to complete the restore.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The [vdso] mark in procfs output is not reliable,
so since we know which prot it should has, escape
obvious mishints.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
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>
The size of vma can be changed after parsing flags. For example we need
to add a guard page for vma with MAP_GROWSDOWN.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
when is_blocked is seted, we should free file_lock
Signed-off-by: Libo Chen <libo.chen@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
"crtools check" crashes on ubuntu 12.10
(00.011275) Error (proc_parse.c:1049): No records of type 6 found in fdinfo file
(00.011281) Error (proc_parse.c:1052): parse_fdinfo: error parsing [flags: 02 ] for 6 : Operation not permitted
*** glibc detected *** /home/vvs/devel/criu/crtools/crtools: double free or corruption (top): 0x000000000068a5a0 **
Signed-off-by: Vasily Averin <vvs@parallels.com>
diff-double-fclose-in-parse_fdinfo
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
One of such things we use right now is the device for anon shmem
mappings backing. In the furure this can be extended to check for
various kernel features.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
On error paths we don't explicitly close procfile.
CID 996191 (#5 of 6): Resource leak (RESOURCE_LEAK)
22. leaked_storage: Variable "f" going out of scope leaks the storage it points to.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
mnt_entry contains a few strings and they should be release too
CID 996198 (#4 of 4): Resource leak (RESOURCE_LEAK)
20. leaked_storage: Variable "pm" going out of scope leaks the storage
it points to.
CID 996190 (#1 of 1): Resource leak (RESOURCE_LEAK)
13. leaked_storage: Variable "new" going out of scope leaks the storage
it points to.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
CID 996207 (#1 of 1): Out-of-bounds access (OVERRUN)
5. alloc_strlen: Allocating insufficient memory for the terminating null of the string.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
I will have to push some sort of map of pages to dump into parasite.
For this, I need to have estimation of how much memory I'd need for
than in parasite args. These two values will help with it.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Right now when we collect list of vmas we need to know the
number of elements in it. In the future I will need to know
more, so it makes sense to create a vmas-list object for it.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
They are really depends on CPU we're running on.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
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>
We collect all file locks to a golbal list, so we can use them easily
in dump_one_task. For optimizaton, we only collect file locks hold by
tasks in the pstree.
Thanks to the ptrace-seize machanism, we can aviod the blocked file lock
issue, makes the work simpler.
Right now, the check handles only one situation:
-- Dumping tasks with file locks hold without the -l option.
This covers for the most part. But we still need some more work to make
it perfect robust in the future.
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
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>
This removes code duplication. There is no strong
need for free_fhandle but I decided to add it to
be consistent with alloc/free handlers.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This patch is intended to reduce the usage of the macro P() since
integer size mismatches sometimes may be fixed by this type generalization.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
* 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>
This patch add ability to test /proc/cpuinfo data
we're interested in at the moment.
The code provides the following functionality
- cpu_init, to parse cpuinfo and check if the
host cpu we're running on is suitable enough
for FPU checkpoint/restore. If FPU present then
there must be at least fxsave capability present
- cpu_set_feature/cpu_has_feature helpers which
provides to test certain bits and set them where
needed (we need to set bits when parse cpuinfo)
Note, we reserve space for all cpuinfo bits known
by the kernel at moment, while use only three FPU
related bits for a while. This is done because we might
need to use or find out other features in future.
After all it's just 40 bytes of memory needed to keep
all possible bits.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Since fdinfo patches were merged to -mm
tree the output format has been slightly
changed. So update our tool accordingly.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Same as eventpoll -- we might have no watchee assigned
but only inotify descriptor created.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Linux kernel emulates anon-shared mappings by mapping internal
tmpfs file in. We try to detect this by checking that the file
under map is such, but do it with error -- major == 0 check is
wrong, as regular tmpfs file can be such as well as btrfs or
ecryptfs can screw things up.
The only working way of doing this is to get the dev_t of this
internal tmpfs mount.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Three parts.
Proc: open of map_files' link doesn't work on sockets. We fstatat
it and check that it's a socket (it will be packet), then save
the socket inode on vma_area.
Dump: we resolve socket inode to socket id and save it on vma.
We use id, not inode, since on restore we'll have to mmap some
opened file, not just abstract socket with inode.
Restore: when reading vma-s we just need to find out on what fd
the respective packet socket is opened (i.e. -- no map-and-close
sockets supported by now) and dup() it to let restorer mmap it
back.
All this make it possible to c/r the tcpdump tool!
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>