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
cb6d63a7
Commit
cb6d63a7
authored
May 01, 2015
by
Serge Hallyn
Committed by
Stéphane Graber
May 26, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make cgmanager follow lxc.cgroup.use
Signed-off-by:
Serge Hallyn
<
serge.hallyn@ubuntu.com
>
Acked-by:
Stéphane Graber
<
stgraber@ubuntu.com
>
parent
4295c5de
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
cgmanager.c
src/lxc/cgmanager.c
+82
-0
No files found.
src/lxc/cgmanager.c
View file @
cb6d63a7
...
@@ -1093,6 +1093,76 @@ static void cull_user_controllers(void)
...
@@ -1093,6 +1093,76 @@ static void cull_user_controllers(void)
}
}
}
}
static
bool
in_comma_list
(
const
char
*
inword
,
const
char
*
cgroup_use
)
{
char
*
e
;
size_t
inlen
=
strlen
(
inword
),
len
;
do
{
e
=
strchr
(
cgroup_use
,
','
);
len
=
e
?
e
-
cgroup_use
:
strlen
(
cgroup_use
);
if
(
len
==
inlen
&&
strncmp
(
inword
,
cgroup_use
,
len
)
==
0
)
return
true
;
cgroup_use
=
e
+
1
;
}
while
(
e
);
return
false
;
}
static
bool
in_subsystem_list
(
const
char
*
c
)
{
int
i
;
for
(
i
=
0
;
i
<
nr_subsystems
;
i
++
)
{
if
(
strcmp
(
c
,
subsystems
[
i
])
==
0
)
return
true
;
}
return
false
;
}
/*
* If /etc/lxc/lxc.conf specifies lxc.cgroup.use = "freezer,memory",
* then clear out any other subsystems, and make sure that freezer
* and memory are both enabled
*/
static
bool
verify_and_prune
(
const
char
*
cgroup_use
)
{
const
char
*
p
;
char
*
e
;
int
i
,
j
;
for
(
p
=
cgroup_use
;
p
&&
*
p
;
p
=
e
+
1
)
{
e
=
strchr
(
p
,
','
);
if
(
e
)
*
e
=
'\0'
;
if
(
!
in_subsystem_list
(
p
))
{
ERROR
(
"Controller %s required by lxc.cgroup.use but not available
\n
"
,
p
);
return
false
;
}
if
(
e
)
*
e
=
','
;
if
(
!
e
)
break
;
}
for
(
i
=
0
;
i
<
nr_subsystems
;)
{
if
(
in_comma_list
(
subsystems
[
i
],
cgroup_use
))
{
i
++
;
continue
;
}
free
(
subsystems
[
i
]);
for
(
j
=
i
;
j
<
nr_subsystems
-
1
;
j
++
)
subsystems
[
j
]
=
subsystems
[
j
+
1
];
subsystems
[
nr_subsystems
-
1
]
=
NULL
;
nr_subsystems
--
;
}
return
true
;
}
static
bool
collect_subsytems
(
void
)
static
bool
collect_subsytems
(
void
)
{
{
char
*
line
=
NULL
;
char
*
line
=
NULL
;
...
@@ -1154,6 +1224,18 @@ static bool collect_subsytems(void)
...
@@ -1154,6 +1224,18 @@ static bool collect_subsytems(void)
return
false
;
return
false
;
}
}
/* make sure that cgroup.use can be and is honored */
const
char
*
cgroup_use
=
lxc_global_config_value
(
"lxc.cgroup.use"
);
if
(
!
cgroup_use
&&
errno
!=
0
)
goto
out_good
;
if
(
cgroup_use
)
{
if
(
!
verify_and_prune
(
cgroup_use
))
goto
out_free
;
subsystems_inone
[
0
]
=
NIH_MUST
(
strdup
(
cgroup_use
)
);
cgm_all_controllers_same
=
false
;
}
out_good:
return
true
;
return
true
;
out_free:
out_free:
...
...
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