Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
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
Chen Yisong
lxc
Commits
1a4faf51
Commit
1a4faf51
authored
Mar 10, 2016
by
Serge Hallyn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #889 from tych0/cgfsng-fixes
Cgfsng fixes
parents
ef372057
7103fe6f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
22 deletions
+20
-22
cgfsng.c
src/lxc/cgfsng.c
+14
-4
cgroup.h
src/lxc/cgroup.h
+2
-2
criu.c
src/lxc/criu.c
+4
-14
criu.h
src/lxc/criu.h
+0
-2
No files found.
src/lxc/cgfsng.c
View file @
1a4faf51
...
...
@@ -1280,14 +1280,21 @@ static int cgfsng_nrtasks(void *hdata) {
}
/* Only root needs to escape to the cgroup of its init */
static
bool
cgfsng_escape
(
void
*
hdata
)
static
bool
cgfsng_escape
()
{
struct
cgfsng_handler_data
*
d
=
hdata
;
struct
cgfsng_handler_data
*
d
;
int
i
;
bool
ret
=
false
;
if
(
geteuid
())
return
true
;
d
=
cgfsng_init
(
"criu-temp-cgfsng"
);
if
(
!
d
)
{
ERROR
(
"cgfsng_init failed"
);
return
false
;
}
for
(
i
=
0
;
d
->
hierarchies
[
i
];
i
++
)
{
char
*
fullpath
=
must_make_path
(
d
->
hierarchies
[
i
]
->
mountpoint
,
d
->
hierarchies
[
i
]
->
base_cgroup
,
...
...
@@ -1295,12 +1302,15 @@ static bool cgfsng_escape(void *hdata)
if
(
lxc_write_to_file
(
fullpath
,
"0"
,
2
,
false
)
!=
0
)
{
SYSERROR
(
"Failed to escape to %s"
,
fullpath
);
free
(
fullpath
);
return
false
;
goto
out
;
}
free
(
fullpath
);
}
return
true
;
ret
=
true
;
out:
free_handler_data
(
d
);
return
ret
;
}
#define THAWED "THAWED"
...
...
src/lxc/cgroup.h
View file @
1a4faf51
...
...
@@ -48,7 +48,7 @@ struct cgroup_ops {
bool
(
*
create_legacy
)(
void
*
hdata
,
pid_t
pid
);
const
char
*
(
*
get_cgroup
)(
void
*
hdata
,
const
char
*
subsystem
);
const
char
*
(
*
canonical_path
)(
void
*
hdata
);
bool
(
*
escape
)(
void
*
hdata
);
bool
(
*
escape
)();
int
(
*
set
)(
const
char
*
filename
,
const
char
*
value
,
const
char
*
name
,
const
char
*
lxcpath
);
int
(
*
get
)(
const
char
*
filename
,
char
*
value
,
size_t
len
,
const
char
*
name
,
const
char
*
lxcpath
);
bool
(
*
unfreeze
)(
void
*
hdata
);
...
...
@@ -73,7 +73,7 @@ extern void cgroup_cleanup(struct lxc_handler *handler);
extern
bool
cgroup_create_legacy
(
struct
lxc_handler
*
handler
);
extern
int
cgroup_nrtasks
(
struct
lxc_handler
*
handler
);
extern
const
char
*
cgroup_get_cgroup
(
struct
lxc_handler
*
handler
,
const
char
*
subsystem
);
extern
bool
cgroup_escape
(
struct
lxc_handler
*
handler
);
extern
bool
cgroup_escape
();
/*
* Currently, this call only makes sense for privileged containers.
...
...
src/lxc/criu.c
View file @
1a4faf51
...
...
@@ -47,7 +47,7 @@
lxc_log_define
(
lxc_criu
,
lxc
);
void
exec_criu
(
struct
lxc_handler
*
handler
,
struct
criu_opts
*
opts
)
static
void
exec_criu
(
struct
criu_opts
*
opts
)
{
char
**
argv
,
log
[
PATH_MAX
];
int
static_args
=
22
,
argc
=
0
,
i
,
ret
;
...
...
@@ -63,7 +63,7 @@ void exec_criu(struct lxc_handler *handler, struct criu_opts *opts)
* /actual/ root cgroup so that lxcfs thinks criu has enough rights to
* see all cgroups.
*/
if
(
!
cgroup_escape
(
handler
))
{
if
(
!
cgroup_escape
())
{
ERROR
(
"failed to escape cgroups"
);
return
;
}
...
...
@@ -517,7 +517,7 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
os
.
cgroup_path
=
cgroup_canonical_path
(
handler
);
/* exec_criu() returning is an error */
exec_criu
(
handler
,
&
os
);
exec_criu
(
&
os
);
umount
(
rootfs
->
mount
);
rmdir
(
rootfs
->
mount
);
goto
out_fini_handler
;
...
...
@@ -624,16 +624,6 @@ static bool do_dump(struct lxc_container *c, char *mode, char *directory,
if
(
pid
==
0
)
{
struct
criu_opts
os
;
struct
lxc_handler
*
handler
;
handler
=
lxc_init
(
c
->
name
,
c
->
lxc_conf
,
c
->
config_path
);
if
(
!
handler
)
exit
(
1
);
if
(
!
cgroup_init
(
handler
))
{
ERROR
(
"failed initing cgroups"
);
exit
(
1
);
}
os
.
action
=
mode
;
os
.
directory
=
directory
;
...
...
@@ -643,7 +633,7 @@ static bool do_dump(struct lxc_container *c, char *mode, char *directory,
os
.
predump_dir
=
predump_dir
;
/* exec_criu() returning is an error */
exec_criu
(
handler
,
&
os
);
exec_criu
(
&
os
);
exit
(
1
);
}
else
{
int
status
;
...
...
src/lxc/criu.h
View file @
1a4faf51
...
...
@@ -58,8 +58,6 @@ struct criu_opts {
const
char
*
cgroup_path
;
};
void
exec_criu
(
struct
lxc_handler
*
handler
,
struct
criu_opts
*
opts
);
/* Check and make sure the container has a configuration that we know CRIU can
* dump. */
bool
criu_ok
(
struct
lxc_container
*
c
);
...
...
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