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
9322b1a3
Unverified
Commit
9322b1a3
authored
Dec 07, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups/cgfsng: rework cgfsng_monitor_create()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
e0c8dc5e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
13 deletions
+23
-13
cgfsng.c
src/lxc/cgroups/cgfsng.c
+16
-12
log.h
src/lxc/log.h
+7
-1
No files found.
src/lxc/cgroups/cgfsng.c
View file @
9322b1a3
...
@@ -1303,14 +1303,22 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
...
@@ -1303,14 +1303,22 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
char
*
offset
,
*
tmp
;
char
*
offset
,
*
tmp
;
int
i
,
idx
=
0
;
int
i
,
idx
=
0
;
size_t
len
;
size_t
len
;
struct
lxc_conf
*
conf
=
handler
->
conf
;
struct
lxc_conf
*
conf
;
if
(
!
conf
)
if
(
!
ops
)
return
false
;
return
ret_set_errno
(
false
,
ENOENT
)
;
if
(
!
ops
->
hierarchies
)
if
(
!
ops
->
hierarchies
)
return
true
;
return
true
;
if
(
ops
->
monitor_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
(
"/"
,
tmp
=
lxc_string_join
(
"/"
,
(
const
char
*
[]){
conf
->
cgroup_meta
.
dir
,
(
const
char
*
[]){
conf
->
cgroup_meta
.
dir
,
...
@@ -1320,7 +1328,7 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
...
@@ -1320,7 +1328,7 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
else
else
tmp
=
must_make_path
(
ops
->
monitor_pattern
,
handler
->
name
,
NULL
);
tmp
=
must_make_path
(
ops
->
monitor_pattern
,
handler
->
name
,
NULL
);
if
(
!
tmp
)
if
(
!
tmp
)
return
false
;
return
ret_set_errno
(
false
,
ENOMEM
)
;
len
=
strlen
(
tmp
)
+
5
;
/* leave room for -NNN\0 */
len
=
strlen
(
tmp
)
+
5
;
/* leave room for -NNN\0 */
monitor_cgroup
=
must_realloc
(
tmp
,
len
);
monitor_cgroup
=
must_realloc
(
tmp
,
len
);
...
@@ -1328,11 +1336,8 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
...
@@ -1328,11 +1336,8 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
*
offset
=
0
;
*
offset
=
0
;
do
{
do
{
if
(
idx
)
{
if
(
idx
)
int
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
(
!
monitor_create_path_for_hierarchy
(
ops
->
hierarchies
[
i
],
if
(
!
monitor_create_path_for_hierarchy
(
ops
->
hierarchies
[
i
],
...
@@ -1351,11 +1356,10 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
...
@@ -1351,11 +1356,10 @@ __cgfsng_ops static inline bool cgfsng_monitor_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 monitor process uses
\"
%s
\"
as cgroup"
,
monitor_cgroup
);
ops
->
monitor_cgroup
=
move_ptr
(
monitor_cgroup
);
ops
->
monitor_cgroup
=
move_ptr
(
monitor_cgroup
);
return
true
;
return
log_info
(
true
,
"The monitor process uses
\"
%s
\"
as cgroup"
,
monitor_cgroup
)
;
}
}
/* Try to create the same cgroup in all hierarchies. Start with cgroup_pattern;
/* Try to create the same cgroup in all hierarchies. Start with cgroup_pattern;
...
...
src/lxc/log.h
View file @
9322b1a3
...
@@ -512,7 +512,7 @@ __unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
...
@@ -512,7 +512,7 @@ __unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
#define log_debug_errno(__ret__, __errno__, format, ...) \
#define log_debug_errno(__ret__, __errno__, format, ...) \
({ \
({ \
errno = __errno__;
\
errno = __errno__;
\
SYSDEBUG(format, ##__VA_ARGS__); \
SYSDEBUG(format, ##__VA_ARGS__); \
__ret__; \
__ret__; \
})
})
...
@@ -523,6 +523,12 @@ __unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
...
@@ -523,6 +523,12 @@ __unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
__ret__; \
__ret__; \
})
})
#define log_info(__ret__, format, ...) \
({ \
INFO(format, ##__VA_ARGS__); \
__ret__; \
})
extern
int
lxc_log_fd
;
extern
int
lxc_log_fd
;
extern
int
lxc_log_syslog
(
int
facility
);
extern
int
lxc_log_syslog
(
int
facility
);
...
...
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