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
e040efb6
Unverified
Commit
e040efb6
authored
Feb 23, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: introduce fd-only cgroup attach
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
b106d22f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
5 deletions
+27
-5
cgfsng.c
src/lxc/cgroups/cgfsng.c
+11
-5
cgroup.h
src/lxc/cgroups/cgroup.h
+16
-0
No files found.
src/lxc/cgroups/cgfsng.c
View file @
e040efb6
...
@@ -3373,12 +3373,14 @@ static int __unified_attach_fd(const struct lxc_conf *conf, int fd_unified, pid_
...
@@ -3373,12 +3373,14 @@ static int __unified_attach_fd(const struct lxc_conf *conf, int fd_unified, pid_
static
int
__cgroup_attach_many
(
const
struct
lxc_conf
*
conf
,
const
char
*
name
,
static
int
__cgroup_attach_many
(
const
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
,
pid_t
pid
)
const
char
*
lxcpath
,
pid_t
pid
)
{
{
call_cleaner
(
put_
unix_fds
)
struct
unix_fds
*
fds
=
&
(
struct
unix_fds
){};
call_cleaner
(
put_
cgroup_ctx
)
struct
cgroup_ctx
*
ctx
=
&
(
struct
cgroup_ctx
){};
int
ret
;
int
ret
;
char
pidstr
[
INTTYPE_TO_STRLEN
(
pid_t
)];
char
pidstr
[
INTTYPE_TO_STRLEN
(
pid_t
)];
size_t
idx
;
ssize_t
pidstr_len
;
ssize_t
pidstr_len
;
ret
=
lxc_cmd_get_cgroup_fd
(
name
,
lxcpath
,
NULL
,
true
,
fds
);
ret
=
lxc_cmd_get_cgroup_ctx
(
name
,
lxcpath
,
NULL
,
true
,
sizeof
(
struct
cgroup_ctx
),
ctx
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret_errno
(
ENOSYS
);
return
ret_errno
(
ENOSYS
);
...
@@ -3386,8 +3388,8 @@ static int __cgroup_attach_many(const struct lxc_conf *conf, const char *name,
...
@@ -3386,8 +3388,8 @@ static int __cgroup_attach_many(const struct lxc_conf *conf, const char *name,
if
(
pidstr_len
<
0
)
if
(
pidstr_len
<
0
)
return
pidstr_len
;
return
pidstr_len
;
for
(
size_t
idx
=
0
;
idx
<
fds
->
fd_count_ret
;
idx
++
)
{
for
(
idx
=
0
;
idx
<
ctx
->
fd_len
;
idx
++
)
{
int
dfd_con
=
fds
->
fd
[
idx
];
int
dfd_con
=
ctx
->
fd
[
idx
];
if
(
unified_cgroup_fd
(
dfd_con
))
if
(
unified_cgroup_fd
(
dfd_con
))
ret
=
__unified_attach_fd
(
conf
,
dfd_con
,
pid
);
ret
=
__unified_attach_fd
(
conf
,
dfd_con
,
pid
);
...
@@ -3399,7 +3401,11 @@ static int __cgroup_attach_many(const struct lxc_conf *conf, const char *name,
...
@@ -3399,7 +3401,11 @@ static int __cgroup_attach_many(const struct lxc_conf *conf, const char *name,
TRACE
(
"Attached to cgroup fd %d"
,
dfd_con
);
TRACE
(
"Attached to cgroup fd %d"
,
dfd_con
);
}
}
return
log_trace
(
0
,
"Attached to cgroups"
);
if
(
idx
==
0
)
return
syserrno_set
(
-
ENOENT
,
"Failed to attach to cgroups"
);
TRACE
(
"Attached to %s cgroup layout"
,
cgroup_layout_name
(
ctx
->
cgroup_layout
));
return
0
;
}
}
static
int
__cgroup_attach_unified
(
const
struct
lxc_conf
*
conf
,
const
char
*
name
,
static
int
__cgroup_attach_unified
(
const
struct
lxc_conf
*
conf
,
const
char
*
name
,
...
...
src/lxc/cgroups/cgroup.h
View file @
e040efb6
...
@@ -35,6 +35,22 @@ typedef enum {
...
@@ -35,6 +35,22 @@ typedef enum {
CGROUP_LAYOUT_UNIFIED
=
2
,
CGROUP_LAYOUT_UNIFIED
=
2
,
}
cgroup_layout_t
;
}
cgroup_layout_t
;
static
inline
const
char
*
cgroup_layout_name
(
cgroup_layout_t
layout
)
{
switch
(
layout
)
{
case
CGROUP_LAYOUT_LEGACY
:
return
"legacy"
;
case
CGROUP_LAYOUT_HYBRID
:
return
"hybrid"
;
case
CGROUP_LAYOUT_UNIFIED
:
return
"unified"
;
case
CGROUP_LAYOUT_UNKNOWN
:
break
;
}
return
"unknown"
;
}
typedef
enum
{
typedef
enum
{
LEGACY_HIERARCHY
=
CGROUP_SUPER_MAGIC
,
LEGACY_HIERARCHY
=
CGROUP_SUPER_MAGIC
,
UNIFIED_HIERARCHY
=
CGROUP2_SUPER_MAGIC
,
UNIFIED_HIERARCHY
=
CGROUP2_SUPER_MAGIC
,
...
...
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