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
58222337
Unverified
Commit
58222337
authored
Dec 08, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups/cgfsng: rework cgfsng_payload_create()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
f29b71ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
cgfsng.c
src/lxc/cgroups/cgfsng.c
+19
-18
No files found.
src/lxc/cgroups/cgfsng.c
View file @
58222337
...
@@ -1366,32 +1366,36 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
...
@@ -1366,32 +1366,36 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
* next cgroup_pattern-1, -2, ..., -999.
* next cgroup_pattern-1, -2, ..., -999.
*/
*/
__cgfsng_ops
static
inline
bool
cgfsng_payload_create
(
struct
cgroup_ops
*
ops
,
__cgfsng_ops
static
inline
bool
cgfsng_payload_create
(
struct
cgroup_ops
*
ops
,
struct
lxc_handler
*
handler
)
struct
lxc_handler
*
handler
)
{
{
__do_free
char
*
container_cgroup
=
NULL
,
*
tmp
=
NULL
;
__do_free
char
*
container_cgroup
=
NULL
,
*
tmp
=
NULL
;
int
idx
=
0
;
int
i
,
ret
;
int
i
,
ret
;
size_t
len
;
size_t
len
;
char
*
offset
;
char
*
offset
;
int
idx
=
0
;
struct
lxc_conf
*
conf
;
struct
lxc_conf
*
conf
=
handler
->
conf
;
if
(
ops
->
container_cgroup
)
return
false
;
if
(
!
conf
)
if
(
!
ops
)
return
false
;
return
ret_set_errno
(
false
,
ENOENT
)
;
if
(
!
ops
->
hierarchies
)
if
(
!
ops
->
hierarchies
)
return
true
;
return
true
;
if
(
ops
->
container_cgroup
)
return
ret_set_errno
(
false
,
EEXIST
);
if
(
!
handler
||
!
handler
->
conf
)
return
ret_set_errno
(
false
,
EINVAL
);
conf
=
handler
->
conf
;
if
(
conf
->
cgroup_meta
.
dir
)
if
(
conf
->
cgroup_meta
.
dir
)
tmp
=
lxc_string_join
(
"/"
,
(
const
char
*
[]){
conf
->
cgroup_meta
.
dir
,
handler
->
name
,
NULL
},
false
);
tmp
=
lxc_string_join
(
"/"
,
(
const
char
*
[]){
conf
->
cgroup_meta
.
dir
,
handler
->
name
,
NULL
},
false
);
else
else
tmp
=
lxc_string_replace
(
"%n"
,
handler
->
name
,
ops
->
cgroup_pattern
);
tmp
=
lxc_string_replace
(
"%n"
,
handler
->
name
,
ops
->
cgroup_pattern
);
if
(
!
tmp
)
{
if
(
!
tmp
)
ERROR
(
"Failed expanding cgroup name pattern"
);
return
log_error_errno
(
false
,
ENOMEM
,
return
false
;
"Failed expanding cgroup name pattern"
);
}
len
=
strlen
(
tmp
)
+
5
;
/* leave room for -NNN\0 */
len
=
strlen
(
tmp
)
+
5
;
/* leave room for -NNN\0 */
container_cgroup
=
must_realloc
(
NULL
,
len
);
container_cgroup
=
must_realloc
(
NULL
,
len
);
...
@@ -1399,11 +1403,8 @@ __cgfsng_ops static inline bool cgfsng_payload_create(struct cgroup_ops *ops,
...
@@ -1399,11 +1403,8 @@ __cgfsng_ops static inline bool cgfsng_payload_create(struct cgroup_ops *ops,
offset
=
container_cgroup
+
len
-
5
;
offset
=
container_cgroup
+
len
-
5
;
do
{
do
{
if
(
idx
)
{
if
(
idx
)
ret
=
snprintf
(
offset
,
5
,
"-%d"
,
idx
);
sprintf
(
offset
,
"-%d"
,
idx
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
5
)
return
false
;
}
for
(
i
=
0
;
ops
->
hierarchies
[
i
];
i
++
)
{
for
(
i
=
0
;
ops
->
hierarchies
[
i
];
i
++
)
{
if
(
!
container_create_path_for_hierarchy
(
ops
->
hierarchies
[
i
],
if
(
!
container_create_path_for_hierarchy
(
ops
->
hierarchies
[
i
],
...
@@ -1421,7 +1422,7 @@ __cgfsng_ops static inline bool cgfsng_payload_create(struct cgroup_ops *ops,
...
@@ -1421,7 +1422,7 @@ __cgfsng_ops static inline bool cgfsng_payload_create(struct cgroup_ops *ops,
}
while
(
ops
->
hierarchies
[
i
]
&&
idx
>
0
&&
idx
<
1000
);
}
while
(
ops
->
hierarchies
[
i
]
&&
idx
>
0
&&
idx
<
1000
);
if
(
idx
==
1000
)
if
(
idx
==
1000
)
return
false
;
return
ret_set_errno
(
false
,
ERANGE
)
;
INFO
(
"The container process uses
\"
%s
\"
as cgroup"
,
container_cgroup
);
INFO
(
"The container process uses
\"
%s
\"
as cgroup"
,
container_cgroup
);
ops
->
container_cgroup
=
move_ptr
(
container_cgroup
);
ops
->
container_cgroup
=
move_ptr
(
container_cgroup
);
...
...
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