2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00
Commit Graph

2733 Commits

Author SHA1 Message Date
Pavel Emelyanov
64249d5a8a mem: Move memory dump routines from parasite-syscall.c into mem.c
There's going to be a LOT of code in there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-08 17:39:21 +04:00
Pavel Emelyanov
e44f10a6b4 parasite: Externalize some parasite-executing fns
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-08 17:38:49 +04:00
Pavel Emelyanov
4edabd3d4f mem: Don't export parasite_mptotect_seized
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-08 17:28:30 +04:00
Cyrill Gorcunov
f6303de7ca sysctl: Don't forget to close fds
In case if openat/open call returned fd = 0,
don't forget to close it on routine exit,
ie just use close_safe macro.

Not a big deal since the descriptors get closed
once program finish execution but still.

#CID 996183 Resource leak

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:23:17 +04:00
Andrey Vagin
a520b1b8cd namespaces: close fd on the source netns in restore_ns
It's opened in switch_ns.

CID 996194 (#3 of 5): Resource leak (RESOURCE_LEAK)
11. leaked_handle: Handle variable rst going out of scope leaks the handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:22:36 +04:00
Andrey Vagin
055b937226 page-pipe: fix memory leak on error path
CID 996197 (#1 of 1): Resource leak (RESOURCE_LEAK)
8. leaked_storage: Variable ppb 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>
2013-04-05 08:21:45 +04:00
Andrey Vagin
c518d47ad3 files-reg: don't forget to close fd in case of error
CID 996201 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_handle: Handle variable "fd" going out of scope leaks the handle.

CID 996202 (#1 of 1): Resource leak (RESOURCE_LEAK)
6. leaked_handle: Handle variable "fd" going out of scope leaks the handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:21:30 +04:00
Andrey Vagin
510b0dacb4 cr-restore: fix error handling and memory leak in read_vma
CID 996203 (#1 of 1): Resource leak (RESOURCE_LEAK)
15. leaked_storage: Variable "vma" 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>
2013-04-05 08:21:05 +04:00
Andrey Vagin
c9c1ec7b44 cr-dump: fix memory leak in fill_zombies_pids
CID 996204 (#1 of 1): Resource leak (RESOURCE_LEAK)
11. leaked_storage: Variable "ch" 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>
2013-04-05 08:20:36 +04:00
Andrey Vagin
50e94780f4 cr-dump: core_entry_free should free core
CID 996205 (#1-2 of 2): Resource leak (RESOURCE_LEAK)
14. leaked_storage: Variable "core" 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>
2013-04-05 08:19:47 +04:00
Andrey Vagin
30a7de3513 cr-dump: move core_entry_free closer to core_entry_alloc
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:19:24 +04:00
Andrey Vagin
5d244ca1bd cr-check: don't forget close a test socket
CID 996206 (#3 of 3): Resource leak (RESOURCE_LEAK)
8. leaked_handle: Handle variable "sk" going out of scope leaks the handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:19:05 +04:00
Andrey Vagin
4ef152447c proc_parse: allocate memory for the terminating null of the string
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>
2013-04-05 08:18:57 +04:00
Cyrill Gorcunov
9c3a88c7b1 mnt: Add simfs entry to a list of supported fs
simfs is used in OpenVZ containers, so lets understand it
and don't fail on its meeting.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:08:33 +04:00
Cyrill Gorcunov
396a08eb95 make: Don't generate tags/cscope for tools/ and test/
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:08:32 +04:00
Cyrill Gorcunov
c0771a01f6 arch: x86 -- Include only asm/int.h in fpu.h
No need to include all types here. And this allows
to reuse this header outside of crtools code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:08:31 +04:00
Alexander Kartashov
4200d42ee6 session02: hard-code the value of the macro CLONE_STACK_SIZE
The macro PAGE_SIZE is declared in the following way in Debian:

 #define PAGE_SIZE               (sysconf(_SC_PAGESIZE))

that makes it impossible to use the macro as the size of
the array clone_args::stack since this generates the following error:

cc -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -iquote ../../lib/arch/arm/include -I../../lib   session02.c ../../lib/libzdtmtst.a   -o session02
session02.c:70:7: error: variably modified 'stack' at file scope

Cc: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:07:20 +04:00
Alexander Kartashov
3ca29f7046 sk-packet.c: fixed a format string warning on ARM
Use a PRI* format specifier to convert an integer of known size
to a string.

Cc: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:07:10 +04:00
Andrey Vagin
0b6548229a pstree: fix error handling
pstree.c:273:3: warning: Value stored to 'ret' is never read
                ret = 0;
                ^     ~

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:31 +04:00
Andrey Vagin
9f994b8179 files: handle errors from fcntl()
files.c:159:21: error: comparison of unsigned expression < 0 is always
false [-Werror,-Wtautological-compare]
        if (p->fown.signum < 0) {
            ~~~~~~~~~~~~~~ ^ ~

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:30 +04:00
Andrey Vagin
0ebc4f058c cr-restore: remove extra initialization of variables
cr-restore.c:1795:2: warning: Value stored to 'restore_task_vma_len' is
never read
        restore_task_vma_len    = 0;
        ^                         ~
cr-restore.c:1796:2: warning: Value stored to 'restore_thread_vma_len'
is never read
        restore_thread_vma_len  = 0;

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:29 +04:00
Andrey Vagin
e08562c277 ipc_ns: free allocated objects at the end
ipc_ns.c:464:3: warning: Memory is never released; potential leak of
memory pointed to by 'values'
                return;
                ^
1 warning generated.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:28 +04:00
Andrey Vagin
7eabe41fb8 parasite: don't set ret if it is not going to be read
pie/parasite.c:308:3: warning: Value stored to 'ret' is never read
                ret = -1;

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:26 +04:00
Andrey Vagin
d1787c84a0 sockets: free all allocated objected in case of any error
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:25 +04:00
Andrey Vagin
06d8c36c56 socket: handle errors of xmalloc
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:24 +04:00
Andrey Vagin
9db8df3dec sk-packet: handle errors of xmalloc
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:23 +04:00
Andrey Vagin
c9b9aad265 mount: rollback and return a negative value in case of errors
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:23 +04:00
Andrey Vagin
caa1c406fa cr-show: avoid double free for pstree items
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:22 +04:00
Andrey Vagin
a6c5953a80 clang: add an exception for BUG_ON_HANDLER
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:21 +04:00
Andrey Vagin
f54f9f0efa bitopts: add a size sufix for ambiguous instructions
clang requires that.

In file included from arch/x86/cpu.c:9:
arch/x86/include/asm/bitops.h:24:15: error: ambiguous instructions
require an explicit suffix (could be 'btsw', 'btsl', or 'btsq')
        asm volatile("bts %1,%0" : ADDR : "Ir" (nr) : "memory");

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:20 +04:00
Andrey Vagin
f238d56661 make: allow to change a compiler
clang-analyzer sets the environment variable CC
scan-build -plist-html --use-analyzer /usr/bin/clang make

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:19 +04:00
Pavel Emelyanov
75d8b81fd1 ipc: Check for IPC namespace to be dumped when such mapping is
If any task has a sysvipc mapping we should make sure, that the
ipc namespace is dumped as well. Otherwise after restore the task
will die.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 13:09:59 +04:00
Pavel Emelyanov
09ebdd4534 sockets: Make crtools check report error when DIAG is incomplete
Absense of packet and netlink diag is OK at dump -- we can be on
older kernel and will fail later if _really_ need these sockets.

During check stage all diag is expected to be in place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 13:08:28 +04:00
Pavel Emelyanov
7bdba0f745 unix: Add _all_ peers into must-dump list
When dumping a unix socket we must make sure, that all connections
are dumped or -x option is used. Currently only peers with non-matching
ids are added into check. Fix this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 23:27:45 +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
6971b8effc headers: types.h -- Move uX types to int.h header
This allows to use it in external projects outside of
types.h header, moreover it's close to what kernel
does too.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 20:31:51 +04:00
Cyrill Gorcunov
7aae1934d3 headers: types.h -- Move BITS_PER_LONG to own header
This diet types.h and allows to include BITS_PER_LONG
only where really needed. It makes BITS_PER_LONG definition
close to one used in kernel.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 20:31:41 +04:00
Cyrill Gorcunov
0109ea2bdb headers: types.h -- Rename BITS_PER_ULONG to BITS_PER_LONG
Lets stick to names used in kernel.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 20:29:32 +04:00
Cyrill Gorcunov
3165fd7886 headers: list.h -- Add hlist helpers
hlist is suitable for hash operations so
extent list.h code. I need it for converter
and this allow me to reuse this header.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 20:29:25 +04:00
Cyrill Gorcunov
7db78063f8 headers: image.h -- Drop asm/types.h inclusion
This header consists of a number of constants
and a few macro helper. No need to make it
asm/types.h dependant. Instead only include
<stdbool.h> for bool definition as required
by forward fdinfo_per_id (I think this declaration
should live in somewhere else place, not sure
where yet, so I left it untouched).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 20:29:15 +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
Cyrill Gorcunov
fd3f33f5d2 headers: image.h -- Drop unused entries
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 20:27:24 +04:00
Pavel Emelyanov
a6b257f0c2 log-simple: Use buffering before output to log file
Multi-task/thread apps spoil log as simple logger does
char-by-char output.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 20:12:12 +04:00
Pavel Emelyanov
c5aa77f88b tcp: Use protobuf showing fn for tcp-stream images
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 14:18:11 +04:00
Pavel Emelyanov
63270e8d9f show: Show per-task fdinfo in -D/-p output
This info is not in per-ID file, not per-PID, so need special care.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 12:09:40 +04:00
Pavel Emelyanov
73d7e283a7 show: Filter -D output with --pid option
Show only image info relevant to given pid. Also reuse
the introduced --pid argument for exec action.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 11:58:15 +04:00
Pavel Emelyanov
6241a057b8 show: Beautify -D mode show
Print delimiters and image names for easier reading of the output.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 11:30:14 +04:00
Pavel Emelyanov
a0ce796734 show: Fix -D mode showing
Threads' IDs were not initialized on img load.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 11:21:47 +04:00
Andrey Vagin
58f0955d81 zdtm: each test file name should contain a test name
It's required for per-test cleaning.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-01 20:12:04 +04:00
Andrey Vagin
2020d3957e dump: prevent dumping if a session leader is outside of the current pidns
A parasite code returns zero sid for such cases.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-01 20:11:13 +04:00