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
571e6ec8
Commit
571e6ec8
authored
Oct 09, 2009
by
Daniel Lezcano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move configuration info to the structure
Move configuration informations from the handler structure to the configuration structure. Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
88d5514d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
40 deletions
+41
-40
commands.c
src/lxc/commands.c
+1
-1
conf.c
src/lxc/conf.c
+10
-9
conf.h
src/lxc/conf.h
+21
-19
console.c
src/lxc/console.c
+1
-1
start.c
src/lxc/start.c
+7
-7
start.h
src/lxc/start.h
+1
-3
No files found.
src/lxc/commands.c
View file @
571e6ec8
...
...
@@ -132,7 +132,7 @@ static int trigger_command(int fd, struct lxc_request *request,
static
void
command_fd_cleanup
(
int
fd
,
struct
lxc_handler
*
handler
,
struct
lxc_epoll_descr
*
descr
)
{
lxc_console_remove_fd
(
fd
,
&
handler
->
tty_info
);
lxc_console_remove_fd
(
fd
,
&
handler
->
conf
.
tty_info
);
lxc_mainloop_del_handler
(
descr
,
fd
);
close
(
fd
);
}
...
...
src/lxc/conf.c
View file @
571e6ec8
...
...
@@ -1242,6 +1242,7 @@ int lxc_conf_init(struct lxc_conf *conf)
conf
->
utsname
=
NULL
;
conf
->
tty
=
0
;
conf
->
pts
=
0
;
conf
->
console
[
0
]
=
'\0'
;
lxc_list_init
(
&
conf
->
cgroup
);
lxc_list_init
(
&
conf
->
networks
);
return
0
;
...
...
@@ -1619,44 +1620,44 @@ void lxc_delete_tty(struct lxc_tty_info *tty_info)
tty_info
->
nbtty
=
0
;
}
int
lxc_setup
(
const
char
*
name
,
struct
lxc_
handler
*
handler
)
int
lxc_setup
(
const
char
*
name
,
struct
lxc_
conf
*
lxc_conf
)
{
if
(
setup_utsname
(
handler
->
lxc_conf
.
utsname
))
{
if
(
setup_utsname
(
lxc_conf
->
utsname
))
{
ERROR
(
"failed to setup the utsname for '%s'"
,
name
);
return
-
1
;
}
if
(
!
lxc_list_empty
(
&
handler
->
lxc_conf
.
networks
)
&&
setup_network
(
name
))
{
if
(
!
lxc_list_empty
(
&
lxc_conf
->
networks
)
&&
setup_network
(
name
))
{
ERROR
(
"failed to setup the network for '%s'"
,
name
);
return
-
1
;
}
if
(
setup_cgroup
(
name
,
&
handler
->
lxc_conf
.
cgroup
))
{
if
(
setup_cgroup
(
name
,
&
lxc_conf
->
cgroup
))
{
ERROR
(
"failed to setup the cgroups for '%s'"
,
name
);
return
-
1
;
}
if
(
setup_mount
(
handler
->
lxc_conf
.
fstab
))
{
if
(
setup_mount
(
lxc_conf
->
fstab
))
{
ERROR
(
"failed to setup the mounts for '%s'"
,
name
);
return
-
1
;
}
if
(
setup_console
(
handler
->
lxc_conf
.
rootfs
,
handler
->
tty
))
{
if
(
setup_console
(
lxc_conf
->
rootfs
,
lxc_conf
->
console
))
{
ERROR
(
"failed to setup the console for '%s'"
,
name
);
return
-
1
;
}
if
(
setup_tty
(
handler
->
lxc_conf
.
rootfs
,
&
handler
->
tty_info
))
{
if
(
setup_tty
(
lxc_conf
->
rootfs
,
&
lxc_conf
->
tty_info
))
{
ERROR
(
"failed to setup the ttys for '%s'"
,
name
);
return
-
1
;
}
if
(
setup_rootfs
(
handler
->
lxc_conf
.
rootfs
))
{
if
(
setup_rootfs
(
lxc_conf
->
rootfs
))
{
ERROR
(
"failed to set rootfs for '%s'"
,
name
);
return
-
1
;
}
if
(
setup_pts
(
handler
->
lxc_conf
.
pts
))
{
if
(
setup_pts
(
lxc_conf
->
pts
))
{
ERROR
(
"failed to setup the new pts instance"
);
return
-
1
;
}
...
...
src/lxc/conf.h
View file @
571e6ec8
...
...
@@ -110,24 +110,6 @@ struct lxc_cgroup {
};
/*
* Defines the global container configuration
* @rootfs : the root directory to run the container
* @mount : the list of mount points
* @network : the network configuration
* @utsname : the container utsname
*/
struct
lxc_conf
{
const
char
*
rcfile
;
char
*
rootfs
;
char
*
fstab
;
int
tty
;
int
pts
;
struct
utsname
*
utsname
;
struct
lxc_list
cgroup
;
struct
lxc_list
networks
;
};
/*
* Defines a structure containing a pty information for
* virtualizing a tty
* @name : the path name of the slave pty side
...
...
@@ -152,6 +134,26 @@ struct lxc_tty_info {
};
/*
* Defines the global container configuration
* @rootfs : the root directory to run the container
* @mount : the list of mount points
* @network : the network configuration
* @utsname : the container utsname
*/
struct
lxc_conf
{
const
char
*
rcfile
;
char
*
rootfs
;
char
*
fstab
;
int
tty
;
int
pts
;
struct
utsname
*
utsname
;
struct
lxc_list
cgroup
;
struct
lxc_list
networks
;
struct
lxc_tty_info
tty_info
;
char
console
[
MAXPATHLEN
];
};
/*
* Initialize the lxc configuration structure
*/
extern
int
lxc_conf_init
(
struct
lxc_conf
*
conf
);
...
...
@@ -179,7 +181,7 @@ extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
struct
lxc_handler
;
extern
int
lxc_setup
(
const
char
*
name
,
struct
lxc_
handler
*
handler
);
extern
int
lxc_setup
(
const
char
*
name
,
struct
lxc_
conf
*
lxc_conf
);
extern
int
conf_has
(
const
char
*
name
,
const
char
*
info
);
...
...
src/lxc/console.c
View file @
571e6ec8
...
...
@@ -95,7 +95,7 @@ extern int lxc_console_callback(int fd, struct lxc_request *request,
struct
lxc_handler
*
handler
)
{
int
ttynum
=
request
->
data
;
struct
lxc_tty_info
*
tty_info
=
&
handler
->
tty_info
;
struct
lxc_tty_info
*
tty_info
=
&
handler
->
conf
.
tty_info
;
if
(
ttynum
>
0
)
{
if
(
ttynum
>
tty_info
->
nbtty
)
...
...
src/lxc/start.c
View file @
571e6ec8
...
...
@@ -256,7 +256,7 @@ struct lxc_handler *lxc_init(const char *name)
goto
out_put_lock
;
}
if
(
lxc_conf_init
(
&
handler
->
lxc_
conf
))
{
if
(
lxc_conf_init
(
&
handler
->
conf
))
{
ERROR
(
"failed to initialize the configuration"
);
goto
out_aborting
;
}
...
...
@@ -265,18 +265,18 @@ struct lxc_handler *lxc_init(const char *name)
if
(
!
access
(
path
,
F_OK
))
{
if
(
lxc_config_read
(
path
,
&
handler
->
lxc_
conf
))
{
if
(
lxc_config_read
(
path
,
&
handler
->
conf
))
{
ERROR
(
"failed to read the configuration file"
);
goto
out_aborting
;
}
}
if
(
console_init
(
handler
->
tty
,
sizeof
(
handler
->
tty
)))
{
if
(
console_init
(
handler
->
conf
.
console
,
sizeof
(
handler
->
conf
.
console
)))
{
ERROR
(
"failed to initialize the console"
);
goto
out_aborting
;
}
if
(
lxc_create_tty
(
name
,
&
handler
->
tty_info
))
{
if
(
lxc_create_tty
(
name
,
&
handler
->
conf
.
tty_info
))
{
ERROR
(
"failed to create the ttys"
);
goto
out_aborting
;
}
...
...
@@ -301,7 +301,7 @@ out:
return
handler
;
out_delete_tty:
lxc_delete_tty
(
&
handler
->
tty_info
);
lxc_delete_tty
(
&
handler
->
conf
.
tty_info
);
out_aborting:
set_state
(
name
,
handler
,
ABORTING
);
out_put_lock:
...
...
@@ -323,7 +323,7 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
if
(
handler
)
{
remove_init_pid
(
name
,
handler
->
pid
);
lxc_delete_tty
(
&
handler
->
tty_info
);
lxc_delete_tty
(
&
handler
->
conf
.
tty_info
);
lxc_put_lock
(
handler
->
lock
);
free
(
handler
);
}
...
...
@@ -377,7 +377,7 @@ static int do_start(void *arg)
}
/* Setup the container, ip, names, utsname, ... */
if
(
lxc_setup
(
name
,
handler
))
{
if
(
lxc_setup
(
name
,
&
handler
->
conf
))
{
ERROR
(
"failed to setup the container"
);
goto
out_warn_father
;
}
...
...
src/lxc/start.h
View file @
571e6ec8
...
...
@@ -28,11 +28,9 @@ struct lxc_handler {
int
sigfd
;
int
lock
;
char
tty
[
MAXPATHLEN
];
char
nsgroup
[
MAXPATHLEN
];
sigset_t
oldmask
;
struct
lxc_tty_info
tty_info
;
struct
lxc_conf
lxc_conf
;
struct
lxc_conf
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