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
28f3b1cd
Unverified
Commit
28f3b1cd
authored
Nov 14, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile: add lxc.console.buffer.size
Determines the size of the ringbuffer. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
05e1745c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
25 deletions
+51
-25
lxc.container.conf.sgml.in
doc/lxc.container.conf.sgml.in
+25
-0
commands.c
src/lxc/commands.c
+2
-2
conf.c
src/lxc/conf.c
+2
-2
conf.h
src/lxc/conf.h
+1
-1
confile.c
src/lxc/confile.c
+18
-17
console.c
src/lxc/console.c
+3
-3
No files found.
doc/lxc.container.conf.sgml.in
View file @
28f3b1cd
...
@@ -682,6 +682,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
...
@@ -682,6 +682,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
where the output of this console goes.
where the output of this console goes.
</para>
</para>
<variablelist>
<variablelist>
<varlistentry>
<term>
<option>lxc.console.buffer.size</option>
</term>
<listitem>
<para>
Setting this option instructs liblxc to allocate an in-memory
ringbuffer. The container's console output will be written to the
ringbuffer. Note that ringbuffer must be at least as big as a
standard page size. When passed a value smaller than a single page
size liblxc will allocate a ringbuffer of a single page size. A page
size is usually 4kB.
The keyword 'auto' will cause liblxc to allocate a ringbuffer of
128kB.
When manually specifying a size for the ringbuffer the value should
be a power of 2 when converted to bytes. Valid size prefixes are
'kB', 'MB', 'GB'. (Note that all conversions are based on multiples
of 1024. That means 'kb' == 'KiB', 'MB' == 'MiB', 'GB' == 'GiB'.)
</para>
</listitem>
</varlistentry>
<varlistentry>
<varlistentry>
<term>
<term>
<option>lxc.console.logfile</option>
<option>lxc.console.logfile</option>
...
...
src/lxc/commands.c
View file @
28f3b1cd
...
@@ -1026,7 +1026,7 @@ static int lxc_cmd_console_log_callback(int fd, struct lxc_cmd_req *req,
...
@@ -1026,7 +1026,7 @@ static int lxc_cmd_console_log_callback(int fd, struct lxc_cmd_req *req,
struct
lxc_handler
*
handler
)
struct
lxc_handler
*
handler
)
{
{
struct
lxc_cmd_rsp
rsp
;
struct
lxc_cmd_rsp
rsp
;
uint64_t
logsize
=
handler
->
conf
->
console
.
log
_size
;
uint64_t
buffer_size
=
handler
->
conf
->
console
.
buffer
_size
;
const
struct
lxc_cmd_console_log
*
log
=
req
->
data
;
const
struct
lxc_cmd_console_log
*
log
=
req
->
data
;
struct
lxc_console
*
console
=
&
handler
->
conf
->
console
;
struct
lxc_console
*
console
=
&
handler
->
conf
->
console
;
struct
lxc_ringbuf
*
buf
=
&
handler
->
conf
->
console
.
ringbuf
;
struct
lxc_ringbuf
*
buf
=
&
handler
->
conf
->
console
.
ringbuf
;
...
@@ -1034,7 +1034,7 @@ static int lxc_cmd_console_log_callback(int fd, struct lxc_cmd_req *req,
...
@@ -1034,7 +1034,7 @@ static int lxc_cmd_console_log_callback(int fd, struct lxc_cmd_req *req,
rsp
.
ret
=
-
EFAULT
;
rsp
.
ret
=
-
EFAULT
;
rsp
.
datalen
=
0
;
rsp
.
datalen
=
0
;
rsp
.
data
=
NULL
;
rsp
.
data
=
NULL
;
if
(
log
size
<=
0
)
if
(
buffer_
size
<=
0
)
goto
out
;
goto
out
;
rsp
.
datalen
=
lxc_ringbuf_used
(
buf
);
rsp
.
datalen
=
lxc_ringbuf_used
(
buf
);
...
...
src/lxc/conf.c
View file @
28f3b1cd
...
@@ -2432,7 +2432,7 @@ struct lxc_conf *lxc_conf_init(void)
...
@@ -2432,7 +2432,7 @@ struct lxc_conf *lxc_conf_init(void)
new
->
autodev
=
1
;
new
->
autodev
=
1
;
new
->
console
.
log_path
=
NULL
;
new
->
console
.
log_path
=
NULL
;
new
->
console
.
log_fd
=
-
1
;
new
->
console
.
log_fd
=
-
1
;
new
->
console
.
log
_size
=
0
;
new
->
console
.
buffer
_size
=
0
;
new
->
console
.
path
=
NULL
;
new
->
console
.
path
=
NULL
;
new
->
console
.
peer
=
-
1
;
new
->
console
.
peer
=
-
1
;
new
->
console
.
peerpty
.
busy
=
-
1
;
new
->
console
.
peerpty
.
busy
=
-
1
;
...
@@ -3463,7 +3463,7 @@ void lxc_conf_free(struct lxc_conf *conf)
...
@@ -3463,7 +3463,7 @@ void lxc_conf_free(struct lxc_conf *conf)
current_config
=
NULL
;
current_config
=
NULL
;
free
(
conf
->
console
.
log_path
);
free
(
conf
->
console
.
log_path
);
free
(
conf
->
console
.
path
);
free
(
conf
->
console
.
path
);
if
(
conf
->
console
.
log
_size
>
0
&&
conf
->
console
.
ringbuf
.
addr
)
if
(
conf
->
console
.
buffer
_size
>
0
&&
conf
->
console
.
ringbuf
.
addr
)
lxc_ringbuf_release
(
&
conf
->
console
.
ringbuf
);
lxc_ringbuf_release
(
&
conf
->
console
.
ringbuf
);
free
(
conf
->
rootfs
.
mount
);
free
(
conf
->
rootfs
.
mount
);
free
(
conf
->
rootfs
.
bdev_type
);
free
(
conf
->
rootfs
.
bdev_type
);
...
...
src/lxc/conf.h
View file @
28f3b1cd
...
@@ -153,7 +153,7 @@ struct lxc_console {
...
@@ -153,7 +153,7 @@ struct lxc_console {
char
name
[
MAXPATHLEN
];
char
name
[
MAXPATHLEN
];
struct
termios
*
tios
;
struct
termios
*
tios
;
struct
lxc_tty_state
*
tty_state
;
struct
lxc_tty_state
*
tty_state
;
uint64_t
log
_size
;
uint64_t
buffer
_size
;
struct
lxc_ringbuf
ringbuf
;
struct
lxc_ringbuf
ringbuf
;
};
};
...
...
src/lxc/confile.c
View file @
28f3b1cd
...
@@ -83,7 +83,7 @@ lxc_config_define(cap_keep);
...
@@ -83,7 +83,7 @@ lxc_config_define(cap_keep);
lxc_config_define
(
cgroup_controller
);
lxc_config_define
(
cgroup_controller
);
lxc_config_define
(
cgroup_dir
);
lxc_config_define
(
cgroup_dir
);
lxc_config_define
(
console_logfile
);
lxc_config_define
(
console_logfile
);
lxc_config_define
(
console_
log
size
);
lxc_config_define
(
console_
buffer_
size
);
lxc_config_define
(
console_path
);
lxc_config_define
(
console_path
);
lxc_config_define
(
environment
);
lxc_config_define
(
environment
);
lxc_config_define
(
ephemeral
);
lxc_config_define
(
ephemeral
);
...
@@ -149,8 +149,8 @@ static struct lxc_config_t config[] = {
...
@@ -149,8 +149,8 @@ static struct lxc_config_t config[] = {
{
"lxc.cap.keep"
,
false
,
set_config_cap_keep
,
get_config_cap_keep
,
clr_config_cap_keep
,
},
{
"lxc.cap.keep"
,
false
,
set_config_cap_keep
,
get_config_cap_keep
,
clr_config_cap_keep
,
},
{
"lxc.cgroup.dir"
,
false
,
set_config_cgroup_dir
,
get_config_cgroup_dir
,
clr_config_cgroup_dir
,
},
{
"lxc.cgroup.dir"
,
false
,
set_config_cgroup_dir
,
get_config_cgroup_dir
,
clr_config_cgroup_dir
,
},
{
"lxc.cgroup"
,
false
,
set_config_cgroup_controller
,
get_config_cgroup_controller
,
clr_config_cgroup_controller
,
},
{
"lxc.cgroup"
,
false
,
set_config_cgroup_controller
,
get_config_cgroup_controller
,
clr_config_cgroup_controller
,
},
{
"lxc.console.buffer.size"
,
false
,
set_config_console_buffer_size
,
get_config_console_buffer_size
,
clr_config_console_buffer_size
,
},
{
"lxc.console.logfile"
,
false
,
set_config_console_logfile
,
get_config_console_logfile
,
clr_config_console_logfile
,
},
{
"lxc.console.logfile"
,
false
,
set_config_console_logfile
,
get_config_console_logfile
,
clr_config_console_logfile
,
},
{
"lxc.console.logsize"
,
false
,
set_config_console_logsize
,
get_config_console_logsize
,
clr_config_console_logsize
,
},
{
"lxc.console.path"
,
false
,
set_config_console_path
,
get_config_console_path
,
clr_config_console_path
,
},
{
"lxc.console.path"
,
false
,
set_config_console_path
,
get_config_console_path
,
clr_config_console_path
,
},
{
"lxc.environment"
,
false
,
set_config_environment
,
get_config_environment
,
clr_config_environment
,
},
{
"lxc.environment"
,
false
,
set_config_environment
,
get_config_environment
,
clr_config_environment
,
},
{
"lxc.ephemeral"
,
false
,
set_config_ephemeral
,
get_config_ephemeral
,
clr_config_ephemeral
,
},
{
"lxc.ephemeral"
,
false
,
set_config_ephemeral
,
get_config_ephemeral
,
clr_config_ephemeral
,
},
...
@@ -1794,21 +1794,21 @@ static int set_config_console_logfile(const char *key, const char *value,
...
@@ -1794,21 +1794,21 @@ static int set_config_console_logfile(const char *key, const char *value,
return
set_config_path_item
(
&
lxc_conf
->
console
.
log_path
,
value
);
return
set_config_path_item
(
&
lxc_conf
->
console
.
log_path
,
value
);
}
}
static
int
set_config_console_
log
size
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_console_
buffer_
size
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
{
int
ret
;
int
ret
;
int64_t
size
;
int64_t
size
;
uint64_t
log
size
,
pgsz
;
uint64_t
buffer_
size
,
pgsz
;
if
(
lxc_config_value_empty
(
value
))
{
if
(
lxc_config_value_empty
(
value
))
{
lxc_conf
->
console
.
log
_size
=
0
;
lxc_conf
->
console
.
buffer
_size
=
0
;
return
0
;
return
0
;
}
}
/* If the user specified "auto" the default log size is 2^17 = 128 Kib */
/* If the user specified "auto" the default log size is 2^17 = 128 Kib */
if
(
!
strcmp
(
value
,
"auto"
))
{
if
(
!
strcmp
(
value
,
"auto"
))
{
lxc_conf
->
console
.
log
_size
=
1
<<
17
;
lxc_conf
->
console
.
buffer
_size
=
1
<<
17
;
return
0
;
return
0
;
}
}
...
@@ -1829,15 +1829,15 @@ static int set_config_console_logsize(const char *key, const char *value,
...
@@ -1829,15 +1829,15 @@ static int set_config_console_logsize(const char *key, const char *value,
size
=
pgsz
;
size
=
pgsz
;
}
}
log
size
=
lxc_find_next_power2
((
uint64_t
)
size
);
buffer_
size
=
lxc_find_next_power2
((
uint64_t
)
size
);
if
(
log
size
==
0
)
if
(
buffer_
size
==
0
)
return
-
EINVAL
;
return
-
EINVAL
;
if
(
log
size
!=
size
)
if
(
buffer_
size
!=
size
)
NOTICE
(
"Passed size was not a power of 2. Rounding log size to "
NOTICE
(
"Passed size was not a power of 2. Rounding log size to "
"next power of two: %"
PRIu64
" bytes"
,
log
size
);
"next power of two: %"
PRIu64
" bytes"
,
buffer_
size
);
lxc_conf
->
console
.
log_size
=
log
size
;
lxc_conf
->
console
.
buffer_size
=
buffer_
size
;
return
0
;
return
0
;
}
}
...
@@ -3091,8 +3091,9 @@ static int get_config_console_logfile(const char *key, char *retv, int inlen,
...
@@ -3091,8 +3091,9 @@ static int get_config_console_logfile(const char *key, char *retv, int inlen,
return
lxc_get_conf_str
(
retv
,
inlen
,
c
->
console
.
log_path
);
return
lxc_get_conf_str
(
retv
,
inlen
,
c
->
console
.
log_path
);
}
}
static
int
get_config_console_logsize
(
const
char
*
key
,
char
*
retv
,
int
inlen
,
static
int
get_config_console_buffer_size
(
const
char
*
key
,
char
*
retv
,
struct
lxc_conf
*
c
,
void
*
data
)
int
inlen
,
struct
lxc_conf
*
c
,
void
*
data
)
{
{
return
lxc_get_conf_uint64
(
c
,
retv
,
inlen
,
c
->
autodev
);
return
lxc_get_conf_uint64
(
c
,
retv
,
inlen
,
c
->
autodev
);
}
}
...
@@ -3501,10 +3502,10 @@ static inline int clr_config_console_logfile(const char *key,
...
@@ -3501,10 +3502,10 @@ static inline int clr_config_console_logfile(const char *key,
return
0
;
return
0
;
}
}
static
inline
int
clr_config_console_
log
size
(
const
char
*
key
,
static
inline
int
clr_config_console_
buffer_
size
(
const
char
*
key
,
struct
lxc_conf
*
c
,
void
*
data
)
struct
lxc_conf
*
c
,
void
*
data
)
{
{
c
->
console
.
log
_size
=
0
;
c
->
console
.
buffer
_size
=
0
;
return
0
;
return
0
;
}
}
...
...
src/lxc/console.c
View file @
28f3b1cd
...
@@ -238,7 +238,7 @@ static int lxc_console_cb_con(int fd, uint32_t events, void *data,
...
@@ -238,7 +238,7 @@ static int lxc_console_cb_con(int fd, uint32_t events, void *data,
w
=
lxc_write_nointr
(
console
->
peer
,
buf
,
r
);
w
=
lxc_write_nointr
(
console
->
peer
,
buf
,
r
);
/* write to console ringbuffer */
/* write to console ringbuffer */
if
(
console
->
log
_size
>
0
)
if
(
console
->
buffer
_size
>
0
)
w_rbuf
=
lxc_ringbuf_write
(
&
console
->
ringbuf
,
buf
,
r
);
w_rbuf
=
lxc_ringbuf_write
(
&
console
->
ringbuf
,
buf
,
r
);
/* write to console log */
/* write to console log */
...
@@ -617,7 +617,7 @@ static int lxc_setup_console_ringbuf(struct lxc_console *console)
...
@@ -617,7 +617,7 @@ static int lxc_setup_console_ringbuf(struct lxc_console *console)
{
{
int
ret
;
int
ret
;
struct
lxc_ringbuf
*
buf
=
&
console
->
ringbuf
;
struct
lxc_ringbuf
*
buf
=
&
console
->
ringbuf
;
uint64_t
size
=
console
->
log
_size
;
uint64_t
size
=
console
->
buffer
_size
;
/* no ringbuffer previously allocated and no ringbuffer requested */
/* no ringbuffer previously allocated and no ringbuffer requested */
if
(
!
buf
->
addr
&&
size
<=
0
)
if
(
!
buf
->
addr
&&
size
<=
0
)
...
@@ -698,7 +698,7 @@ int lxc_console_create(struct lxc_conf *conf)
...
@@ -698,7 +698,7 @@ int lxc_console_create(struct lxc_conf *conf)
goto
err
;
goto
err
;
}
}
if
(
console
->
log_path
&&
console
->
log
_size
<=
0
)
{
if
(
console
->
log_path
&&
console
->
buffer
_size
<=
0
)
{
console
->
log_fd
=
lxc_unpriv
(
open
(
console
->
log_path
,
O_CLOEXEC
|
O_RDWR
|
O_CREAT
|
O_APPEND
,
0600
));
console
->
log_fd
=
lxc_unpriv
(
open
(
console
->
log_path
,
O_CLOEXEC
|
O_RDWR
|
O_CREAT
|
O_APPEND
,
0600
));
if
(
console
->
log_fd
<
0
)
{
if
(
console
->
log_fd
<
0
)
{
SYSERROR
(
"Failed to open console log file
\"
%s
\"
"
,
console
->
log_path
);
SYSERROR
(
"Failed to open console log file
\"
%s
\"
"
,
console
->
log_path
);
...
...
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