Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
0fd17a08
Commit
0fd17a08
authored
Nov 15, 2011
by
Cyrill Gorcunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bring some order in usage of VMA entries helpers
Signed-off-by:
Cyrill Gorcunov
<
gorcunov@gmail.com
>
parent
bb15450d
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
51 additions
and
54 deletions
+51
-54
cr-dump.c
cr-dump.c
+10
-9
cr-restore.c
cr-restore.c
+5
-5
cr-show.c
cr-show.c
+1
-1
crtools.h
include/crtools.h
+2
-7
image.h
include/image.h
+20
-15
util.h
include/util.h
+0
-3
parasite.c
parasite.c
+1
-1
restorer.c
restorer.c
+11
-12
util.c
util.c
+1
-1
No files found.
cr-dump.c
View file @
0fd17a08
...
...
@@ -352,14 +352,14 @@ static int dump_task_mappings(pid_t pid, struct list_head *vma_area_list, struct
struct
vma_entry
*
vma
=
&
vma_area
->
vma
;
if
(
!
(
vma
->
status
&
VMA_AREA_REGULAR
))
if
(
!
vma_entry_is
(
vma
,
VMA_AREA_REGULAR
))
continue
;
pr_info_vma
(
vma_area
);
if
(
vma
->
flags
&
(
MAP_SHARED
|
MAP_PRIVATE
))
{
if
(
(
vma
->
status
&
VMA_ANON_SHARED
))
{
if
(
vma_entry_is
(
vma
,
VMA_ANON_SHARED
))
{
struct
shmem_entry
e
;
e
.
start
=
vma
->
start
;
...
...
@@ -370,12 +370,13 @@ static int dump_task_mappings(pid_t pid, struct list_head *vma_area_list, struct
e
.
start
,
e
.
end
,
e
.
shmid
);
write_ptr_safe
(
cr_fdset
->
desc
[
CR_FD_SHMEM
].
fd
,
&
e
,
err
);
}
else
if
(
(
vma
->
status
&
VMA_FILE_PRIVATE
)
||
(
vma
->
status
&
VMA_FILE_SHARED
))
{
}
else
if
(
vma_entry_is
(
vma
,
VMA_FILE_PRIVATE
)
||
vma_entry_is
(
vma
,
VMA_FILE_SHARED
))
{
unsigned
int
flags
;
if
(
vma
->
prot
&
PROT_WRITE
&&
(
vma
->
status
&
VMA_FILE_SHARED
))
if
(
vma
->
prot
&
PROT_WRITE
&&
vma_entry_is
(
vma
,
VMA_FILE_SHARED
))
flags
=
O_RDWR
;
else
flags
=
O_RDONLY
;
...
...
@@ -985,13 +986,13 @@ static int finalize_core(pid_t pid, struct list_head *vma_area_list, struct cr_f
* Just in case if someone broke parasite page
* dumper code.
*/
if
(
!
vma_area_
ha
s
(
vma_area
,
VMA_AREA_REGULAR
))
{
if
(
!
vma_area_
i
s
(
vma_area
,
VMA_AREA_REGULAR
))
{
pr_panic
(
"
\n
A page with address %lx has a wrong status
\n
"
,
va
);
goto
err
;
}
if
(
vma_area_
ha
s
(
vma_area
,
VMA_ANON_PRIVATE
)
||
vma_area_
ha
s
(
vma_area
,
VMA_FILE_PRIVATE
))
{
if
(
vma_area_
i
s
(
vma_area
,
VMA_ANON_PRIVATE
)
||
vma_area_
i
s
(
vma_area
,
VMA_FILE_PRIVATE
))
{
ret
=
write
(
fd_core
,
&
va
,
sizeof
(
va
));
ret
+=
sendfile
(
fd_core
,
fd_pages
,
NULL
,
PAGE_SIZE
);
if
(
ret
!=
sizeof
(
va
)
+
PAGE_SIZE
)
{
...
...
@@ -1001,7 +1002,7 @@ static int finalize_core(pid_t pid, struct list_head *vma_area_list, struct cr_f
goto
err
;
}
num
++
;
}
else
if
(
vma_area_
ha
s
(
vma_area
,
VMA_ANON_SHARED
))
{
}
else
if
(
vma_area_
i
s
(
vma_area
,
VMA_ANON_SHARED
))
{
ret
=
write
(
fd_pages_shmem
,
&
va
,
sizeof
(
va
));
ret
+=
sendfile
(
fd_pages_shmem
,
fd_pages
,
NULL
,
PAGE_SIZE
);
if
(
ret
!=
sizeof
(
va
)
+
PAGE_SIZE
)
{
...
...
cr-restore.c
View file @
0fd17a08
...
...
@@ -703,15 +703,15 @@ static int fixup_vma_fds(int pid, int fd)
return
1
;
}
if
(
vi
.
start
==
0
&&
vi
.
end
==
0
)
if
(
final_vma_entry
(
&
vi
)
)
return
0
;
if
(
!
(
v
i
.
status
&
VMA_AREA_REGULAR
))
if
(
!
(
v
ma_entry_is
(
&
vi
,
VMA_AREA_REGULAR
)
))
continue
;
if
(
(
vi
.
status
&
VMA_FILE_PRIVATE
)
||
(
vi
.
status
&
VMA_FILE_SHARED
)
||
(
vi
.
status
&
VMA_ANON_SHARED
))
{
if
(
vma_entry_is
(
&
vi
,
VMA_FILE_PRIVATE
)
||
vma_entry_is
(
&
vi
,
VMA_FILE_SHARED
)
||
vma_entry_is
(
&
vi
,
VMA_ANON_SHARED
))
{
pr_info
(
"%d: Fixing %016lx-%016lx %016lx vma
\n
"
,
pid
,
vi
.
start
,
vi
.
end
,
vi
.
pgoff
);
...
...
cr-show.c
View file @
0fd17a08
...
...
@@ -253,7 +253,7 @@ static void show_core(struct cr_fdset *cr_fdset)
goto
out
;
}
if
(
is_ending_vma
(
&
ve
))
{
if
(
final_vma_entry
(
&
ve
))
{
pr_info
(
"
\n\t
---[Pages]---
\n
"
);
while
(
1
)
{
ret
=
read
(
fd_core
,
&
va
,
sizeof
(
va
));
...
...
include/crtools.h
View file @
0fd17a08
...
...
@@ -85,8 +85,8 @@ struct vma_area {
int
vm_file_fd
;
};
#define vma_area_
has(vma_area, s) vma_entry_has(&vma_area->vma
, s)
#define vma_
entry_len(vma) ((vma)->end - (vma)->start
)
#define vma_area_
is(vma_area, s) vma_entry_is(&((vma_area)->vma)
, s)
#define vma_
area_len(vma_area) vma_entry_len(&((vma_area)->vma)
)
struct
pstree_item
{
struct
list_head
list
;
...
...
@@ -97,11 +97,6 @@ struct pstree_item {
u32
*
children
;
/* array of children */
};
static
inline
unsigned
long
vma_area_size
(
struct
vma_area
*
vma
)
{
return
vma
->
vma
.
end
-
vma
->
vma
.
start
;
}
static
inline
int
in_vma_area
(
struct
vma_area
*
vma
,
unsigned
long
addr
)
{
return
addr
>=
(
unsigned
long
)
vma
->
vma
.
start
&&
...
...
include/image.h
View file @
0fd17a08
...
...
@@ -50,6 +50,20 @@ struct pipe_entry {
u8
data
[
0
];
}
__packed
;
struct
vma_entry
{
u64
start
;
u64
end
;
u64
pgoff
;
u32
prot
;
u32
flags
;
u32
status
;
u32
pid
;
s64
fd
;
u64
ino
;
u32
dev_maj
;
u32
dev_min
;
}
__packed
;
#define VMA_AREA_NONE (0 << 0)
#define VMA_AREA_REGULAR (1 << 0)
/* Dumpable area */
#define VMA_AREA_STACK (1 << 1)
...
...
@@ -64,27 +78,18 @@ struct pipe_entry {
#define VMA_ANON_PRIVATE (1 << 9)
#define VMA_DUMP_ALL (1 << 10)
/* Dump the whole VMA area pages */
#define vma_entry_has(vma, s) (((vma)->status & (s)) == (s))
struct
vma_entry
{
u64
start
;
u64
end
;
u64
pgoff
;
u32
prot
;
u32
flags
;
u32
status
;
u32
pid
;
s64
fd
;
u64
ino
;
u32
dev_maj
;
u32
dev_min
;
}
__packed
;
#define vma_entry_is(vma, s) (((vma)->status & (s)) == (s))
#define vma_entry_len(vma) ((vma)->end - (vma)->start)
#define final_vma_entry(vma) ((vma)->start == 0 && (vma)->end == 0)
struct
page_entry
{
u64
va
;
u8
data
[
PAGE_IMAGE_SIZE
];
}
__packed
;
#define final_page_va(va) ((va) == 0)
#define final_page_entry(page_entry) (final_page_va((page_entry)->va))
#define HEADER_VERSION 1
#define HEADER_ARCH_X86_64 1
...
...
include/util.h
View file @
0fd17a08
...
...
@@ -125,9 +125,6 @@ struct list_head;
void
printk_vma
(
struct
vma_area
*
vma_area
);
/* A special marker */
#define is_ending_vma(vma) ((vma)->start == 0 && (vma)->end == 0)
#define pr_info_vma_list(head) \
do { \
struct vma_area *vma; \
...
...
parasite.c
View file @
0fd17a08
...
...
@@ -126,7 +126,7 @@ static int dump_pages(parasite_args_cmd_dumppages_t *args)
}
}
dump_all
=
!!
(
args
->
vma_entry
.
status
&
VMA_DUMP_ALL
);
dump_all
=
vma_entry_is
(
&
args
->
vma_entry
,
VMA_DUMP_ALL
);
/*
* Try to change page protection if needed so we would
...
...
restorer.c
View file @
0fd17a08
...
...
@@ -238,11 +238,10 @@ self_len_end:
goto
core_restore_end
;
}
if
(
!
(
vma_entry
.
status
&
VMA_AREA_REGULAR
))
if
(
!
vma_entry_is
(
&
vma_entry
,
VMA_AREA_REGULAR
))
continue
;
if
(
sys_munmap
((
void
*
)
vma_entry
.
start
,
vma_entry
.
end
-
vma_entry
.
start
))
{
if
(
sys_munmap
((
void
*
)
vma_entry
.
start
,
vma_entry_len
(
&
vma_entry
)))
{
write_hex_n
(
__LINE__
);
goto
core_restore_end
;
}
...
...
@@ -265,10 +264,10 @@ self_len_end:
goto
core_restore_end
;
}
if
(
!
vma_entry
.
start
)
if
(
final_vma_entry
(
&
vma_entry
)
)
break
;
if
(
vma_entry
.
status
&
VMA_AREA_VDSO
)
{
if
(
vma_entry
_is
(
&
vma_entry
,
VMA_AREA_VDSO
)
)
{
ret
=
sys_prctl
(
PR_CKPT_CTL
,
PR_CKPT_CTL_SETUP_VDSO_AT
,
vma_entry
.
start
,
0
,
0
);
if
(
ret
)
{
...
...
@@ -279,7 +278,7 @@ self_len_end:
continue
;
}
if
(
!
(
vma_entry
.
status
&
VMA_AREA_REGULAR
))
if
(
!
vma_entry_is
(
&
vma_entry
,
VMA_AREA_REGULAR
))
continue
;
/*
...
...
@@ -288,7 +287,7 @@ self_len_end:
* MAP_ANONYMOUS should be eliminated so fd would
* be taken into account by a kernel.
*/
if
(
vma_entry
.
status
&
VMA_ANON_SHARED
)
{
if
(
vma_entry
_is
(
&
vma_entry
,
VMA_ANON_SHARED
)
)
{
if
(
vma_entry
.
fd
!=
-
1UL
)
vma_entry
.
flags
&=
~
MAP_ANONYMOUS
;
}
...
...
@@ -299,7 +298,7 @@ self_len_end:
* contents.
*/
va
=
sys_mmap
((
void
*
)
vma_entry
.
start
,
vma_entry
.
end
-
vma_entry
.
start
,
vma_entry
_len
(
&
vma_entry
)
,
vma_entry
.
prot
|
PROT_WRITE
,
vma_entry
.
flags
|
MAP_FIXED
,
vma_entry
.
fd
,
...
...
@@ -333,7 +332,7 @@ self_len_end:
write_hex_n
(
ret
);
goto
core_restore_end
;
}
if
(
!
va
)
if
(
final_page_va
(
va
)
)
break
;
ret
=
sys_read
(
fd_core
,
(
void
*
)
va
,
PAGE_SIZE
);
...
...
@@ -359,17 +358,17 @@ self_len_end:
goto
core_restore_end
;
}
if
(
!
vma_entry
.
start
)
if
(
final_vma_entry
(
&
vma_entry
)
)
break
;
if
(
!
(
vma_entry
.
status
&
VMA_AREA_REGULAR
))
if
(
!
(
vma_entry
_is
(
&
vma_entry
,
VMA_AREA_REGULAR
)
))
continue
;
if
(
vma_entry
.
prot
&
PROT_WRITE
)
continue
;
sys_mprotect
(
vma_entry
.
start
,
vma_entry
.
end
-
vma_entry
.
start
,
vma_entry
_len
(
&
vma_entry
)
,
vma_entry
.
prot
);
}
...
...
util.c
View file @
0fd17a08
...
...
@@ -178,7 +178,7 @@ void printk_vma(struct vma_area *vma_area)
printk
(
"s: %16lx e: %16lx l: %4liK p: %4x f: %8x pg: %8lx "
"fd: %4d pid: %4d dev:%02x:%02x:%08lx vf: %s st: %s spc: %s
\n
"
,
vma_area
->
vma
.
start
,
vma_area
->
vma
.
end
,
vma_
entry_len
(
&
vma_area
->
vm
a
)
>>
10
,
vma_
area_len
(
vma_are
a
)
>>
10
,
vma_area
->
vma
.
prot
,
vma_area
->
vma
.
flags
,
vma_area
->
vma
.
pgoff
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment