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
08fbe494
Unverified
Commit
08fbe494
authored
Feb 07, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'lifeng68-remount_cgroup' into lxc/master
parents
c112f06d
886cac86
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
16 deletions
+37
-16
cgfsng.c
src/lxc/cgroups/cgfsng.c
+37
-16
No files found.
src/lxc/cgroups/cgfsng.c
View file @
08fbe494
...
@@ -1915,40 +1915,61 @@ static bool cg_mount_needs_subdirs(int type)
...
@@ -1915,40 +1915,61 @@ static bool cg_mount_needs_subdirs(int type)
return
true
;
return
true
;
}
}
/*
/* After $rootfs/sys/fs/container/controller/the/cg/path has been created,
* After $rootfs/sys/fs/container/controller/the/cg/path has been
* remount controller ro if needed and bindmount the cgroupfs onto
* created, remount controller ro if needed and bindmount the
* controll/the/cg/path.
* cgroupfs onto controll/the/cg/path
*/
*/
static
int
do_secondstage_mounts_if_needed
(
int
type
,
struct
hierarchy
*
h
,
static
int
do_secondstage_mounts_if_needed
(
int
type
,
struct
hierarchy
*
h
,
char
*
controllerpath
,
char
*
cgpath
,
char
*
controllerpath
,
char
*
cgpath
,
const
char
*
container_cgroup
)
const
char
*
container_cgroup
)
{
{
int
ret
;
char
*
sourcepath
;
int
flags
=
MS_BIND
;
if
(
type
==
LXC_AUTO_CGROUP_RO
||
type
==
LXC_AUTO_CGROUP_MIXED
)
{
if
(
type
==
LXC_AUTO_CGROUP_RO
||
type
==
LXC_AUTO_CGROUP_MIXED
)
{
if
(
mount
(
controllerpath
,
controllerpath
,
"cgroup"
,
MS_BIND
,
NULL
)
<
0
)
{
ret
=
mount
(
controllerpath
,
controllerpath
,
"cgroup"
,
MS_BIND
,
NULL
);
SYSERROR
(
"Error bind-mounting %s"
,
controllerpath
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to bind mount
\"
%s
\"
onto
\"
%s
\"
"
,
controllerpath
,
controllerpath
);
return
-
1
;
return
-
1
;
}
}
if
(
mount
(
controllerpath
,
controllerpath
,
"cgroup"
,
MS_REMOUNT
|
MS_BIND
|
MS_RDONLY
,
NULL
)
<
0
)
{
ret
=
mount
(
controllerpath
,
controllerpath
,
"cgroup"
,
SYSERROR
(
"Error remounting %s read-only"
,
controllerpath
);
MS_REMOUNT
|
MS_BIND
|
MS_RDONLY
,
NULL
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to remount
\"
%s
\"
ro"
,
controllerpath
);
return
-
1
;
return
-
1
;
}
}
INFO
(
"Remounted %s read-only"
,
controllerpath
);
INFO
(
"Remounted %s read-only"
,
controllerpath
);
}
}
char
*
sourcepath
=
must_make_path
(
h
->
mountpoint
,
h
->
base_cgroup
,
container_cgroup
,
NULL
);
int
flags
=
MS_BIND
;
sourcepath
=
must_make_path
(
h
->
mountpoint
,
h
->
base_cgroup
,
container_cgroup
,
NULL
);
if
(
type
==
LXC_AUTO_CGROUP_RO
)
if
(
type
==
LXC_AUTO_CGROUP_RO
)
flags
|=
MS_RDONLY
;
flags
|=
MS_RDONLY
;
INFO
(
"Mounting %s onto %s"
,
sourcepath
,
cgpath
);
if
(
mount
(
sourcepath
,
cgpath
,
"cgroup"
,
flags
,
NULL
)
<
0
)
{
ret
=
mount
(
sourcepath
,
cgpath
,
"cgroup"
,
flags
,
NULL
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to mount
\"
%s
\"
onto
\"
%s
\"
"
,
h
->
controllers
[
0
],
cgpath
);
free
(
sourcepath
);
free
(
sourcepath
);
SYSERROR
(
"Error mounting cgroup %s onto %s"
,
h
->
controllers
[
0
],
cgpath
);
return
-
1
;
return
-
1
;
}
}
INFO
(
"Mounted
\"
%s
\"
onto
\"
%s
\"
"
,
h
->
controllers
[
0
],
cgpath
);
if
(
flags
&
MS_RDONLY
)
{
ret
=
mount
(
sourcepath
,
cgpath
,
"cgroup"
,
MS_REMOUNT
|
flags
|
MS_RDONLY
,
NULL
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to remount
\"
%s
\"
ro"
,
cgpath
);
free
(
sourcepath
);
return
-
1
;
}
}
free
(
sourcepath
);
free
(
sourcepath
);
INFO
(
"Completed second stage cgroup automounts for
%s
"
,
cgpath
);
INFO
(
"Completed second stage cgroup automounts for
\"
%s
\"
"
,
cgpath
);
return
0
;
return
0
;
}
}
...
...
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