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
ee91fa06
Unverified
Commit
ee91fa06
authored
Dec 08, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile: cleanup __set_config_cgroup_controller()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
c4d9b159
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
20 deletions
+22
-20
conf.h
src/lxc/conf.h
+11
-0
confile.c
src/lxc/confile.c
+11
-20
No files found.
src/lxc/conf.h
View file @
ee91fa06
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "config.h"
#include "config.h"
#include "list.h"
#include "list.h"
#include "lxcseccomp.h"
#include "lxcseccomp.h"
#include "memory_utils.h"
#include "ringbuf.h"
#include "ringbuf.h"
#include "start.h"
#include "start.h"
#include "terminal.h"
#include "terminal.h"
...
@@ -69,6 +70,16 @@ struct lxc_cgroup {
...
@@ -69,6 +70,16 @@ struct lxc_cgroup {
};
};
};
};
static
void
free_lxc_cgroup
(
struct
lxc_cgroup
*
ptr
)
{
if
(
ptr
)
{
free
(
ptr
->
subsystem
);
free
(
ptr
->
value
);
free_disarm
(
ptr
);
}
}
define_cleanup_function
(
struct
lxc_cgroup
*
,
free_lxc_cgroup
);
#if !HAVE_SYS_RESOURCE_H
#if !HAVE_SYS_RESOURCE_H
#define RLIM_INFINITY ((unsigned long)-1)
#define RLIM_INFINITY ((unsigned long)-1)
struct
rlimit
{
struct
rlimit
{
...
...
src/lxc/confile.c
View file @
ee91fa06
...
@@ -1686,10 +1686,10 @@ static int set_config_signal_stop(const char *key, const char *value,
...
@@ -1686,10 +1686,10 @@ static int set_config_signal_stop(const char *key, const char *value,
static
int
__set_config_cgroup_controller
(
const
char
*
key
,
const
char
*
value
,
static
int
__set_config_cgroup_controller
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
int
version
)
struct
lxc_conf
*
lxc_conf
,
int
version
)
{
{
__do_free
struct
lxc_list
*
cglist
=
NULL
;
call_cleaner
(
free_lxc_cgroup
)
struct
lxc_cgroup
*
cgelem
=
NULL
;
const
char
*
subkey
,
*
token
;
const
char
*
subkey
,
*
token
;
size_t
token_len
;
size_t
token_len
;
struct
lxc_list
*
cglist
=
NULL
;
struct
lxc_cgroup
*
cgelem
=
NULL
;
if
(
lxc_config_value_empty
(
value
))
if
(
lxc_config_value_empty
(
value
))
return
lxc_clear_cgroups
(
lxc_conf
,
key
,
version
);
return
lxc_clear_cgroups
(
lxc_conf
,
key
,
version
);
...
@@ -1701,53 +1701,44 @@ static int __set_config_cgroup_controller(const char *key, const char *value,
...
@@ -1701,53 +1701,44 @@ static int __set_config_cgroup_controller(const char *key, const char *value,
token
=
"lxc.cgroup."
;
token
=
"lxc.cgroup."
;
token_len
=
11
;
token_len
=
11
;
}
else
{
}
else
{
return
-
EINVAL
;
return
ret_errno
(
EINVAL
)
;
}
}
if
(
strncmp
(
key
,
token
,
token_len
)
!=
0
)
if
(
strncmp
(
key
,
token
,
token_len
)
!=
0
)
return
-
EINVAL
;
return
ret_errno
(
EINVAL
)
;
subkey
=
key
+
token_len
;
subkey
=
key
+
token_len
;
if
(
*
subkey
==
'\0'
)
if
(
*
subkey
==
'\0'
)
return
-
EINVAL
;
return
ret_errno
(
EINVAL
)
;
cglist
=
malloc
(
sizeof
(
*
cglist
));
cglist
=
malloc
(
sizeof
(
*
cglist
));
if
(
!
cglist
)
if
(
!
cglist
)
goto
out
;
return
ret_errno
(
ENOMEM
)
;
cgelem
=
malloc
(
sizeof
(
*
cgelem
));
cgelem
=
malloc
(
sizeof
(
*
cgelem
));
if
(
!
cgelem
)
if
(
!
cgelem
)
goto
out
;
return
ret_errno
(
ENOMEM
)
;
memset
(
cgelem
,
0
,
sizeof
(
*
cgelem
));
memset
(
cgelem
,
0
,
sizeof
(
*
cgelem
));
cgelem
->
subsystem
=
strdup
(
subkey
);
cgelem
->
subsystem
=
strdup
(
subkey
);
if
(
!
cgelem
->
subsystem
)
if
(
!
cgelem
->
subsystem
)
goto
out
;
return
ret_errno
(
ENOMEM
)
;
cgelem
->
value
=
strdup
(
value
);
cgelem
->
value
=
strdup
(
value
);
if
(
!
cgelem
->
value
)
if
(
!
cgelem
->
value
)
goto
out
;
return
ret_errno
(
ENOMEM
)
;
cgelem
->
version
=
version
;
cgelem
->
version
=
version
;
lxc_list_add_elem
(
cglist
,
cgelem
);
lxc_list_add_elem
(
cglist
,
move_ptr
(
cgelem
)
);
if
(
version
==
CGROUP2_SUPER_MAGIC
)
if
(
version
==
CGROUP2_SUPER_MAGIC
)
lxc_list_add_tail
(
&
lxc_conf
->
cgroup2
,
cglist
);
lxc_list_add_tail
(
&
lxc_conf
->
cgroup2
,
cglist
);
else
else
lxc_list_add_tail
(
&
lxc_conf
->
cgroup
,
cglist
);
lxc_list_add_tail
(
&
lxc_conf
->
cgroup
,
cglist
);
move_ptr
(
cglist
);
return
0
;
return
0
;
out:
free
(
cglist
);
if
(
cgelem
)
{
free
(
cgelem
->
subsystem
);
free
(
cgelem
->
value
);
free
(
cgelem
);
}
return
-
1
;
}
}
static
int
set_config_cgroup_controller
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_cgroup_controller
(
const
char
*
key
,
const
char
*
value
,
...
...
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