This code opens a log file and duplicates the descriptor to logfd,
but forgets to close the first one.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Restorer does really restore shared memory (including page
contents restore) only on master process, while all other
processes do open such memory area via map_files/ procfs entry
so that we might have a situation when shared VMA is present
in some particular core-%d.img file but it's not listed in
collected shmems array and find_shmem_by_pid will return NULL.
This is perfectly fine, be ready for that.
Another issue is that shared memory might look like
CR_FD_SHMEM: /home/cyrill/projects/kernel/crtools/shmem-2641.img
----------------------------------------
0x7f2200775000-0x7f2200776000 id 19664
0x7f2200776000-0x7f2200777000 id 19663
----------------------------------------
So vma area is [x;y) range and we should distinguish two
shmem lookup cases
- one when we search for page in shmem area
- second when we lookup shmem area in collected ranges
They both have a different lookup conditions so single
find_shmem splitted into two helpers find_shmem and
find_shmem_page as appropriate.
This patch finally fixes the three process asynchronious
shared memory updates test-case.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
The remapping of /proc path to shmem should be
done with pid of process which did mmap() call
initially.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
In commit 99eb3d09c5c42200b230783e793b778882ce8dd6
we started to use self-contained shared memory
region but it revealed the problem that anonymous
sgared mappings might be parsed by parse_maps incorrectly,
so fix it and be ready to get anon-shared mappings.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Also make output a bit more fancy, as
CR_FD_UNIXSK: unixsk-2440.img
----------------------------------------
fd 3 type 1 state 1 namelen 0 id 19406 peer 19407
fd 4 type 1 state 1 namelen 0 id 19407 peer 19406
fd 5 type 2 state 7 namelen 7 id 19408 peer 0 ---> [tst-sk]
fd 6 type 2 state 7 namelen 0 id 19409 peer 0
fd 7 type 2 state 7 namelen 0 id 19410 peer 19411
fd 8 type 2 state 7 namelen 8 id 19411 peer 0 ---> [tst-sk1]
----------------------------------------
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Several places just need to open an image, thus the helper is OK to use.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
To follow rest of code
- use !x for xalloc result tests
- structure members are tab aligned
- multiline assignments over structure members are aligned as well
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Since we're not system library
- no underscopes in functions name until really needed
and known to not clash with posix namespace
- empty line between system headers and own headers
for readability
- extern for function prototypes
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Otherwise getting errors like
| CC libnetlink.o
| In file included from libnetlink.c:4:0:
| ./include/libnetlink.h:34:0: error: "NLMSG_LENGTH" redefined [-Werror]
And make macros a bit more readable.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
The next patch will remap shmems region and will use it in restorer.
Actually this patch moves shmem_nr to struct shmems.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
[gorcunov: Various tuneups]
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>