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
fd543fe0
Unverified
Commit
fd543fe0
authored
Dec 23, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
console: adapt lxc_console_mainloop_add()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
a93bfc5f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
24 deletions
+28
-24
console.c
src/lxc/console.c
+8
-14
console.h
src/lxc/console.h
+1
-1
start.c
src/lxc/start.c
+18
-8
lxc_attach.c
src/lxc/tools/lxc_attach.c
+1
-1
No files found.
src/lxc/console.c
View file @
fd543fe0
...
@@ -269,31 +269,25 @@ static int lxc_console_mainloop_add_peer(struct lxc_console *console)
...
@@ -269,31 +269,25 @@ static int lxc_console_mainloop_add_peer(struct lxc_console *console)
return
0
;
return
0
;
}
}
extern
int
lxc_console_mainloop_add
(
struct
lxc_epoll_descr
*
descr
,
int
lxc_console_mainloop_add
(
struct
lxc_epoll_descr
*
descr
,
struct
lxc_conf
*
conf
)
struct
lxc_console
*
console
)
{
{
int
ret
;
int
ret
;
struct
lxc_console
*
console
=
&
conf
->
console
;
if
(
!
conf
->
rootfs
.
path
)
{
INFO
(
"no rootfs, no console."
);
return
0
;
}
if
(
console
->
master
<
0
)
{
if
(
console
->
master
<
0
)
{
INFO
(
"no console"
);
INFO
(
"no console"
);
return
0
;
return
0
;
}
}
if
(
lxc_mainloop_add_handler
(
descr
,
console
->
master
,
ret
=
lxc_mainloop_add_handler
(
descr
,
console
->
master
,
lxc_console_cb_con
,
console
))
{
lxc_console_cb_con
,
console
);
ERROR
(
"failed to add to mainloop console handler for '%d'"
,
if
(
ret
<
0
)
{
console
->
master
);
ERROR
(
"Failed to add handler for %d to mainloop"
,
console
->
master
);
return
-
1
;
return
-
1
;
}
}
/*
w
e cache the descr so that we can add an fd to it when someone
/*
W
e cache the descr so that we can add an fd to it when someone
* does attach to it in lxc_console_allocate()
* does attach to it in lxc_console_allocate()
.
*/
*/
console
->
descr
=
descr
;
console
->
descr
=
descr
;
ret
=
lxc_console_mainloop_add_peer
(
console
);
ret
=
lxc_console_mainloop_add_peer
(
console
);
...
...
src/lxc/console.h
View file @
fd543fe0
...
@@ -114,7 +114,7 @@ extern void lxc_console_free(struct lxc_conf *conf, int fd);
...
@@ -114,7 +114,7 @@ extern void lxc_console_free(struct lxc_conf *conf, int fd);
/*
/*
* Register pty event handlers in an open mainloop
* Register pty event handlers in an open mainloop
*/
*/
extern
int
lxc_console_mainloop_add
(
struct
lxc_epoll_descr
*
,
struct
lxc_con
f
*
);
extern
int
lxc_console_mainloop_add
(
struct
lxc_epoll_descr
*
,
struct
lxc_con
sole
*
);
/*
/*
* Handle SIGWINCH events on the allocated ptys.
* Handle SIGWINCH events on the allocated ptys.
...
...
src/lxc/start.c
View file @
fd543fe0
...
@@ -459,6 +459,7 @@ int lxc_set_state(const char *name, struct lxc_handler *handler,
...
@@ -459,6 +459,7 @@ int lxc_set_state(const char *name, struct lxc_handler *handler,
int
lxc_poll
(
const
char
*
name
,
struct
lxc_handler
*
handler
)
int
lxc_poll
(
const
char
*
name
,
struct
lxc_handler
*
handler
)
{
{
int
ret
;
int
ret
;
bool
has_console
=
(
handler
->
conf
->
rootfs
.
path
!=
NULL
);
struct
lxc_epoll_descr
descr
,
descr_console
;
struct
lxc_epoll_descr
descr
,
descr_console
;
ret
=
lxc_mainloop_open
(
&
descr
);
ret
=
lxc_mainloop_open
(
&
descr
);
...
@@ -467,11 +468,13 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
...
@@ -467,11 +468,13 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
goto
out_sigfd
;
goto
out_sigfd
;
}
}
if
(
has_console
)
{
ret
=
lxc_mainloop_open
(
&
descr_console
);
ret
=
lxc_mainloop_open
(
&
descr_console
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
ERROR
(
"Failed to create console mainloop"
);
ERROR
(
"Failed to create console mainloop"
);
goto
out_mainloop
;
goto
out_mainloop
;
}
}
}
ret
=
lxc_mainloop_add_handler
(
&
descr
,
handler
->
sigfd
,
signal_handler
,
handler
);
ret
=
lxc_mainloop_add_handler
(
&
descr
,
handler
->
sigfd
,
signal_handler
,
handler
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -479,12 +482,6 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
...
@@ -479,12 +482,6 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
goto
out_mainloop_console
;
goto
out_mainloop_console
;
}
}
ret
=
lxc_console_mainloop_add
(
&
descr
,
handler
->
conf
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to add console handlers to mainloop"
);
goto
out_mainloop_console
;
}
if
(
handler
->
conf
->
need_utmp_watch
)
{
if
(
handler
->
conf
->
need_utmp_watch
)
{
#if HAVE_LIBCAP
#if HAVE_LIBCAP
if
(
lxc_utmp_mainloop_add
(
&
descr
,
handler
))
{
if
(
lxc_utmp_mainloop_add
(
&
descr
,
handler
))
{
...
@@ -495,13 +492,22 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
...
@@ -495,13 +492,22 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
DEBUG
(
"Not starting utmp handler as CAP_SYS_BOOT cannot be dropped without capabilities support."
);
DEBUG
(
"Not starting utmp handler as CAP_SYS_BOOT cannot be dropped without capabilities support."
);
#endif
#endif
}
}
TRACE
(
"lxc mainloop is ready"
);
ret
=
lxc_console_mainloop_add
(
&
descr_console
,
handler
->
conf
);
if
(
has_console
)
{
struct
lxc_console
*
console
=
&
handler
->
conf
->
console
;
ret
=
lxc_console_mainloop_add
(
&
descr
,
console
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to add console handlers to mainloop"
);
goto
out_mainloop_console
;
}
ret
=
lxc_console_mainloop_add
(
&
descr_console
,
console
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
ERROR
(
"Failed to add console handlers to console mainloop"
);
ERROR
(
"Failed to add console handlers to console mainloop"
);
goto
out_mainloop_console
;
goto
out_mainloop_console
;
}
}
}
ret
=
lxc_cmd_mainloop_add
(
name
,
&
descr
,
handler
);
ret
=
lxc_cmd_mainloop_add
(
name
,
&
descr
,
handler
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -517,15 +523,19 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
...
@@ -517,15 +523,19 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
if
(
ret
<
0
||
!
handler
->
init_died
)
if
(
ret
<
0
||
!
handler
->
init_died
)
goto
out_mainloop
;
goto
out_mainloop
;
if
(
has_console
)
ret
=
lxc_mainloop
(
&
descr_console
,
0
);
ret
=
lxc_mainloop
(
&
descr_console
,
0
);
out_mainloop:
out_mainloop:
lxc_mainloop_close
(
&
descr
);
lxc_mainloop_close
(
&
descr
);
TRACE
(
"Closed mainloop"
);
TRACE
(
"Closed mainloop"
);
out_mainloop_console:
out_mainloop_console:
if
(
has_console
)
{
lxc_mainloop_close
(
&
descr_console
);
lxc_mainloop_close
(
&
descr_console
);
TRACE
(
"Closed console mainloop"
);
TRACE
(
"Closed console mainloop"
);
}
out_sigfd:
out_sigfd:
close
(
handler
->
sigfd
);
close
(
handler
->
sigfd
);
...
...
src/lxc/tools/lxc_attach.c
View file @
fd543fe0
...
@@ -356,7 +356,7 @@ static int get_pty_on_host(struct lxc_container *c, struct wrapargs *wrap, int *
...
@@ -356,7 +356,7 @@ static int get_pty_on_host(struct lxc_container *c, struct wrapargs *wrap, int *
goto
err2
;
goto
err2
;
}
}
if
(
lxc_console_mainloop_add
(
&
descr
,
conf
)
<
0
)
{
if
(
lxc_console_mainloop_add
(
&
descr
,
&
conf
->
console
)
<
0
)
{
fprintf
(
stderr
,
"Failed to add handlers to lxc mainloop.
\n
"
);
fprintf
(
stderr
,
"Failed to add handlers to lxc mainloop.
\n
"
);
goto
err3
;
goto
err3
;
}
}
...
...
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