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
7793add3
Unverified
Commit
7793add3
authored
Feb 17, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgfsng: cg_legacy_handle_cpuset_hierarchy()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
b095a8eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
19 deletions
+29
-19
cgfsng.c
src/lxc/cgroups/cgfsng.c
+29
-19
No files found.
src/lxc/cgroups/cgfsng.c
View file @
7793add3
...
@@ -687,15 +687,16 @@ on_error:
...
@@ -687,15 +687,16 @@ on_error:
return
false
;
return
false
;
}
}
/*
/* Initialize the cpuset hierarchy in first directory of @gname and set
* Initialize the cpuset hierarchy in first directory of @gname and
* cgroup.clone_children so that children inherit settings. Since the
* set cgroup.clone_children so that children inherit settings.
* h->base_path is populated by init or ourselves, we know it is already
* Since the h->base_path is populated by init or ourselves, we know
* initialized.
* it is already initialized.
*/
*/
static
bool
cg_legacy_handle_cpuset_hierarchy
(
struct
hierarchy
*
h
,
char
*
cgname
)
static
bool
cg_legacy_handle_cpuset_hierarchy
(
struct
hierarchy
*
h
,
char
*
cgname
)
{
{
char
*
cgpath
,
*
clonechildrenpath
,
v
,
*
slash
;
int
ret
;
char
v
;
char
*
cgpath
,
*
clonechildrenpath
,
*
slash
;
if
(
!
string_in_list
(
h
->
controllers
,
"cpuset"
))
if
(
!
string_in_list
(
h
->
controllers
,
"cpuset"
))
return
true
;
return
true
;
...
@@ -709,21 +710,28 @@ static bool cg_legacy_handle_cpuset_hierarchy(struct hierarchy *h, char *cgname)
...
@@ -709,21 +710,28 @@ static bool cg_legacy_handle_cpuset_hierarchy(struct hierarchy *h, char *cgname)
cgpath
=
must_make_path
(
h
->
mountpoint
,
h
->
base_cgroup
,
cgname
,
NULL
);
cgpath
=
must_make_path
(
h
->
mountpoint
,
h
->
base_cgroup
,
cgname
,
NULL
);
if
(
slash
)
if
(
slash
)
*
slash
=
'/'
;
*
slash
=
'/'
;
if
(
mkdir
(
cgpath
,
0755
)
<
0
&&
errno
!=
EEXIST
)
{
SYSERROR
(
"Failed to create '%s'"
,
cgpath
);
ret
=
mkdir
(
cgpath
,
0755
);
free
(
cgpath
);
if
(
ret
<
0
)
{
return
false
;
if
(
errno
!=
EEXIST
)
{
SYSERROR
(
"Failed to create directory
\"
%s
\"
"
,
cgpath
);
free
(
cgpath
);
return
false
;
}
}
}
clonechildrenpath
=
must_make_path
(
cgpath
,
"cgroup.clone_children"
,
NULL
);
clonechildrenpath
=
must_make_path
(
cgpath
,
"cgroup.clone_children"
,
NULL
);
/* unified hierarchy doesn't have clone_children */
/* unified hierarchy doesn't have clone_children */
if
(
!
file_exists
(
clonechildrenpath
))
{
if
(
!
file_exists
(
clonechildrenpath
))
{
free
(
clonechildrenpath
);
free
(
clonechildrenpath
);
free
(
cgpath
);
free
(
cgpath
);
return
true
;
return
true
;
}
}
if
(
lxc_read_from_file
(
clonechildrenpath
,
&
v
,
1
)
<
0
)
{
SYSERROR
(
"Failed to read '%s'"
,
clonechildrenpath
);
ret
=
lxc_read_from_file
(
clonechildrenpath
,
&
v
,
1
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to read file
\"
%s
\"
"
,
clonechildrenpath
);
free
(
clonechildrenpath
);
free
(
clonechildrenpath
);
free
(
cgpath
);
free
(
cgpath
);
return
false
;
return
false
;
...
@@ -731,14 +739,15 @@ static bool cg_legacy_handle_cpuset_hierarchy(struct hierarchy *h, char *cgname)
...
@@ -731,14 +739,15 @@ static bool cg_legacy_handle_cpuset_hierarchy(struct hierarchy *h, char *cgname)
/* Make sure any isolated cpus are removed from cpuset.cpus. */
/* Make sure any isolated cpus are removed from cpuset.cpus. */
if
(
!
cg_legacy_filter_and_set_cpus
(
cgpath
,
v
==
'1'
))
{
if
(
!
cg_legacy_filter_and_set_cpus
(
cgpath
,
v
==
'1'
))
{
SYSERROR
(
"Failed to remove isolated cpus
.
"
);
SYSERROR
(
"Failed to remove isolated cpus"
);
free
(
clonechildrenpath
);
free
(
clonechildrenpath
);
free
(
cgpath
);
free
(
cgpath
);
return
false
;
return
false
;
}
}
if
(
v
==
'1'
)
{
/* already set for us by someone else */
/* Already set for us by someone else. */
DEBUG
(
"
\"
cgroup.clone_children
\"
was already set to
\"
1
\"
."
);
if
(
v
==
'1'
)
{
DEBUG
(
"
\"
cgroup.clone_children
\"
was already set to
\"
1
\"
"
);
free
(
clonechildrenpath
);
free
(
clonechildrenpath
);
free
(
cgpath
);
free
(
cgpath
);
return
true
;
return
true
;
...
@@ -746,16 +755,17 @@ static bool cg_legacy_handle_cpuset_hierarchy(struct hierarchy *h, char *cgname)
...
@@ -746,16 +755,17 @@ static bool cg_legacy_handle_cpuset_hierarchy(struct hierarchy *h, char *cgname)
/* copy parent's settings */
/* copy parent's settings */
if
(
!
copy_parent_file
(
cgpath
,
"cpuset.mems"
))
{
if
(
!
copy_parent_file
(
cgpath
,
"cpuset.mems"
))
{
SYSERROR
(
"Failed to copy
\"
cpuset.mems
\"
settings
.
"
);
SYSERROR
(
"Failed to copy
\"
cpuset.mems
\"
settings"
);
free
(
cgpath
);
free
(
cgpath
);
free
(
clonechildrenpath
);
free
(
clonechildrenpath
);
return
false
;
return
false
;
}
}
free
(
cgpath
);
free
(
cgpath
);
if
(
lxc_write_to_file
(
clonechildrenpath
,
"1"
,
1
,
false
)
<
0
)
{
ret
=
lxc_write_to_file
(
clonechildrenpath
,
"1"
,
1
,
false
);
if
(
ret
<
0
)
{
/* Set clone_children so children inherit our settings */
/* Set clone_children so children inherit our settings */
SYSERROR
(
"Failed to write 1 to
%s
"
,
clonechildrenpath
);
SYSERROR
(
"Failed to write 1 to
\"
%s
\"
"
,
clonechildrenpath
);
free
(
clonechildrenpath
);
free
(
clonechildrenpath
);
return
false
;
return
false
;
}
}
...
...
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