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
88d5514d
Commit
88d5514d
authored
Oct 09, 2009
by
Daniel Lezcano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the configuration file to the start function
We want to store more information in the configuration structure, especially the ttys. Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
102a5303
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
34 deletions
+34
-34
conf.c
src/lxc/conf.c
+9
-31
conf.h
src/lxc/conf.h
+4
-2
start.c
src/lxc/start.c
+20
-1
start.h
src/lxc/start.h
+1
-0
No files found.
src/lxc/conf.c
View file @
88d5514d
...
...
@@ -1619,66 +1619,44 @@ void lxc_delete_tty(struct lxc_tty_info *tty_info)
tty_info
->
nbtty
=
0
;
}
extern
int
lxc_config_read
(
const
char
*
file
,
struct
lxc_conf
*
conf
);
int
lxc_setup
(
const
char
*
name
,
const
char
*
cons
,
const
struct
lxc_tty_info
*
tty_info
)
int
lxc_setup
(
const
char
*
name
,
struct
lxc_handler
*
handler
)
{
struct
lxc_conf
lxc_conf
;
char
path
[
MAXPATHLEN
];
if
(
lxc_conf_init
(
&
lxc_conf
))
{
ERROR
(
"failed to initialize the configuration"
);
return
-
1
;
}
snprintf
(
path
,
sizeof
(
path
),
LXCPATH
"/%s/config"
,
name
);
if
(
!
access
(
path
,
F_OK
))
{
if
(
lxc_config_read
(
path
,
&
lxc_conf
))
{
ERROR
(
"failed to read the configuration file"
);
return
-
1
;
}
}
if
(
setup_utsname
(
lxc_conf
.
utsname
))
{
if
(
setup_utsname
(
handler
->
lxc_conf
.
utsname
))
{
ERROR
(
"failed to setup the utsname for '%s'"
,
name
);
return
-
1
;
}
if
(
!
lxc_list_empty
(
&
lxc_conf
.
networks
)
&&
setup_network
(
name
))
{
if
(
!
lxc_list_empty
(
&
handler
->
lxc_conf
.
networks
)
&&
setup_network
(
name
))
{
ERROR
(
"failed to setup the network for '%s'"
,
name
);
return
-
1
;
}
if
(
setup_cgroup
(
name
,
&
lxc_conf
.
cgroup
))
{
if
(
setup_cgroup
(
name
,
&
handler
->
lxc_conf
.
cgroup
))
{
ERROR
(
"failed to setup the cgroups for '%s'"
,
name
);
return
-
1
;
}
if
(
setup_mount
(
lxc_conf
.
fstab
))
{
if
(
setup_mount
(
handler
->
lxc_conf
.
fstab
))
{
ERROR
(
"failed to setup the mounts for '%s'"
,
name
);
return
-
1
;
}
if
(
setup_console
(
lxc_conf
.
rootfs
,
cons
))
{
if
(
setup_console
(
handler
->
lxc_conf
.
rootfs
,
handler
->
tty
))
{
ERROR
(
"failed to setup the console for '%s'"
,
name
);
return
-
1
;
}
if
(
setup_tty
(
lxc_conf
.
rootfs
,
tty_info
))
{
if
(
setup_tty
(
handler
->
lxc_conf
.
rootfs
,
&
handler
->
tty_info
))
{
ERROR
(
"failed to setup the ttys for '%s'"
,
name
);
return
-
1
;
}
if
(
setup_rootfs
(
lxc_conf
.
rootfs
))
{
if
(
setup_rootfs
(
handler
->
lxc_conf
.
rootfs
))
{
ERROR
(
"failed to set rootfs for '%s'"
,
name
);
return
-
1
;
}
if
(
setup_pts
(
lxc_conf
.
pts
))
{
if
(
setup_pts
(
handler
->
lxc_conf
.
pts
))
{
ERROR
(
"failed to setup the new pts instance"
);
return
-
1
;
}
...
...
src/lxc/conf.h
View file @
88d5514d
...
...
@@ -176,8 +176,10 @@ extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
/*
* Configure the container from inside
*/
extern
int
lxc_setup
(
const
char
*
name
,
const
char
*
tty
,
const
struct
lxc_tty_info
*
tty_info
);
struct
lxc_handler
;
extern
int
lxc_setup
(
const
char
*
name
,
struct
lxc_handler
*
handler
);
extern
int
conf_has
(
const
char
*
name
,
const
char
*
info
);
...
...
src/lxc/start.c
View file @
88d5514d
...
...
@@ -44,6 +44,9 @@
#include <sys/un.h>
#include <sys/poll.h>
#include <lxc/lxc.h>
#include <lxc/confile.h>
#ifdef HAVE_SYS_SIGNALFD_H
# include <sys/signalfd.h>
#else
...
...
@@ -235,6 +238,7 @@ static int console_init(char *console, size_t size)
struct
lxc_handler
*
lxc_init
(
const
char
*
name
)
{
struct
lxc_handler
*
handler
;
char
path
[
MAXPATHLEN
];
handler
=
malloc
(
sizeof
(
*
handler
));
if
(
!
handler
)
...
...
@@ -252,6 +256,21 @@ struct lxc_handler *lxc_init(const char *name)
goto
out_put_lock
;
}
if
(
lxc_conf_init
(
&
handler
->
lxc_conf
))
{
ERROR
(
"failed to initialize the configuration"
);
goto
out_aborting
;
}
snprintf
(
path
,
sizeof
(
path
),
LXCPATH
"/%s/config"
,
name
);
if
(
!
access
(
path
,
F_OK
))
{
if
(
lxc_config_read
(
path
,
&
handler
->
lxc_conf
))
{
ERROR
(
"failed to read the configuration file"
);
goto
out_aborting
;
}
}
if
(
console_init
(
handler
->
tty
,
sizeof
(
handler
->
tty
)))
{
ERROR
(
"failed to initialize the console"
);
goto
out_aborting
;
...
...
@@ -358,7 +377,7 @@ static int do_start(void *arg)
}
/* Setup the container, ip, names, utsname, ... */
if
(
lxc_setup
(
name
,
handler
->
tty
,
&
handler
->
tty_info
))
{
if
(
lxc_setup
(
name
,
handler
))
{
ERROR
(
"failed to setup the container"
);
goto
out_warn_father
;
}
...
...
src/lxc/start.h
View file @
88d5514d
...
...
@@ -32,6 +32,7 @@ struct lxc_handler {
char
nsgroup
[
MAXPATHLEN
];
sigset_t
oldmask
;
struct
lxc_tty_info
tty_info
;
struct
lxc_conf
lxc_conf
;
};
extern
struct
lxc_handler
*
lxc_init
(
const
char
*
name
);
...
...
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