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
029d8e88
Unverified
Commit
029d8e88
authored
Feb 02, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: move down cgroup_attach()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
739af847
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
36 deletions
+36
-36
cgfsng.c
src/lxc/cgroups/cgfsng.c
+36
-36
No files found.
src/lxc/cgroups/cgfsng.c
View file @
029d8e88
...
@@ -2350,42 +2350,6 @@ static int cgroup_unified_attach_parent_wrapper(void *data)
...
@@ -2350,42 +2350,6 @@ static int cgroup_unified_attach_parent_wrapper(void *data)
args
->
pid
);
args
->
pid
);
}
}
int
cgroup_attach
(
const
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
,
pid_t
pid
)
{
__do_close
int
unified_fd
=
-
EBADF
;
int
ret
;
if
(
!
conf
||
!
name
||
!
lxcpath
||
pid
<=
0
)
return
ret_errno
(
EINVAL
);
unified_fd
=
lxc_cmd_get_cgroup2_fd
(
name
,
lxcpath
);
if
(
unified_fd
<
0
)
return
ret_errno
(
EBADF
);
if
(
!
lxc_list_empty
(
&
conf
->
id_map
))
{
struct
userns_exec_unified_attach_data
args
=
{
.
conf
=
conf
,
.
unified_fd
=
unified_fd
,
.
pid
=
pid
,
};
ret
=
socketpair
(
PF_LOCAL
,
SOCK_STREAM
|
SOCK_CLOEXEC
,
0
,
args
.
sk_pair
);
if
(
ret
<
0
)
return
-
errno
;
ret
=
userns_exec_minimal
(
conf
,
cgroup_unified_attach_parent_wrapper
,
&
args
,
cgroup_unified_attach_child_wrapper
,
&
args
);
}
else
{
ret
=
cgroup_attach_leaf
(
conf
,
unified_fd
,
pid
);
}
return
ret
;
}
/* Technically, we're always at a delegation boundary here (This is especially
/* Technically, we're always at a delegation boundary here (This is especially
* true when cgroup namespaces are available.). The reasoning is that in order
* true when cgroup namespaces are available.). The reasoning is that in order
* for us to have been able to start a container in the first place the root
* for us to have been able to start a container in the first place the root
...
@@ -3495,6 +3459,42 @@ struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf)
...
@@ -3495,6 +3459,42 @@ struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf)
return
move_ptr
(
cgfsng_ops
);
return
move_ptr
(
cgfsng_ops
);
}
}
int
cgroup_attach
(
const
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
,
pid_t
pid
)
{
__do_close
int
unified_fd
=
-
EBADF
;
int
ret
;
if
(
!
conf
||
!
name
||
!
lxcpath
||
pid
<=
0
)
return
ret_errno
(
EINVAL
);
unified_fd
=
lxc_cmd_get_cgroup2_fd
(
name
,
lxcpath
);
if
(
unified_fd
<
0
)
return
ret_errno
(
EBADF
);
if
(
!
lxc_list_empty
(
&
conf
->
id_map
))
{
struct
userns_exec_unified_attach_data
args
=
{
.
conf
=
conf
,
.
unified_fd
=
unified_fd
,
.
pid
=
pid
,
};
ret
=
socketpair
(
PF_LOCAL
,
SOCK_STREAM
|
SOCK_CLOEXEC
,
0
,
args
.
sk_pair
);
if
(
ret
<
0
)
return
-
errno
;
ret
=
userns_exec_minimal
(
conf
,
cgroup_unified_attach_parent_wrapper
,
&
args
,
cgroup_unified_attach_child_wrapper
,
&
args
);
}
else
{
ret
=
cgroup_attach_leaf
(
conf
,
unified_fd
,
pid
);
}
return
ret
;
}
/* Connects to command socket therefore isn't callable from command handler. */
/* Connects to command socket therefore isn't callable from command handler. */
int
cgroup_get
(
const
char
*
name
,
const
char
*
lxcpath
,
int
cgroup_get
(
const
char
*
name
,
const
char
*
lxcpath
,
const
char
*
filename
,
char
*
buf
,
size_t
len
)
const
char
*
filename
,
char
*
buf
,
size_t
len
)
...
...
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