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
2bc49098
Unverified
Commit
2bc49098
authored
Feb 28, 2020
by
Stéphane Graber
Committed by
GitHub
Feb 28, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3270 from brauner/2020-02-27/support_cgroup_pattern
cgroups: honor lxc.cgroup.pattern if set explicitly
parents
bf04c850
b3ed2061
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
15 deletions
+23
-15
configure.ac
configure.ac
+1
-1
cgfsng.c
src/lxc/cgroups/cgfsng.c
+21
-13
initutils.c
src/lxc/initutils.c
+1
-1
No files found.
configure.ac
View file @
2bc49098
...
@@ -487,7 +487,7 @@ AC_ARG_WITH([rootfs-path],
...
@@ -487,7 +487,7 @@ AC_ARG_WITH([rootfs-path],
# cgroup pattern specification
# cgroup pattern specification
AC_ARG_WITH([cgroup-pattern],
AC_ARG_WITH([cgroup-pattern],
[AS_HELP_STRING([--with-cgroup-pattern=pattern], [pattern for container cgroups])],
[AS_HELP_STRING([--with-cgroup-pattern=pattern], [pattern for container cgroups])],
[with_cgroup_pattern=$withval], [with_cgroup_pattern=['
lxc.payload.%n
']])
[with_cgroup_pattern=$withval], [with_cgroup_pattern=['']])
# The path for the apparmor_parser's cache for generated apparmor profiles
# The path for the apparmor_parser's cache for generated apparmor profiles
AC_ARG_WITH([apparmor-cache-dir],
AC_ARG_WITH([apparmor-cache-dir],
...
...
src/lxc/cgroups/cgfsng.c
View file @
2bc49098
...
@@ -1243,7 +1243,7 @@ static void cgroup_remove_leaf(struct hierarchy *h, bool payload)
...
@@ -1243,7 +1243,7 @@ static void cgroup_remove_leaf(struct hierarchy *h, bool payload)
__cgfsng_ops
static
inline
bool
cgfsng_monitor_create
(
struct
cgroup_ops
*
ops
,
__cgfsng_ops
static
inline
bool
cgfsng_monitor_create
(
struct
cgroup_ops
*
ops
,
struct
lxc_handler
*
handler
)
struct
lxc_handler
*
handler
)
{
{
__do_free
char
*
monitor_cgroup
=
NULL
;
__do_free
char
*
monitor_cgroup
=
NULL
,
*
__cgroup_tree
=
NULL
;
const
char
*
cgroup_tree
;
const
char
*
cgroup_tree
;
int
idx
=
0
;
int
idx
=
0
;
int
i
;
int
i
;
...
@@ -1264,17 +1264,23 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
...
@@ -1264,17 +1264,23 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
return
ret_set_errno
(
false
,
EINVAL
);
return
ret_set_errno
(
false
,
EINVAL
);
conf
=
handler
->
conf
;
conf
=
handler
->
conf
;
cgroup_tree
=
conf
->
cgroup_meta
.
dir
;
if
(
cgroup_tree
)
if
(
conf
->
cgroup_meta
.
dir
)
{
cgroup_tree
=
conf
->
cgroup_meta
.
dir
;
monitor_cgroup
=
must_concat
(
&
len
,
conf
->
cgroup_meta
.
dir
,
"/"
,
monitor_cgroup
=
must_concat
(
&
len
,
conf
->
cgroup_meta
.
dir
,
"/"
,
DEFAULT_MONITOR_CGROUP_PREFIX
,
DEFAULT_MONITOR_CGROUP_PREFIX
,
handler
->
name
,
handler
->
name
,
CGROUP_CREATE_RETRY
,
NULL
);
CGROUP_CREATE_RETRY
,
NULL
);
else
}
else
if
(
ops
->
cgroup_pattern
)
{
__cgroup_tree
=
lxc_string_replace
(
"%n"
,
handler
->
name
,
ops
->
cgroup_pattern
);
cgroup_tree
=
__cgroup_tree
;
monitor_cgroup
=
must_concat
(
&
len
,
cgroup_tree
,
CGROUP_CREATE_RETRY
,
NULL
);
}
else
{
monitor_cgroup
=
must_concat
(
&
len
,
DEFAULT_MONITOR_CGROUP_PREFIX
,
monitor_cgroup
=
must_concat
(
&
len
,
DEFAULT_MONITOR_CGROUP_PREFIX
,
handler
->
name
,
handler
->
name
,
CGROUP_CREATE_RETRY
,
NULL
);
CGROUP_CREATE_RETRY
,
NULL
);
}
if
(
!
monitor_cgroup
)
if
(
!
monitor_cgroup
)
return
ret_set_errno
(
false
,
ENOMEM
);
return
ret_set_errno
(
false
,
ENOMEM
);
...
@@ -1311,7 +1317,7 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
...
@@ -1311,7 +1317,7 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
__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
;
__do_free
char
*
container_cgroup
=
NULL
,
*
__cgroup_tree
=
NULL
;
const
char
*
cgroup_tree
;
const
char
*
cgroup_tree
;
int
idx
=
0
;
int
idx
=
0
;
int
i
;
int
i
;
...
@@ -1332,17 +1338,23 @@ __cgfsng_ops static inline bool cgfsng_payload_create(struct cgroup_ops *ops,
...
@@ -1332,17 +1338,23 @@ __cgfsng_ops static inline bool cgfsng_payload_create(struct cgroup_ops *ops,
return
ret_set_errno
(
false
,
EINVAL
);
return
ret_set_errno
(
false
,
EINVAL
);
conf
=
handler
->
conf
;
conf
=
handler
->
conf
;
cgroup_tree
=
conf
->
cgroup_meta
.
dir
;
if
(
cgroup_tree
)
if
(
conf
->
cgroup_meta
.
dir
)
{
cgroup_tree
=
conf
->
cgroup_meta
.
dir
;
container_cgroup
=
must_concat
(
&
len
,
cgroup_tree
,
"/"
,
container_cgroup
=
must_concat
(
&
len
,
cgroup_tree
,
"/"
,
DEFAULT_PAYLOAD_CGROUP_PREFIX
,
DEFAULT_PAYLOAD_CGROUP_PREFIX
,
handler
->
name
,
handler
->
name
,
CGROUP_CREATE_RETRY
,
NULL
);
CGROUP_CREATE_RETRY
,
NULL
);
else
}
else
if
(
ops
->
cgroup_pattern
)
{
__cgroup_tree
=
lxc_string_replace
(
"%n"
,
handler
->
name
,
ops
->
cgroup_pattern
);
cgroup_tree
=
__cgroup_tree
;
container_cgroup
=
must_concat
(
&
len
,
cgroup_tree
,
CGROUP_CREATE_RETRY
,
NULL
);
}
else
{
container_cgroup
=
must_concat
(
&
len
,
DEFAULT_PAYLOAD_CGROUP_PREFIX
,
container_cgroup
=
must_concat
(
&
len
,
DEFAULT_PAYLOAD_CGROUP_PREFIX
,
handler
->
name
,
handler
->
name
,
CGROUP_CREATE_RETRY
,
NULL
);
CGROUP_CREATE_RETRY
,
NULL
);
}
if
(
!
container_cgroup
)
if
(
!
container_cgroup
)
return
ret_set_errno
(
false
,
ENOMEM
);
return
ret_set_errno
(
false
,
ENOMEM
);
...
@@ -3179,11 +3191,7 @@ __cgfsng_ops static int cgfsng_data_init(struct cgroup_ops *ops)
...
@@ -3179,11 +3191,7 @@ __cgfsng_ops static int cgfsng_data_init(struct cgroup_ops *ops)
/* copy system-wide cgroup information */
/* copy system-wide cgroup information */
cgroup_pattern
=
lxc_global_config_value
(
"lxc.cgroup.pattern"
);
cgroup_pattern
=
lxc_global_config_value
(
"lxc.cgroup.pattern"
);
if
(
!
cgroup_pattern
)
{
if
(
cgroup_pattern
&&
strcmp
(
cgroup_pattern
,
""
)
!=
0
)
/* lxc.cgroup.pattern is only NULL on error. */
ERROR
(
"Failed to retrieve cgroup pattern"
);
return
ret_set_errno
(
-
1
,
ENOMEM
);
}
ops
->
cgroup_pattern
=
must_copy_string
(
cgroup_pattern
);
ops
->
cgroup_pattern
=
must_copy_string
(
cgroup_pattern
);
return
0
;
return
0
;
...
...
src/lxc/initutils.c
View file @
2bc49098
...
@@ -84,12 +84,12 @@ const char *lxc_global_config_value(const char *option_name)
...
@@ -84,12 +84,12 @@ const char *lxc_global_config_value(const char *option_name)
sprintf
(
user_config_path
,
"%s/.config/lxc/lxc.conf"
,
user_home
);
sprintf
(
user_config_path
,
"%s/.config/lxc/lxc.conf"
,
user_home
);
sprintf
(
user_default_config_path
,
"%s/.config/lxc/default.conf"
,
user_home
);
sprintf
(
user_default_config_path
,
"%s/.config/lxc/default.conf"
,
user_home
);
sprintf
(
user_lxc_path
,
"%s/.local/share/lxc/"
,
user_home
);
sprintf
(
user_lxc_path
,
"%s/.local/share/lxc/"
,
user_home
);
user_cgroup_pattern
=
strdup
(
"%n"
);
}
}
else
{
else
{
user_config_path
=
strdup
(
LXC_GLOBAL_CONF
);
user_config_path
=
strdup
(
LXC_GLOBAL_CONF
);
user_default_config_path
=
strdup
(
LXC_DEFAULT_CONFIG
);
user_default_config_path
=
strdup
(
LXC_DEFAULT_CONFIG
);
user_lxc_path
=
strdup
(
LXCPATH
);
user_lxc_path
=
strdup
(
LXCPATH
);
if
(
strcmp
(
DEFAULT_CGROUP_PATTERN
,
""
)
!=
0
)
user_cgroup_pattern
=
strdup
(
DEFAULT_CGROUP_PATTERN
);
user_cgroup_pattern
=
strdup
(
DEFAULT_CGROUP_PATTERN
);
}
}
...
...
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