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
6e2078de
Unverified
Commit
6e2078de
authored
Feb 04, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: improve error handling and logging in cgroup_attach_leaf()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
88c27c53
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
cgfsng.c
src/lxc/cgroups/cgfsng.c
+9
-6
No files found.
src/lxc/cgroups/cgfsng.c
View file @
6e2078de
...
@@ -2233,23 +2233,26 @@ static int cgroup_attach_leaf(const struct lxc_conf *conf, int unified_fd, pid_t
...
@@ -2233,23 +2233,26 @@ static int cgroup_attach_leaf(const struct lxc_conf *conf, int unified_fd, pid_t
int
idx
=
1
;
int
idx
=
1
;
int
ret
;
int
ret
;
char
pidstr
[
INTTYPE_TO_STRLEN
(
int64_t
)
+
1
];
char
pidstr
[
INTTYPE_TO_STRLEN
(
int64_t
)
+
1
];
size_t
pidstr_len
;
s
s
ize_t
pidstr_len
;
/* Create leaf cgroup. */
/* Create leaf cgroup. */
ret
=
mkdirat
(
unified_fd
,
".lxc"
,
0755
);
ret
=
mkdirat
(
unified_fd
,
".lxc"
,
0755
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
if
(
ret
<
0
&&
errno
!=
EEXIST
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to create leaf cgroup
\"
.lxc
\"
"
);
return
log_error_errno
(
-
errno
,
errno
,
"Failed to create leaf cgroup
\"
.lxc
\"
"
);
pidstr_len
=
snprintf
(
pidstr
,
sizeof
(
pidstr
),
INT64_FMT
,
(
int64_t
)
pid
);
if
(
pidstr_len
<
0
||
(
size_t
)
pidstr_len
>=
sizeof
(
pidstr
))
return
ret_errno
(
EIO
);
pidstr_len
=
sprintf
(
pidstr
,
INT64_FMT
,
(
int64_t
)
pid
);
ret
=
lxc_writeat
(
unified_fd
,
".lxc/cgroup.procs"
,
pidstr
,
pidstr_len
);
ret
=
lxc_writeat
(
unified_fd
,
".lxc/cgroup.procs"
,
pidstr
,
pidstr_len
);
if
(
ret
<
0
)
if
(
ret
<
0
)
ret
=
lxc_writeat
(
unified_fd
,
"cgroup.procs"
,
pidstr
,
pidstr_len
);
ret
=
lxc_writeat
(
unified_fd
,
"cgroup.procs"
,
pidstr
,
pidstr_len
);
if
(
ret
==
0
)
if
(
ret
==
0
)
return
0
;
return
log_trace
(
0
,
"Moved process %s into cgroup %d(.lxc)"
,
pidstr
,
unified_fd
)
;
/* this is a non-leaf node */
/* this is a non-leaf node */
if
(
errno
!=
EBUSY
)
if
(
errno
!=
EBUSY
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to attach to unified cgroup"
);
return
log_error_errno
(
-
errno
,
errno
,
"Failed to attach to unified cgroup"
);
do
{
do
{
bool
rm
=
false
;
bool
rm
=
false
;
...
@@ -2281,7 +2284,7 @@ static int cgroup_attach_leaf(const struct lxc_conf *conf, int unified_fd, pid_t
...
@@ -2281,7 +2284,7 @@ static int cgroup_attach_leaf(const struct lxc_conf *conf, int unified_fd, pid_t
ret
=
lxc_writeat
(
unified_fd
,
attach_cgroup
,
pidstr
,
pidstr_len
);
ret
=
lxc_writeat
(
unified_fd
,
attach_cgroup
,
pidstr
,
pidstr_len
);
if
(
ret
==
0
)
if
(
ret
==
0
)
return
0
;
return
log_trace
(
0
,
"Moved process %s into cgroup %d(%s)"
,
pidstr
,
unified_fd
,
attach_cgroup
)
;
if
(
rm
&&
unlinkat
(
unified_fd
,
attach_cgroup
,
AT_REMOVEDIR
))
if
(
rm
&&
unlinkat
(
unified_fd
,
attach_cgroup
,
AT_REMOVEDIR
))
SYSERROR
(
"Failed to remove cgroup
\"
%d(%s)
\"
"
,
unified_fd
,
attach_cgroup
);
SYSERROR
(
"Failed to remove cgroup
\"
%d(%s)
\"
"
,
unified_fd
,
attach_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