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
67d54d09
Unverified
Commit
67d54d09
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 #3271 from brauner/2020-02-28/support_cgroup_pattern_2
cgroups: honor lxc.cgroup.pattern if set explicitly II
parents
2bc49098
d6bdd182
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
26 deletions
+25
-26
cgfsng.c
src/lxc/cgroups/cgfsng.c
+15
-12
cgroup.h
src/lxc/cgroups/cgroup.h
+2
-0
initutils.c
src/lxc/initutils.c
+8
-14
No files found.
src/lxc/cgroups/cgfsng.c
View file @
67d54d09
...
@@ -1223,21 +1223,14 @@ static void cgroup_remove_leaf(struct hierarchy *h, bool payload)
...
@@ -1223,21 +1223,14 @@ static void cgroup_remove_leaf(struct hierarchy *h, bool payload)
if
(
payload
)
{
if
(
payload
)
{
__lxc_unused
__do_close_prot_errno
int
fd
=
move_fd
(
h
->
cgfd_con
);
__lxc_unused
__do_close_prot_errno
int
fd
=
move_fd
(
h
->
cgfd_con
);
h
->
cgfd_con
=
-
EBADF
;
full_path
=
move_ptr
(
h
->
container_full_path
);
full_path
=
h
->
container_full_path
;
}
else
{
}
else
{
__lxc_unused
__do_close_prot_errno
int
fd
=
move_fd
(
h
->
cgfd_mon
);
__lxc_unused
__do_close_prot_errno
int
fd
=
move_fd
(
h
->
cgfd_mon
);
h
->
cgfd_mon
=
-
EBADF
;
full_path
=
move_ptr
(
h
->
monitor_full_path
);
full_path
=
h
->
monitor_full_path
;
}
}
if
(
rmdir
(
full_path
))
if
(
full_path
&&
rmdir
(
full_path
))
SYSWARN
(
"Failed to rmdir(
\"
%s
\"
) cgroup"
,
full_path
);
SYSWARN
(
"Failed to rmdir(
\"
%s
\"
) cgroup"
,
full_path
);
if
(
payload
)
h
->
container_full_path
=
NULL
;
else
h
->
monitor_full_path
=
NULL
;
}
}
__cgfsng_ops
static
inline
bool
cgfsng_monitor_create
(
struct
cgroup_ops
*
ops
,
__cgfsng_ops
static
inline
bool
cgfsng_monitor_create
(
struct
cgroup_ops
*
ops
,
...
@@ -1273,10 +1266,15 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
...
@@ -1273,10 +1266,15 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
CGROUP_CREATE_RETRY
,
NULL
);
CGROUP_CREATE_RETRY
,
NULL
);
}
else
if
(
ops
->
cgroup_pattern
)
{
}
else
if
(
ops
->
cgroup_pattern
)
{
__cgroup_tree
=
lxc_string_replace
(
"%n"
,
handler
->
name
,
ops
->
cgroup_pattern
);
__cgroup_tree
=
lxc_string_replace
(
"%n"
,
handler
->
name
,
ops
->
cgroup_pattern
);
if
(
!
__cgroup_tree
)
return
ret_set_errno
(
false
,
ENOMEM
);
cgroup_tree
=
__cgroup_tree
;
cgroup_tree
=
__cgroup_tree
;
monitor_cgroup
=
must_concat
(
&
len
,
cgroup_tree
,
monitor_cgroup
=
must_concat
(
&
len
,
cgroup_tree
,
"/"
,
DEFAULT_MONITOR_CGROUP
,
CGROUP_CREATE_RETRY
,
NULL
);
CGROUP_CREATE_RETRY
,
NULL
);
}
else
{
}
else
{
cgroup_tree
=
NULL
;
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
);
...
@@ -1347,10 +1345,15 @@ __cgfsng_ops static inline bool cgfsng_payload_create(struct cgroup_ops *ops,
...
@@ -1347,10 +1345,15 @@ __cgfsng_ops static inline bool cgfsng_payload_create(struct cgroup_ops *ops,
CGROUP_CREATE_RETRY
,
NULL
);
CGROUP_CREATE_RETRY
,
NULL
);
}
else
if
(
ops
->
cgroup_pattern
)
{
}
else
if
(
ops
->
cgroup_pattern
)
{
__cgroup_tree
=
lxc_string_replace
(
"%n"
,
handler
->
name
,
ops
->
cgroup_pattern
);
__cgroup_tree
=
lxc_string_replace
(
"%n"
,
handler
->
name
,
ops
->
cgroup_pattern
);
if
(
!
__cgroup_tree
)
return
ret_set_errno
(
false
,
ENOMEM
);
cgroup_tree
=
__cgroup_tree
;
cgroup_tree
=
__cgroup_tree
;
container_cgroup
=
must_concat
(
&
len
,
cgroup_tree
,
container_cgroup
=
must_concat
(
&
len
,
cgroup_tree
,
"/"
,
DEFAULT_PAYLOAD_CGROUP
,
CGROUP_CREATE_RETRY
,
NULL
);
CGROUP_CREATE_RETRY
,
NULL
);
}
else
{
}
else
{
cgroup_tree
=
NULL
;
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
);
...
...
src/lxc/cgroups/cgroup.h
View file @
67d54d09
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
#define DEFAULT_CGROUP_MOUNTPOINT "/sys/fs/cgroup"
#define DEFAULT_CGROUP_MOUNTPOINT "/sys/fs/cgroup"
#define DEFAULT_PAYLOAD_CGROUP_PREFIX "lxc.payload."
#define DEFAULT_PAYLOAD_CGROUP_PREFIX "lxc.payload."
#define DEFAULT_MONITOR_CGROUP_PREFIX "lxc.monitor."
#define DEFAULT_MONITOR_CGROUP_PREFIX "lxc.monitor."
#define DEFAULT_PAYLOAD_CGROUP "payload"
#define DEFAULT_MONITOR_CGROUP "monitor"
#define CGROUP_CREATE_RETRY "-NNNN"
#define CGROUP_CREATE_RETRY "-NNNN"
#define CGROUP_CREATE_RETRY_LEN (STRLITERALLEN(CGROUP_CREATE_RETRY))
#define CGROUP_CREATE_RETRY_LEN (STRLITERALLEN(CGROUP_CREATE_RETRY))
#define CGROUP_PIVOT "lxc.pivot"
#define CGROUP_PIVOT "lxc.pivot"
...
...
src/lxc/initutils.c
View file @
67d54d09
...
@@ -169,8 +169,7 @@ const char *lxc_global_config_value(const char *option_name)
...
@@ -169,8 +169,7 @@ const char *lxc_global_config_value(const char *option_name)
free
(
user_lxc_path
);
free
(
user_lxc_path
);
user_lxc_path
=
copy_global_config_value
(
slider1
);
user_lxc_path
=
copy_global_config_value
(
slider1
);
remove_trailing_slashes
(
user_lxc_path
);
remove_trailing_slashes
(
user_lxc_path
);
values
[
i
]
=
user_lxc_path
;
values
[
i
]
=
move_ptr
(
user_lxc_path
);
user_lxc_path
=
NULL
;
goto
out
;
goto
out
;
}
}
...
@@ -182,19 +181,14 @@ const char *lxc_global_config_value(const char *option_name)
...
@@ -182,19 +181,14 @@ const char *lxc_global_config_value(const char *option_name)
/* could not find value, use default */
/* could not find value, use default */
if
(
strcmp
(
option_name
,
"lxc.lxcpath"
)
==
0
)
{
if
(
strcmp
(
option_name
,
"lxc.lxcpath"
)
==
0
)
{
remove_trailing_slashes
(
user_lxc_path
);
remove_trailing_slashes
(
user_lxc_path
);
values
[
i
]
=
user_lxc_path
;
values
[
i
]
=
move_ptr
(
user_lxc_path
);
user_lxc_path
=
NULL
;
}
else
if
(
strcmp
(
option_name
,
"lxc.default_config"
)
==
0
)
{
}
values
[
i
]
=
move_ptr
(
user_default_config_path
);
else
if
(
strcmp
(
option_name
,
"lxc.default_config"
)
==
0
)
{
}
else
if
(
strcmp
(
option_name
,
"lxc.cgroup.pattern"
)
==
0
)
{
values
[
i
]
=
user_default_config_path
;
values
[
i
]
=
move_ptr
(
user_cgroup_pattern
);
user_default_config_path
=
NULL
;
}
else
{
}
else
if
(
strcmp
(
option_name
,
"lxc.cgroup.pattern"
)
==
0
)
{
values
[
i
]
=
user_cgroup_pattern
;
user_cgroup_pattern
=
NULL
;
}
else
values
[
i
]
=
(
*
ptr
)[
1
];
values
[
i
]
=
(
*
ptr
)[
1
];
}
/* special case: if default value is NULL,
/* special case: if default value is NULL,
* and there is no config, don't view that
* and there is no config, don't view that
...
...
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