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
5a076633
Unverified
Commit
5a076633
authored
Mar 15, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree-wide: port cgroup cleanup to call_cleaner(cgroup_exit)
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
1e22a683
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
25 deletions
+11
-25
attach.c
src/lxc/attach.c
+1
-1
cgroup.h
src/lxc/cgroups/cgroup.h
+3
-8
freezer.c
src/lxc/freezer.c
+1
-1
lxccontainer.c
src/lxc/lxccontainer.c
+6
-15
No files found.
src/lxc/attach.c
View file @
5a076633
...
@@ -1176,7 +1176,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
...
@@ -1176,7 +1176,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
*/
*/
ret
=
cgroup_attach
(
name
,
lxcpath
,
pid
);
ret
=
cgroup_attach
(
name
,
lxcpath
,
pid
);
if
(
ret
)
{
if
(
ret
)
{
__do_cgroup_exit
struct
cgroup_ops
*
cgroup_ops
=
NULL
;
call_cleaner
(
cgroup_exit
)
struct
cgroup_ops
*
cgroup_ops
=
NULL
;
cgroup_ops
=
cgroup_init
(
conf
);
cgroup_ops
=
cgroup_init
(
conf
);
if
(
!
cgroup_ops
)
if
(
!
cgroup_ops
)
...
...
src/lxc/cgroups/cgroup.h
View file @
5a076633
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include <sys/types.h>
#include <sys/types.h>
#include "macro.h"
#include "macro.h"
#include "memory_utils.h"
#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."
...
@@ -171,20 +172,14 @@ struct cgroup_ops {
...
@@ -171,20 +172,14 @@ struct cgroup_ops {
};
};
extern
struct
cgroup_ops
*
cgroup_init
(
struct
lxc_conf
*
conf
);
extern
struct
cgroup_ops
*
cgroup_init
(
struct
lxc_conf
*
conf
);
extern
void
cgroup_exit
(
struct
cgroup_ops
*
ops
);
extern
void
cgroup_exit
(
struct
cgroup_ops
*
ops
);
define_cleanup_function
(
struct
cgroup_ops
*
,
cgroup_exit
);
extern
void
prune_init_scope
(
char
*
cg
);
extern
void
prune_init_scope
(
char
*
cg
);
static
inline
void
__auto_cgroup_exit__
(
struct
cgroup_ops
**
ops
)
{
if
(
*
ops
)
cgroup_exit
(
*
ops
);
}
extern
int
cgroup_attach
(
const
char
*
name
,
const
char
*
lxcpath
,
int64_t
pid
);
extern
int
cgroup_attach
(
const
char
*
name
,
const
char
*
lxcpath
,
int64_t
pid
);
#define __do_cgroup_exit __attribute__((__cleanup__(__auto_cgroup_exit__)))
static
inline
bool
pure_unified_layout
(
const
struct
cgroup_ops
*
ops
)
static
inline
bool
pure_unified_layout
(
const
struct
cgroup_ops
*
ops
)
{
{
return
ops
->
cgroup_layout
==
CGROUP_LAYOUT_UNIFIED
;
return
ops
->
cgroup_layout
==
CGROUP_LAYOUT_UNIFIED
;
...
...
src/lxc/freezer.c
View file @
5a076633
...
@@ -35,7 +35,7 @@ static void notify_state_listeners(const char *name, const char *lxcpath,
...
@@ -35,7 +35,7 @@ static void notify_state_listeners(const char *name, const char *lxcpath,
static
int
do_freeze_thaw
(
bool
freeze
,
struct
lxc_conf
*
conf
,
const
char
*
name
,
static
int
do_freeze_thaw
(
bool
freeze
,
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
)
const
char
*
lxcpath
)
{
{
__do_cgroup_exit
struct
cgroup_ops
*
cgroup_ops
=
NULL
;
call_cleaner
(
cgroup_exit
)
struct
cgroup_ops
*
cgroup_ops
=
NULL
;
lxc_state_t
new_state
=
freeze
?
FROZEN
:
THAWED
;
lxc_state_t
new_state
=
freeze
?
FROZEN
:
THAWED
;
int
ret
;
int
ret
;
const
char
*
state
;
const
char
*
state
;
...
...
src/lxc/lxccontainer.c
View file @
5a076633
...
@@ -3308,8 +3308,7 @@ WRAP_API_1(bool, lxcapi_set_config_path, const char *)
...
@@ -3308,8 +3308,7 @@ WRAP_API_1(bool, lxcapi_set_config_path, const char *)
static
bool
do_lxcapi_set_cgroup_item
(
struct
lxc_container
*
c
,
const
char
*
subsys
,
const
char
*
value
)
static
bool
do_lxcapi_set_cgroup_item
(
struct
lxc_container
*
c
,
const
char
*
subsys
,
const
char
*
value
)
{
{
int
ret
;
call_cleaner
(
cgroup_exit
)
struct
cgroup_ops
*
cgroup_ops
=
NULL
;
struct
cgroup_ops
*
cgroup_ops
;
if
(
!
c
)
if
(
!
c
)
return
false
;
return
false
;
...
@@ -3321,19 +3320,15 @@ static bool do_lxcapi_set_cgroup_item(struct lxc_container *c, const char *subsy
...
@@ -3321,19 +3320,15 @@ static bool do_lxcapi_set_cgroup_item(struct lxc_container *c, const char *subsy
if
(
!
cgroup_ops
)
if
(
!
cgroup_ops
)
return
false
;
return
false
;
ret
=
cgroup_ops
->
set
(
cgroup_ops
,
subsys
,
value
,
c
->
name
,
c
->
config_path
);
return
cgroup_ops
->
set
(
cgroup_ops
,
subsys
,
value
,
c
->
name
,
c
->
config_path
)
==
0
;
cgroup_exit
(
cgroup_ops
);
return
ret
==
0
;
}
}
WRAP_API_2
(
bool
,
lxcapi_set_cgroup_item
,
const
char
*
,
const
char
*
)
WRAP_API_2
(
bool
,
lxcapi_set_cgroup_item
,
const
char
*
,
const
char
*
)
static
int
do_lxcapi_get_cgroup_item
(
struct
lxc_container
*
c
,
const
char
*
subsys
,
char
*
retv
,
int
inlen
)
static
int
do_lxcapi_get_cgroup_item
(
struct
lxc_container
*
c
,
const
char
*
subsys
,
char
*
retv
,
int
inlen
)
{
{
int
ret
;
call_cleaner
(
cgroup_exit
)
struct
cgroup_ops
*
cgroup_ops
=
NULL
;
struct
cgroup_ops
*
cgroup_ops
;
if
(
!
c
)
if
(
!
c
)
return
-
1
;
return
-
1
;
...
@@ -3345,12 +3340,8 @@ static int do_lxcapi_get_cgroup_item(struct lxc_container *c, const char *subsys
...
@@ -3345,12 +3340,8 @@ static int do_lxcapi_get_cgroup_item(struct lxc_container *c, const char *subsys
if
(
!
cgroup_ops
)
if
(
!
cgroup_ops
)
return
-
1
;
return
-
1
;
ret
=
cgroup_ops
->
get
(
cgroup_ops
,
subsys
,
retv
,
inlen
,
c
->
name
,
return
cgroup_ops
->
get
(
cgroup_ops
,
subsys
,
retv
,
inlen
,
c
->
name
,
c
->
config_path
);
c
->
config_path
);
cgroup_exit
(
cgroup_ops
);
return
ret
;
}
}
WRAP_API_3
(
int
,
lxcapi_get_cgroup_item
,
const
char
*
,
char
*
,
int
)
WRAP_API_3
(
int
,
lxcapi_get_cgroup_item
,
const
char
*
,
char
*
,
int
)
...
...
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