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
7a41e857
Unverified
Commit
7a41e857
authored
May 19, 2018
by
Liza Tretyakova
Committed by
Christian Brauner
Jul 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf, confile, lxccontainer, start: nonfunctional changes
Signed-off-by:
Liza Tretyakova
<
elizabet.tretyakova@gmail.com
>
parent
1f5a90f9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
32 deletions
+33
-32
conf.c
src/lxc/conf.c
+8
-7
conf.h
src/lxc/conf.h
+2
-2
confile.c
src/lxc/confile.c
+3
-3
lxccontainer.c
src/lxc/lxccontainer.c
+7
-7
start.c
src/lxc/start.c
+13
-13
No files found.
src/lxc/conf.c
View file @
7a41e857
...
@@ -656,12 +656,12 @@ static int add_shmount_to_list(struct lxc_conf *conf) {
...
@@ -656,12 +656,12 @@ static int add_shmount_to_list(struct lxc_conf *conf) {
int
ret
=
-
1
,
offset
=
1
;
int
ret
=
-
1
,
offset
=
1
;
/* +1 for the separating whitespace */
/* +1 for the separating whitespace */
len_mount
=
strlen
(
conf
->
lxc_
shmount
.
path_host
)
+
1
len_mount
=
strlen
(
conf
->
shmount
.
path_host
)
+
1
+
strlen
(
conf
->
lxc_
shmount
.
path_cont
)
-
offset
+
strlen
(
conf
->
shmount
.
path_cont
)
-
offset
+
sizeof
(
" none bind,create=dir 0 0"
)
-
1
;
+
sizeof
(
" none bind,create=dir 0 0"
)
-
1
;
ret
=
snprintf
(
new_mount
,
len_mount
+
1
,
"%s %s none bind,create=dir 0 0"
,
ret
=
snprintf
(
new_mount
,
len_mount
+
1
,
"%s %s none bind,create=dir 0 0"
,
conf
->
lxc_shmount
.
path_host
,
conf
->
lxc_
shmount
.
path_cont
+
offset
);
conf
->
shmount
.
path_host
,
conf
->
shmount
.
path_cont
+
offset
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
len_mount
+
1
)
if
(
ret
<
0
||
(
size_t
)
ret
>=
len_mount
+
1
)
return
-
1
;
return
-
1
;
...
@@ -2747,8 +2747,9 @@ struct lxc_conf *lxc_conf_init(void)
...
@@ -2747,8 +2747,9 @@ struct lxc_conf *lxc_conf_init(void)
new
->
lsm_aa_profile
=
NULL
;
new
->
lsm_aa_profile
=
NULL
;
new
->
lsm_se_context
=
NULL
;
new
->
lsm_se_context
=
NULL
;
new
->
tmp_umount_proc
=
false
;
new
->
tmp_umount_proc
=
false
;
new
->
lxc_shmount
.
path_host
=
NULL
;
new
->
tmp_umount_proc
=
0
;
new
->
lxc_shmount
.
path_cont
=
NULL
;
new
->
shmount
.
path_host
=
NULL
;
new
->
shmount
.
path_cont
=
NULL
;
/* if running in a new user namespace, init and COMMAND
/* if running in a new user namespace, init and COMMAND
* default to running as UID/GID 0 when using lxc-execute */
* default to running as UID/GID 0 when using lxc-execute */
...
@@ -4076,8 +4077,8 @@ void lxc_conf_free(struct lxc_conf *conf)
...
@@ -4076,8 +4077,8 @@ void lxc_conf_free(struct lxc_conf *conf)
lxc_clear_procs
(
conf
,
"lxc.proc"
);
lxc_clear_procs
(
conf
,
"lxc.proc"
);
free
(
conf
->
cgroup_meta
.
dir
);
free
(
conf
->
cgroup_meta
.
dir
);
free
(
conf
->
cgroup_meta
.
controllers
);
free
(
conf
->
cgroup_meta
.
controllers
);
free
(
conf
->
lxc_
shmount
.
path_host
);
free
(
conf
->
shmount
.
path_host
);
free
(
conf
->
lxc_
shmount
.
path_cont
);
free
(
conf
->
shmount
.
path_cont
);
free
(
conf
);
free
(
conf
);
}
}
...
...
src/lxc/conf.h
View file @
7a41e857
...
@@ -371,12 +371,12 @@ struct lxc_conf {
...
@@ -371,12 +371,12 @@ struct lxc_conf {
/* procs */
/* procs */
struct
lxc_list
procs
;
struct
lxc_list
procs
;
struct
lxc_
shmount
{
struct
shmount
{
/* Absolute path to the shared mount point on the host */
/* Absolute path to the shared mount point on the host */
char
*
path_host
;
char
*
path_host
;
/* Absolute path (in the container) to the shared mount point */
/* Absolute path (in the container) to the shared mount point */
char
*
path_cont
;
char
*
path_cont
;
}
lxc_
shmount
;
}
shmount
;
};
};
extern
int
write_id_mapping
(
enum
idtype
idtype
,
pid_t
pid
,
const
char
*
buf
,
extern
int
write_id_mapping
(
enum
idtype
idtype
,
pid_t
pid
,
const
char
*
buf
,
...
...
src/lxc/confile.c
View file @
7a41e857
...
@@ -1704,12 +1704,12 @@ static int set_config_mount_auto(const char *key, const char *value,
...
@@ -1704,12 +1704,12 @@ static int set_config_mount_auto(const char *key, const char *value,
lxc_conf
->
auto_mounts
&=
~
allowed_auto_mounts
[
i
].
mask
;
lxc_conf
->
auto_mounts
&=
~
allowed_auto_mounts
[
i
].
mask
;
lxc_conf
->
auto_mounts
|=
allowed_auto_mounts
[
i
].
flag
;
lxc_conf
->
auto_mounts
|=
allowed_auto_mounts
[
i
].
flag
;
if
(
is_shmounts
)
{
if
(
is_shmounts
)
{
lxc_conf
->
lxc_
shmount
.
path_host
=
strdup
(
token
+
(
sizeof
(
"shmounts:"
)
-
1
));
lxc_conf
->
shmount
.
path_host
=
strdup
(
token
+
(
sizeof
(
"shmounts:"
)
-
1
));
if
(
strcmp
(
lxc_conf
->
lxc_
shmount
.
path_host
,
""
)
==
0
)
{
if
(
strcmp
(
lxc_conf
->
shmount
.
path_host
,
""
)
==
0
)
{
ERROR
(
"Invalid shmounts path: empty"
);
ERROR
(
"Invalid shmounts path: empty"
);
break
;
break
;
}
}
lxc_conf
->
lxc_
shmount
.
path_cont
=
strdup
(
"/dev/.lxc-mounts"
);
lxc_conf
->
shmount
.
path_cont
=
strdup
(
"/dev/.lxc-mounts"
);
}
}
}
}
...
...
src/lxc/lxccontainer.c
View file @
7a41e857
...
@@ -4966,13 +4966,13 @@ static int do_lxcapi_mount(struct lxc_container *c, const char *source,
...
@@ -4966,13 +4966,13 @@ static int do_lxcapi_mount(struct lxc_container *c, const char *source,
return
-
EINVAL
;
return
-
EINVAL
;
}
}
if
(
!
c
->
lxc_conf
->
lxc_
shmount
.
path_host
)
{
if
(
!
c
->
lxc_conf
->
shmount
.
path_host
)
{
ERROR
(
"Host path to shared mountpoint must be specified in the config
\n
"
);
ERROR
(
"Host path to shared mountpoint must be specified in the config
\n
"
);
return
-
EINVAL
;
return
-
EINVAL
;
}
}
len
=
strlen
(
c
->
lxc_conf
->
lxc_
shmount
.
path_host
)
+
sizeof
(
"/.lxcmount_XXXXXX"
)
-
1
;
len
=
strlen
(
c
->
lxc_conf
->
shmount
.
path_host
)
+
sizeof
(
"/.lxcmount_XXXXXX"
)
-
1
;
ret
=
snprintf
(
template
,
len
+
1
,
"%s/.lxcmount_XXXXXX"
,
c
->
lxc_conf
->
lxc_
shmount
.
path_host
);
ret
=
snprintf
(
template
,
len
+
1
,
"%s/.lxcmount_XXXXXX"
,
c
->
lxc_conf
->
shmount
.
path_host
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
len
+
1
)
{
if
(
ret
<
0
||
(
size_t
)
ret
>=
len
+
1
)
{
SYSERROR
(
"Error writing shmounts tempdir name"
);
SYSERROR
(
"Error writing shmounts tempdir name"
);
goto
out
;
goto
out
;
...
@@ -5048,8 +5048,8 @@ static int do_lxcapi_mount(struct lxc_container *c, const char *source,
...
@@ -5048,8 +5048,8 @@ static int do_lxcapi_mount(struct lxc_container *c, const char *source,
if
(
!
suff
)
if
(
!
suff
)
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
len
=
strlen
(
c
->
lxc_conf
->
lxc_
shmount
.
path_cont
)
+
sizeof
(
"/.lxcmount_XXXXXX"
)
-
1
;
len
=
strlen
(
c
->
lxc_conf
->
shmount
.
path_cont
)
+
sizeof
(
"/.lxcmount_XXXXXX"
)
-
1
;
ret
=
snprintf
(
path
,
len
+
1
,
"%s%s"
,
c
->
lxc_conf
->
lxc_
shmount
.
path_cont
,
suff
);
ret
=
snprintf
(
path
,
len
+
1
,
"%s%s"
,
c
->
lxc_conf
->
shmount
.
path_cont
,
suff
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
len
+
1
)
{
if
(
ret
<
0
||
(
size_t
)
ret
>=
len
+
1
)
{
SYSERROR
(
"Error writing container mountpoint name"
);
SYSERROR
(
"Error writing container mountpoint name"
);
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
...
@@ -5087,7 +5087,7 @@ WRAP_API_6(int, lxcapi_mount, const char *, const char *, const char *,
...
@@ -5087,7 +5087,7 @@ WRAP_API_6(int, lxcapi_mount, const char *, const char *, const char *,
unsigned
long
,
const
void
*
,
struct
lxc_mount
*
)
unsigned
long
,
const
void
*
,
struct
lxc_mount
*
)
static
int
do_lxcapi_umount
(
struct
lxc_container
*
c
,
const
char
*
target
,
static
int
do_lxcapi_umount
(
struct
lxc_container
*
c
,
const
char
*
target
,
unsigned
long
mount
flags
,
struct
lxc_mount
*
mnt
)
unsigned
long
flags
,
struct
lxc_mount
*
mnt
)
{
{
pid_t
pid
,
init_pid
;
pid_t
pid
,
init_pid
;
int
ret
=
-
1
;
int
ret
=
-
1
;
...
@@ -5125,7 +5125,7 @@ static int do_lxcapi_umount(struct lxc_container *c, const char *target,
...
@@ -5125,7 +5125,7 @@ static int do_lxcapi_umount(struct lxc_container *c, const char *target,
}
}
/* Do the unmount */
/* Do the unmount */
ret
=
umount2
(
target
,
mount
flags
);
ret
=
umount2
(
target
,
flags
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to umount
\"
%s
\"
"
,
target
);
SYSERROR
(
"Failed to umount
\"
%s
\"
"
,
target
);
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
...
...
src/lxc/start.c
View file @
7a41e857
...
@@ -1536,14 +1536,14 @@ static int lxc_setup_shmount(struct lxc_conf *conf) {
...
@@ -1536,14 +1536,14 @@ static int lxc_setup_shmount(struct lxc_conf *conf) {
/* Construct the shmount path under the container root */
/* Construct the shmount path under the container root */
/* +1 for slash */
/* +1 for slash */
len_cont
=
strlen
(
conf
->
rootfs
.
mount
)
+
1
+
strlen
(
conf
->
lxc_
shmount
.
path_cont
);
len_cont
=
strlen
(
conf
->
rootfs
.
mount
)
+
1
+
strlen
(
conf
->
shmount
.
path_cont
);
/* +1 for the terminating '\0' */
/* +1 for the terminating '\0' */
full_cont_path
=
malloc
(
len_cont
+
1
);
full_cont_path
=
malloc
(
len_cont
+
1
);
if
(
!
full_cont_path
)
{
if
(
!
full_cont_path
)
{
SYSERROR
(
"Not enough memory"
);
SYSERROR
(
"Not enough memory"
);
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
ret
=
snprintf
(
full_cont_path
,
len_cont
+
1
,
"%s/%s"
,
conf
->
rootfs
.
mount
,
conf
->
lxc_
shmount
.
path_cont
);
ret
=
snprintf
(
full_cont_path
,
len_cont
+
1
,
"%s/%s"
,
conf
->
rootfs
.
mount
,
conf
->
shmount
.
path_cont
);
if
(
ret
<
0
||
ret
>=
len_cont
+
1
)
{
if
(
ret
<
0
||
ret
>=
len_cont
+
1
)
{
SYSERROR
(
"Failed to create filename"
);
SYSERROR
(
"Failed to create filename"
);
free
(
full_cont_path
);
free
(
full_cont_path
);
...
@@ -1551,16 +1551,16 @@ static int lxc_setup_shmount(struct lxc_conf *conf) {
...
@@ -1551,16 +1551,16 @@ static int lxc_setup_shmount(struct lxc_conf *conf) {
}
}
/* Check if shmount point is already set up */
/* Check if shmount point is already set up */
if
(
is_shared_mountpoint
(
conf
->
lxc_
shmount
.
path_host
))
{
if
(
is_shared_mountpoint
(
conf
->
shmount
.
path_host
))
{
INFO
(
"Path
\"
%s
\"
is already MS_SHARED. Reusing"
,
conf
->
lxc_
shmount
.
path_host
);
INFO
(
"Path
\"
%s
\"
is already MS_SHARED. Reusing"
,
conf
->
shmount
.
path_host
);
free
(
full_cont_path
);
free
(
full_cont_path
);
return
0
;
return
0
;
}
}
/* Create host and cont mount paths */
/* Create host and cont mount paths */
ret
=
mkdir_p
(
conf
->
lxc_
shmount
.
path_host
,
0711
);
ret
=
mkdir_p
(
conf
->
shmount
.
path_host
,
0711
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
SYSERROR
(
"Failed to create directory
\"
%s
\"
"
,
conf
->
lxc_
shmount
.
path_host
);
SYSERROR
(
"Failed to create directory
\"
%s
\"
"
,
conf
->
shmount
.
path_host
);
free
(
full_cont_path
);
free
(
full_cont_path
);
return
ret
;
return
ret
;
}
}
...
@@ -1573,22 +1573,22 @@ static int lxc_setup_shmount(struct lxc_conf *conf) {
...
@@ -1573,22 +1573,22 @@ static int lxc_setup_shmount(struct lxc_conf *conf) {
}
}
/* Prepare host mountpoint */
/* Prepare host mountpoint */
ret
=
mount
(
"tmpfs"
,
conf
->
lxc_
shmount
.
path_host
,
"tmpfs"
,
ret
=
mount
(
"tmpfs"
,
conf
->
shmount
.
path_host
,
"tmpfs"
,
0
,
"size=100k,mode=0711"
);
0
,
"size=100k,mode=0711"
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to mount
\"
%s
\"
"
,
conf
->
lxc_
shmount
.
path_host
);
SYSERROR
(
"Failed to mount
\"
%s
\"
"
,
conf
->
shmount
.
path_host
);
free
(
full_cont_path
);
free
(
full_cont_path
);
return
ret
;
return
ret
;
}
}
ret
=
mount
(
conf
->
lxc_shmount
.
path_host
,
conf
->
lxc_
shmount
.
path_host
,
"none"
,
ret
=
mount
(
conf
->
shmount
.
path_host
,
conf
->
shmount
.
path_host
,
"none"
,
MS_REC
|
MS_SHARED
,
""
);
MS_REC
|
MS_SHARED
,
""
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to make shared
\"
%s
\"
"
,
conf
->
lxc_
shmount
.
path_host
);
SYSERROR
(
"Failed to make shared
\"
%s
\"
"
,
conf
->
shmount
.
path_host
);
free
(
full_cont_path
);
free
(
full_cont_path
);
return
ret
;
return
ret
;
}
}
INFO
(
"Made shared mount point
\"
%s
\"
"
,
conf
->
lxc_
shmount
.
path_host
);
INFO
(
"Made shared mount point
\"
%s
\"
"
,
conf
->
shmount
.
path_host
);
free
(
full_cont_path
);
free
(
full_cont_path
);
return
0
;
return
0
;
}
}
...
@@ -1670,12 +1670,12 @@ static int lxc_spawn(struct lxc_handler *handler)
...
@@ -1670,12 +1670,12 @@ static int lxc_spawn(struct lxc_handler *handler)
}
}
}
}
if
(
conf
->
lxc_shmount
.
path_host
&&
!
conf
->
lxc_
shmount
.
path_cont
)
{
if
(
conf
->
shmount
.
path_host
&&
!
conf
->
shmount
.
path_cont
)
{
ERROR
(
"Missing the container side path to the shared mount point"
);
ERROR
(
"Missing the container side path to the shared mount point"
);
lxc_sync_fini
(
handler
);
lxc_sync_fini
(
handler
);
return
-
1
;
return
-
1
;
}
}
if
(
conf
->
lxc_
shmount
.
path_host
)
{
if
(
conf
->
shmount
.
path_host
)
{
ret
=
lxc_setup_shmount
(
conf
);
ret
=
lxc_setup_shmount
(
conf
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
ERROR
(
"Failed to setup shared mount point"
);
ERROR
(
"Failed to setup shared mount point"
);
...
...
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