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
300df83e
Unverified
Commit
300df83e
authored
Aug 16, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile: lxc_getconfig() -> lxc_get_config()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
0c9a9339
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
17 deletions
+25
-17
commands.c
src/lxc/commands.c
+1
-1
confile.c
src/lxc/confile.c
+6
-3
confile.h
src/lxc/confile.h
+1
-1
confile_legacy.c
src/lxc/confile_legacy.c
+1
-1
lxccontainer.c
src/lxc/lxccontainer.c
+15
-10
config_jump_table.c
src/tests/config_jump_table.c
+1
-1
No files found.
src/lxc/commands.c
View file @
300df83e
...
@@ -516,7 +516,7 @@ static int lxc_cmd_get_config_item_callback(int fd, struct lxc_cmd_req *req,
...
@@ -516,7 +516,7 @@ static int lxc_cmd_get_config_item_callback(int fd, struct lxc_cmd_req *req,
struct
lxc_config_t
*
item
;
struct
lxc_config_t
*
item
;
memset
(
&
rsp
,
0
,
sizeof
(
rsp
));
memset
(
&
rsp
,
0
,
sizeof
(
rsp
));
item
=
lxc_getconfig
(
req
->
data
);
item
=
lxc_get
_
config
(
req
->
data
);
if
(
!
item
)
if
(
!
item
)
goto
err1
;
goto
err1
;
cilen
=
item
->
get
(
req
->
data
,
NULL
,
0
,
handler
->
conf
,
NULL
);
cilen
=
item
->
get
(
req
->
data
,
NULL
,
0
,
handler
->
conf
,
NULL
);
...
...
src/lxc/confile.c
View file @
300df83e
...
@@ -356,13 +356,14 @@ static const struct signame signames[] = {
...
@@ -356,13 +356,14 @@ static const struct signame signames[] = {
static
const
size_t
config_size
=
sizeof
(
config
)
/
sizeof
(
struct
lxc_config_t
);
static
const
size_t
config_size
=
sizeof
(
config
)
/
sizeof
(
struct
lxc_config_t
);
extern
struct
lxc_config_t
*
lxc_get
config
(
const
char
*
key
)
struct
lxc_config_t
*
lxc_get_
config
(
const
char
*
key
)
{
{
size_t
i
;
size_t
i
;
for
(
i
=
0
;
i
<
config_size
;
i
++
)
for
(
i
=
0
;
i
<
config_size
;
i
++
)
if
(
!
strncmp
(
config
[
i
].
name
,
key
,
strlen
(
config
[
i
].
name
)))
if
(
!
strncmp
(
config
[
i
].
name
,
key
,
strlen
(
config
[
i
].
name
)))
return
&
config
[
i
];
return
&
config
[
i
];
return
NULL
;
return
NULL
;
}
}
...
@@ -2038,7 +2039,7 @@ static int parse_line(char *buffer, void *data)
...
@@ -2038,7 +2039,7 @@ static int parse_line(char *buffer, void *data)
}
}
}
}
config
=
lxc_getconfig
(
key
);
config
=
lxc_get
_
config
(
key
);
if
(
!
config
)
{
if
(
!
config
)
{
ERROR
(
"unknown key %s"
,
key
);
ERROR
(
"unknown key %s"
,
key
);
goto
out
;
goto
out
;
...
@@ -3607,7 +3608,7 @@ static struct lxc_config_t *get_network_config_ops(const char *key,
...
@@ -3607,7 +3608,7 @@ static struct lxc_config_t *get_network_config_ops(const char *key,
memmove
(
copy
+
8
,
idx_end
+
1
,
strlen
(
idx_end
+
1
));
memmove
(
copy
+
8
,
idx_end
+
1
,
strlen
(
idx_end
+
1
));
copy
[
strlen
(
key
)
-
numstrlen
+
1
]
=
'\0'
;
copy
[
strlen
(
key
)
-
numstrlen
+
1
]
=
'\0'
;
config
=
lxc_getconfig
(
copy
);
config
=
lxc_get
_
config
(
copy
);
if
(
!
config
)
{
if
(
!
config
)
{
ERROR
(
"unknown network configuration key %s"
,
key
);
ERROR
(
"unknown network configuration key %s"
,
key
);
goto
on_error
;
goto
on_error
;
...
@@ -4442,8 +4443,10 @@ int lxc_list_config_items(char *retv, int inlen)
...
@@ -4442,8 +4443,10 @@ int lxc_list_config_items(char *retv, int inlen)
for
(
i
=
0
;
i
<
config_size
;
i
++
)
{
for
(
i
=
0
;
i
<
config_size
;
i
++
)
{
char
*
s
=
config
[
i
].
name
;
char
*
s
=
config
[
i
].
name
;
if
(
s
[
strlen
(
s
)
-
1
]
==
'.'
)
if
(
s
[
strlen
(
s
)
-
1
]
==
'.'
)
continue
;
continue
;
strprint
(
retv
,
inlen
,
"%s
\n
"
,
s
);
strprint
(
retv
,
inlen
,
"%s
\n
"
,
s
);
}
}
...
...
src/lxc/confile.h
View file @
300df83e
...
@@ -47,7 +47,7 @@ struct lxc_config_t {
...
@@ -47,7 +47,7 @@ struct lxc_config_t {
config_clr_cb
clr
;
config_clr_cb
clr
;
};
};
extern
struct
lxc_config_t
*
lxc_getconfig
(
const
char
*
key
);
extern
struct
lxc_config_t
*
lxc_get
_
config
(
const
char
*
key
);
/* List all configuration items associated with a given network. For example
/* List all configuration items associated with a given network. For example
* pass "lxc.net.[i]" to retrieve all configuration items associated with
* pass "lxc.net.[i]" to retrieve all configuration items associated with
...
...
src/lxc/confile_legacy.c
View file @
300df83e
...
@@ -91,7 +91,7 @@ int set_config_network_legacy_nic(const char *key, const char *value,
...
@@ -91,7 +91,7 @@ int set_config_network_legacy_nic(const char *key, const char *value,
goto
out
;
goto
out
;
strcpy
(
copy
+
12
,
p
+
1
);
strcpy
(
copy
+
12
,
p
+
1
);
config
=
lxc_getconfig
(
copy
);
config
=
lxc_get
_
config
(
copy
);
if
(
!
config
)
{
if
(
!
config
)
{
ERROR
(
"unknown key %s"
,
key
);
ERROR
(
"unknown key %s"
,
key
);
goto
out
;
goto
out
;
...
...
src/lxc/lxccontainer.c
View file @
300df83e
...
@@ -1902,7 +1902,7 @@ static bool do_lxcapi_clear_config_item(struct lxc_container *c,
...
@@ -1902,7 +1902,7 @@ static bool do_lxcapi_clear_config_item(struct lxc_container *c,
if
(
container_mem_lock
(
c
))
if
(
container_mem_lock
(
c
))
return
false
;
return
false
;
config
=
lxc_getconfig
(
key
);
config
=
lxc_get
_
config
(
key
);
/* Verify that the config key exists and that it has a callback
/* Verify that the config key exists and that it has a callback
* implemented.
* implemented.
*/
*/
...
@@ -2218,7 +2218,7 @@ static int do_lxcapi_get_config_item(struct lxc_container *c, const char *key, c
...
@@ -2218,7 +2218,7 @@ static int do_lxcapi_get_config_item(struct lxc_container *c, const char *key, c
if
(
container_mem_lock
(
c
))
if
(
container_mem_lock
(
c
))
return
-
1
;
return
-
1
;
config
=
lxc_getconfig
(
key
);
config
=
lxc_get
_
config
(
key
);
/* Verify that the config key exists and that it has a callback
/* Verify that the config key exists and that it has a callback
* implemented.
* implemented.
*/
*/
...
@@ -2248,22 +2248,27 @@ WRAP_API_1(char *, lxcapi_get_running_config_item, const char *)
...
@@ -2248,22 +2248,27 @@ WRAP_API_1(char *, lxcapi_get_running_config_item, const char *)
static
int
do_lxcapi_get_keys
(
struct
lxc_container
*
c
,
const
char
*
key
,
char
*
retv
,
int
inlen
)
static
int
do_lxcapi_get_keys
(
struct
lxc_container
*
c
,
const
char
*
key
,
char
*
retv
,
int
inlen
)
{
{
int
ret
=
-
1
;
/* List all config items. */
if
(
!
key
)
if
(
!
key
)
return
lxc_list_config_items
(
retv
,
inlen
);
return
lxc_list_config_items
(
retv
,
inlen
);
/*
* Support 'lxc.net.<idx>', i.e. 'lxc.net.0'
* This is an intelligent result to show which keys are valid given
* the type of nic it is
*/
if
(
!
c
||
!
c
->
lxc_conf
)
if
(
!
c
||
!
c
->
lxc_conf
)
return
-
1
;
return
-
1
;
if
(
container_mem_lock
(
c
))
if
(
container_mem_lock
(
c
))
return
-
1
;
return
-
1
;
int
ret
=
-
1
;
/* Support 'lxc.net.<idx>', i.e. 'lxc.net.0'
* This is an intelligent result to show which keys are valid given the
* type of nic it is.
*/
if
(
!
strncmp
(
key
,
"lxc.net."
,
8
))
if
(
!
strncmp
(
key
,
"lxc.net."
,
8
))
ret
=
lxc_list_net
(
c
->
lxc_conf
,
key
,
retv
,
inlen
);
ret
=
lxc_list_net
(
c
->
lxc_conf
,
key
,
retv
,
inlen
);
else
if
(
strncmp
(
key
,
"lxc.network."
,
12
)
==
0
)
else
if
(
strncmp
(
key
,
"lxc.network."
,
12
)
==
0
)
ret
=
lxc_list_nicconfigs_legacy
(
c
->
lxc_conf
,
key
,
retv
,
inlen
);
ret
=
lxc_list_nicconfigs_legacy
(
c
->
lxc_conf
,
key
,
retv
,
inlen
);
container_mem_unlock
(
c
);
container_mem_unlock
(
c
);
return
ret
;
return
ret
;
}
}
...
@@ -2755,7 +2760,7 @@ static bool set_config_item_locked(struct lxc_container *c, const char *key, con
...
@@ -2755,7 +2760,7 @@ static bool set_config_item_locked(struct lxc_container *c, const char *key, con
if
(
!
c
->
lxc_conf
)
if
(
!
c
->
lxc_conf
)
return
false
;
return
false
;
config
=
lxc_getconfig
(
key
);
config
=
lxc_get
_
config
(
key
);
if
(
!
config
)
if
(
!
config
)
return
false
;
return
false
;
...
@@ -4867,5 +4872,5 @@ free_ct_name:
...
@@ -4867,5 +4872,5 @@ free_ct_name:
bool
lxc_config_item_is_supported
(
const
char
*
key
)
bool
lxc_config_item_is_supported
(
const
char
*
key
)
{
{
return
!!
lxc_getconfig
(
key
);
return
!!
lxc_get
_
config
(
key
);
}
}
src/tests/config_jump_table.c
View file @
300df83e
...
@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
...
@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
for
(
key
=
strtok_r
(
keys
,
"
\n
"
,
&
saveptr
);
key
!=
NULL
;
for
(
key
=
strtok_r
(
keys
,
"
\n
"
,
&
saveptr
);
key
!=
NULL
;
key
=
strtok_r
(
NULL
,
"
\n
"
,
&
saveptr
))
{
key
=
strtok_r
(
NULL
,
"
\n
"
,
&
saveptr
))
{
struct
lxc_config_t
*
config
;
struct
lxc_config_t
*
config
;
config
=
lxc_getconfig
(
key
);
config
=
lxc_get
_
config
(
key
);
if
(
!
config
)
{
if
(
!
config
)
{
lxc_error
(
"configuration key
\"
%s
\"
not implemented in "
lxc_error
(
"configuration key
\"
%s
\"
not implemented in "
"jump table"
,
"jump table"
,
...
...
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