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
3486d993
Unverified
Commit
3486d993
authored
Feb 16, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: stash fds for the controller mountpoint and base cgroup path
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
5c7b8143
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
0 deletions
+23
-0
cgfsng.c
src/lxc/cgroups/cgfsng.c
+13
-0
cgroup.c
src/lxc/cgroups/cgroup.c
+4
-0
cgroup.h
src/lxc/cgroups/cgroup.h
+6
-0
No files found.
src/lxc/cgroups/cgfsng.c
View file @
3486d993
...
@@ -696,6 +696,7 @@ static struct hierarchy *add_hierarchy(struct cgroup_ops *ops,
...
@@ -696,6 +696,7 @@ static struct hierarchy *add_hierarchy(struct cgroup_ops *ops,
char
**
clist
,
char
*
mountpoint
,
char
**
clist
,
char
*
mountpoint
,
char
*
container_base_path
,
int
type
)
char
*
container_base_path
,
int
type
)
{
{
__do_close
int
dfd_base
=
-
EBADF
,
dfd_mnt
=
-
EBADF
;
__do_free
struct
hierarchy
*
new
=
NULL
;
__do_free
struct
hierarchy
*
new
=
NULL
;
int
newentry
;
int
newentry
;
...
@@ -714,6 +715,16 @@ static struct hierarchy *add_hierarchy(struct cgroup_ops *ops,
...
@@ -714,6 +715,16 @@ static struct hierarchy *add_hierarchy(struct cgroup_ops *ops,
new
->
cgfd_limit
=
-
EBADF
;
new
->
cgfd_limit
=
-
EBADF
;
new
->
cgfd_mon
=
-
EBADF
;
new
->
cgfd_mon
=
-
EBADF
;
dfd_mnt
=
open_at
(
-
EBADF
,
mountpoint
,
PROTECT_OPATH_DIRECTORY
,
PROTECT_LOOKUP_ABSOLUTE_XDEV
,
0
);
if
(
dfd_mnt
<
0
)
return
syserrno
(
NULL
,
"Failed to open %s"
,
mountpoint
);
dfd_base
=
open_at
(
dfd_mnt
,
container_base_path
,
PROTECT_OPATH_DIRECTORY
,
PROTECT_LOOKUP_BENEATH_XDEV
,
0
);
if
(
dfd_base
<
0
)
return
syserrno
(
NULL
,
"Failed to open %d(%s)"
,
dfd_base
,
container_base_path
);
TRACE
(
"Adding cgroup hierarchy with mountpoint %s and base cgroup %s %s"
,
TRACE
(
"Adding cgroup hierarchy with mountpoint %s and base cgroup %s %s"
,
mountpoint
,
container_base_path
,
mountpoint
,
container_base_path
,
clist
?
"with controllers "
:
"without any controllers"
);
clist
?
"with controllers "
:
"without any controllers"
);
...
@@ -721,6 +732,8 @@ static struct hierarchy *add_hierarchy(struct cgroup_ops *ops,
...
@@ -721,6 +732,8 @@ static struct hierarchy *add_hierarchy(struct cgroup_ops *ops,
TRACE
(
"%s"
,
*
it
);
TRACE
(
"%s"
,
*
it
);
newentry
=
append_null_to_list
((
void
***
)
&
ops
->
hierarchies
);
newentry
=
append_null_to_list
((
void
***
)
&
ops
->
hierarchies
);
new
->
dfd_mnt
=
move_fd
(
dfd_mnt
);
new
->
dfd_base
=
move_fd
(
dfd_base
);
(
ops
->
hierarchies
)[
newentry
]
=
new
;
(
ops
->
hierarchies
)[
newentry
]
=
new
;
return
move_ptr
(
new
);
return
move_ptr
(
new
);
}
}
...
...
src/lxc/cgroups/cgroup.c
View file @
3486d993
...
@@ -92,6 +92,10 @@ void cgroup_exit(struct cgroup_ops *ops)
...
@@ -92,6 +92,10 @@ void cgroup_exit(struct cgroup_ops *ops)
close
((
*
it
)
->
cgfd_con
);
close
((
*
it
)
->
cgfd_con
);
if
((
*
it
)
->
cgfd_mon
>=
0
)
if
((
*
it
)
->
cgfd_mon
>=
0
)
close
((
*
it
)
->
cgfd_mon
);
close
((
*
it
)
->
cgfd_mon
);
if
((
*
it
)
->
dfd_mnt
>=
0
)
close
((
*
it
)
->
dfd_mnt
);
if
((
*
it
)
->
dfd_base
>=
0
)
close
((
*
it
)
->
dfd_base
);
free
(
*
it
);
free
(
*
it
);
}
}
free
(
ops
->
hierarchies
);
free
(
ops
->
hierarchies
);
...
...
src/lxc/cgroups/cgroup.h
View file @
3486d993
...
@@ -103,6 +103,12 @@ struct hierarchy {
...
@@ -103,6 +103,12 @@ struct hierarchy {
/* File descriptor for the monitor's cgroup @monitor_full_path. */
/* File descriptor for the monitor's cgroup @monitor_full_path. */
int
cgfd_mon
;
int
cgfd_mon
;
/* File descriptor for the controller's mountpoint @mountpoint. */
int
dfd_mnt
;
/* File descriptor for the controller's base cgroup path @container_base_path. */
int
dfd_base
;
};
};
struct
cgroup_ops
{
struct
cgroup_ops
{
...
...
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