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
3fe8773d
Unverified
Commit
3fe8773d
authored
Dec 10, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroupfs/cgfsng: pass cgroup to cg_legacy_handle_cpuset_hierarchy() as const char *
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
c95a8c8c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
17 deletions
+25
-17
cgfsng.c
src/lxc/cgroups/cgfsng.c
+25
-17
No files found.
src/lxc/cgroups/cgfsng.c
View file @
3fe8773d
...
@@ -553,7 +553,8 @@ static bool is_unified_hierarchy(const struct hierarchy *h)
...
@@ -553,7 +553,8 @@ static bool is_unified_hierarchy(const struct hierarchy *h)
return
h
->
version
==
CGROUP2_SUPER_MAGIC
;
return
h
->
version
==
CGROUP2_SUPER_MAGIC
;
}
}
/* Initialize the cpuset hierarchy in first directory of @gname and set
/*
* Initialize the cpuset hierarchy in first directory of @cgroup_leaf and set
* cgroup.clone_children so that children inherit settings. Since the
* cgroup.clone_children so that children inherit settings. Since the
* h->base_path is populated by init or ourselves, we know it is already
* h->base_path is populated by init or ourselves, we know it is already
* initialized.
* initialized.
...
@@ -561,14 +562,16 @@ static bool is_unified_hierarchy(const struct hierarchy *h)
...
@@ -561,14 +562,16 @@ static bool is_unified_hierarchy(const struct hierarchy *h)
* returns -1 on error, 0 when we didn't created a cgroup, 1 if we created a
* returns -1 on error, 0 when we didn't created a cgroup, 1 if we created a
* cgroup.
* cgroup.
*/
*/
static
int
cg_legacy_handle_cpuset_hierarchy
(
struct
hierarchy
*
h
,
char
*
cgname
)
static
int
cg_legacy_handle_cpuset_hierarchy
(
struct
hierarchy
*
h
,
const
char
*
cgroup_leaf
)
{
{
int
fret
=
-
1
;
int
fret
=
-
1
;
__do_free
char
*
cgpath
=
NULL
;
__do_free
char
*
parent_or_self
=
NULL
,
*
dup
=
NULL
;
__do_close_prot_errno
int
cgroup_fd
=
-
EBADF
;
__do_close_prot_errno
int
cgroup_fd
=
-
EBADF
;
size_t
len
;
int
ret
;
int
ret
;
char
v
;
char
v
;
char
*
slash
;
char
*
leaf
,
*
slash
;
if
(
is_unified_hierarchy
(
h
))
if
(
is_unified_hierarchy
(
h
))
return
0
;
return
0
;
...
@@ -576,35 +579,40 @@ static int cg_legacy_handle_cpuset_hierarchy(struct hierarchy *h, char *cgname)
...
@@ -576,35 +579,40 @@ static int cg_legacy_handle_cpuset_hierarchy(struct hierarchy *h, char *cgname)
if
(
!
string_in_list
(
h
->
controllers
,
"cpuset"
))
if
(
!
string_in_list
(
h
->
controllers
,
"cpuset"
))
return
0
;
return
0
;
if
(
*
cgname
==
'/'
)
if
(
!
cgroup_leaf
)
cgname
++
;
return
ret_set_errno
(
-
1
,
EINVAL
);
slash
=
strchr
(
cgname
,
'/'
);
dup
=
strdup
(
cgroup_leaf
);
if
(
!
dup
)
return
ret_set_errno
(
-
1
,
ENOMEM
);
leaf
+=
strspn
(
leaf
,
"/"
);
slash
=
strchr
(
leaf
,
'/'
);
if
(
slash
)
if
(
slash
)
*
slash
=
'\0'
;
*
slash
=
'\0'
;
parent_or_self
=
must_make_path
(
h
->
mountpoint
,
h
->
container_base_path
,
leaf
,
NULL
);
cgpath
=
must_make_path
(
h
->
mountpoint
,
h
->
container_base_path
,
cgname
,
NULL
);
if
(
slash
)
if
(
slash
)
*
slash
=
'/'
;
*
slash
=
'/'
;
fret
=
1
;
fret
=
1
;
ret
=
mkdir
(
cgpath
,
0755
);
ret
=
mkdir
(
parent_or_self
,
0755
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
if
(
errno
!=
EEXIST
)
if
(
errno
!=
EEXIST
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to create directory
\"
%s
\"
"
,
cgpath
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to create directory
\"
%s
\"
"
,
parent_or_self
);
fret
=
0
;
fret
=
0
;
}
}
cgroup_fd
=
lxc_open_dirfd
(
cgpath
);
cgroup_fd
=
lxc_open_dirfd
(
parent_or_self
);
if
(
cgroup_fd
<
0
)
if
(
cgroup_fd
<
0
)
return
-
1
;
return
-
1
;
ret
=
lxc_readat
(
cgroup_fd
,
"cgroup.clone_children"
,
&
v
,
1
);
ret
=
lxc_readat
(
cgroup_fd
,
"cgroup.clone_children"
,
&
v
,
1
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to read file
\"
%s/cgroup.clone_children
\"
"
,
cgpath
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to read file
\"
%s/cgroup.clone_children
\"
"
,
parent_or_self
);
/* 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
(
parent_or_self
,
v
==
'1'
))
return
log_error_errno
(
-
1
,
errno
,
"Failed to remove isolated cpus"
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to remove isolated cpus"
);
/* Already set for us by someone else. */
/* Already set for us by someone else. */
...
@@ -612,13 +620,13 @@ static int cg_legacy_handle_cpuset_hierarchy(struct hierarchy *h, char *cgname)
...
@@ -612,13 +620,13 @@ static int cg_legacy_handle_cpuset_hierarchy(struct hierarchy *h, char *cgname)
TRACE
(
"
\"
cgroup.clone_children
\"
was already set to
\"
1
\"
"
);
TRACE
(
"
\"
cgroup.clone_children
\"
was already set to
\"
1
\"
"
);
/* copy parent's settings */
/* copy parent's settings */
if
(
!
copy_parent_file
(
cgpath
,
"cpuset.mems"
))
if
(
!
copy_parent_file
(
parent_or_self
,
"cpuset.mems"
))
return
log_error_errno
(
-
1
,
errno
,
"Failed to copy
\"
cpuset.mems
\"
settings"
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to copy
\"
cpuset.mems
\"
settings"
);
/* Set clone_children so children inherit our settings */
/* Set clone_children so children inherit our settings */
ret
=
lxc_writeat
(
cgroup_fd
,
"cgroup.clone_children"
,
"1"
,
1
);
ret
=
lxc_writeat
(
cgroup_fd
,
"cgroup.clone_children"
,
"1"
,
1
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to write 1 to
\"
%s/cgroup.clone_children
\"
"
,
cgpath
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to write 1 to
\"
%s/cgroup.clone_children
\"
"
,
parent_or_self
);
return
fret
;
return
fret
;
}
}
...
@@ -1228,7 +1236,7 @@ static int mkdir_eexist_on_last(const char *dir, mode_t mode)
...
@@ -1228,7 +1236,7 @@ static int mkdir_eexist_on_last(const char *dir, mode_t mode)
}
}
static
bool
create_cgroup_tree
(
struct
hierarchy
*
h
,
const
char
*
cgroup_tree
,
static
bool
create_cgroup_tree
(
struct
hierarchy
*
h
,
const
char
*
cgroup_tree
,
char
*
cgroup_leaf
,
bool
payload
)
c
onst
c
har
*
cgroup_leaf
,
bool
payload
)
{
{
__do_free
char
*
path
=
NULL
;
__do_free
char
*
path
=
NULL
;
int
ret
,
ret_cpuset
;
int
ret
,
ret_cpuset
;
...
...
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