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
829dd918
Commit
829dd918
authored
Feb 01, 2011
by
Daniel Lezcano
Committed by
Daniel Lezcano
Feb 01, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxc-start can output the console to a file
Add the ability to specify a file to output the console. Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
9dd97e44
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
18 deletions
+51
-18
lxc-start.sgml.in
doc/lxc-start.sgml.in
+17
-1
arguments.c
src/lxc/arguments.c
+1
-0
arguments.h
src/lxc/arguments.h
+1
-0
lxc_start.c
src/lxc/lxc_start.c
+32
-17
No files found.
doc/lxc-start.sgml.in
View file @
829dd918
...
...
@@ -49,7 +49,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<refsynopsisdiv>
<cmdsynopsis><command>lxc-start <replaceable>-n
name</replaceable> <optional>-f
config_file</optional> <optional>-s KEY=VAL</optional>
config_file</optional> <optional>-c
console_file</optional> <optional>-d</optional> <optional>-s
KEY=VAL</optional>
<optional>command</optional></command></cmdsynopsis>
</refsynopsisdiv>
...
...
@@ -120,6 +122,20 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<varlistentry>
<term>
<option>-c,
--console <replaceable>console_file</replaceable></option>
</term>
<listitem>
<para>
Specify a file to output the container console. If the
option is not specified the output will go the terminal
except if the <option>-d</option> is specified.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>-s, --define <replaceable>KEY=VAL</replaceable></option>
</term>
<listitem>
...
...
src/lxc/arguments.c
View file @
829dd918
...
...
@@ -168,6 +168,7 @@ extern int lxc_arguments_parse(struct lxc_arguments *args,
case
'n'
:
args
->
name
=
optarg
;
break
;
case
'o'
:
args
->
log_file
=
optarg
;
break
;
case
'l'
:
args
->
log_priority
=
optarg
;
break
;
case
'c'
:
args
->
console
=
optarg
;
break
;
case
'q'
:
args
->
quiet
=
1
;
break
;
case
OPT_USAGE
:
print_usage
(
args
->
options
,
args
);
case
'?'
:
print_help
(
args
,
1
);
...
...
src/lxc/arguments.h
View file @
829dd918
...
...
@@ -44,6 +44,7 @@ struct lxc_arguments {
int
quiet
;
int
daemonize
;
const
char
*
rcfile
;
const
char
*
console
;
/* for lxc-checkpoint/restart */
const
char
*
statefile
;
...
...
src/lxc/lxc_start.c
View file @
829dd918
...
...
@@ -57,6 +57,7 @@ static struct lxc_list defines;
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
{
switch
(
c
)
{
case
'c'
:
args
->
console
=
arg
;
break
;
case
'd'
:
args
->
daemonize
=
1
;
break
;
case
'f'
:
args
->
rcfile
=
arg
;
break
;
case
's'
:
return
lxc_config_define_add
(
&
defines
,
arg
);
...
...
@@ -68,6 +69,7 @@ static const struct option my_longopts[] = {
{
"daemon"
,
no_argument
,
0
,
'd'
},
{
"rcfile"
,
required_argument
,
0
,
'f'
},
{
"define"
,
required_argument
,
0
,
's'
},
{
"console"
,
required_argument
,
0
,
'c'
},
LXC_COMMON_OPTIONS
};
...
...
@@ -82,6 +84,7 @@ Options :\n\
-n, --name=NAME NAME for name of the container
\n
\
-d, --daemon daemonize the container
\n
\
-f, --rcfile=FILE Load configuration file FILE
\n
\
-c, --console=FILE Set the file output for the container console
\n
\
-s, --define KEY=VAL Assign VAL to configuration variable KEY
\n
"
,
.
options
=
my_longopts
,
.
parser
=
my_parser
,
...
...
@@ -160,28 +163,40 @@ int main(int argc, char *argv[])
return
err
;
}
if
(
my_args
.
daemoniz
e
)
{
if
(
my_args
.
consol
e
)
{
/* do not chdir as we want to open the log file,
* change the directory right after.
* do not close 0, 1, 2, we want to do that
* ourself because we don't want /dev/null
* being reopened.
*/
if
(
daemon
(
1
,
1
))
{
SYSERROR
(
"failed to daemonize '%s'"
,
my_args
.
name
);
return
err
;
char
*
console
,
fd
;
if
(
access
(
my_args
.
console
,
W_OK
))
{
fd
=
creat
(
my_args
.
console
,
0600
);
if
(
fd
<
0
)
{
SYSERROR
(
"failed to touch file '%s'"
,
my_args
.
console
);
return
err
;
}
close
(
fd
);
}
close
(
0
);
close
(
1
);
close
(
2
);
console
=
realpath
(
my_args
.
console
,
NULL
);
if
(
!
console
)
{
SYSERROR
(
"failed to get the real path of '%s'"
,
my_args
.
console
);
return
err
;
}
if
(
my_args
.
log_file
)
{
open
(
my_args
.
log_file
,
O_WRONLY
|
O_CLOEXEC
);
open
(
my_args
.
log_file
,
O_RDONLY
|
O_CLOEXEC
);
open
(
my_args
.
log_file
,
O_RDONLY
|
O_CLOEXEC
)
;
conf
->
console
.
path
=
strdup
(
console
);
if
(
!
conf
->
console
.
path
)
{
ERROR
(
"failed to dup string '%s'"
,
console
);
return
err
;
}
free
(
console
);
}
if
(
my_args
.
daemonize
&&
daemon
(
0
,
0
))
{
SYSERROR
(
"failed to daemonize '%s'"
,
my_args
.
name
);
return
err
;
}
err
=
lxc_start
(
my_args
.
name
,
args
,
conf
);
...
...
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