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
9c631ea7
Commit
9c631ea7
authored
Jul 01, 2013
by
Dwight Engen
Committed by
Serge Hallyn
Jul 01, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow lxc-info to get running container configuration
Signed-off-by:
Dwight Engen
<
dwight.engen@oracle.com
>
Signed-off-by:
Serge Hallyn
<
serge.hallyn@ubuntu.com
>
parent
9a15a0f3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
6 deletions
+49
-6
lxc-info.sgml.in
doc/lxc-info.sgml.in
+25
-3
lxc_info.c
src/lxc/lxc_info.c
+24
-3
No files found.
doc/lxc-info.sgml.in
View file @
9c631ea7
...
@@ -48,9 +48,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
...
@@ -48,9 +48,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<cmdsynopsis>
<cmdsynopsis>
<command>lxc-info</command>
<command>lxc-info</command>
<arg choice="req">-n <replaceable>name</replaceable></arg>
<arg choice="req">-n <replaceable>name</replaceable></arg>
<arg choice="req">-s</arg>
<arg choice="opt">-c <replaceable>KEY</replaceable></arg>
<arg choice="req">-p</arg>
<arg choice="opt">-s</arg>
<arg choice="req">-t <replaceable>state</replaceable></arg>
<arg choice="opt">-p</arg>
<arg choice="opt">-t <replaceable>state</replaceable></arg>
</cmdsynopsis>
</cmdsynopsis>
</refsynopsisdiv>
</refsynopsisdiv>
...
@@ -79,6 +80,18 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
...
@@ -79,6 +80,18 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<varlistentry>
<varlistentry>
<term>
<term>
<option><optional>-c <replaceable>KEY</replaceable></optional></option>
</term>
<listitem>
<para>
Print a configuration key from the running container. This option
may be given mulitple times to print out multiple key = value pairs.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option><optional>-s</optional></option>
<option><optional>-s</optional></option>
</term>
</term>
<listitem>
<listitem>
...
@@ -135,6 +148,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
...
@@ -135,6 +148,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
</listitem>
</listitem>
</varlistentry>
</varlistentry>
<varlistentry>
<term>lxc-info -n foo -c lxc.network.0.veth.pair</term>
<listitem>
<para>
prints the veth pair name of foo.
</para>
</listitem>
</varlistentry>
</variablelist>
</variablelist>
</refsect1>
</refsect1>
...
...
src/lxc/lxc_info.c
View file @
9c631ea7
...
@@ -36,10 +36,17 @@
...
@@ -36,10 +36,17 @@
static
bool
state
;
static
bool
state
;
static
bool
pid
;
static
bool
pid
;
static
char
*
test_state
=
NULL
;
static
char
*
test_state
=
NULL
;
static
char
**
key
=
NULL
;
static
int
keys
=
0
;
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
{
{
switch
(
c
)
{
switch
(
c
)
{
case
'c'
:
key
=
realloc
(
key
,
keys
+
1
*
sizeof
(
key
[
0
]));
key
[
keys
]
=
arg
;
keys
++
;
break
;
case
's'
:
state
=
true
;
break
;
case
's'
:
state
=
true
;
break
;
case
'p'
:
pid
=
true
;
break
;
case
'p'
:
pid
=
true
;
break
;
case
't'
:
test_state
=
arg
;
break
;
case
't'
:
test_state
=
arg
;
break
;
...
@@ -48,6 +55,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
...
@@ -48,6 +55,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
}
}
static
const
struct
option
my_longopts
[]
=
{
static
const
struct
option
my_longopts
[]
=
{
{
"config"
,
required_argument
,
0
,
'c'
},
{
"state"
,
no_argument
,
0
,
's'
},
{
"state"
,
no_argument
,
0
,
's'
},
{
"pid"
,
no_argument
,
0
,
'p'
},
{
"pid"
,
no_argument
,
0
,
'p'
},
{
"state-is"
,
required_argument
,
0
,
't'
},
{
"state-is"
,
required_argument
,
0
,
't'
},
...
@@ -63,8 +71,9 @@ lxc-info display some information about a container with the identifier NAME\n\
...
@@ -63,8 +71,9 @@ lxc-info display some information about a container with the identifier NAME\n\
\n
\
\n
\
Options :
\n
\
Options :
\n
\
-n, --name=NAME NAME for name of the container
\n
\
-n, --name=NAME NAME for name of the container
\n
\
-
s, --state shows the state of the
container
\n
\
-
c, --config=KEY show configuration variable KEY from running
container
\n
\
-p, --pid shows the process id of the init container
\n
\
-p, --pid shows the process id of the init container
\n
\
-s, --state shows the state of the container
\n
\
-t, --state-is=STATE test if current state is STATE
\n
\
-t, --state-is=STATE test if current state is STATE
\n
\
returns success if it matches, false otherwise
\n
"
,
returns success if it matches, false otherwise
\n
"
,
.
options
=
my_longopts
,
.
options
=
my_longopts
,
...
@@ -74,7 +83,7 @@ Options :\n\
...
@@ -74,7 +83,7 @@ Options :\n\
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
ret
;
int
ret
,
i
;
ret
=
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
);
ret
=
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
);
if
(
ret
)
if
(
ret
)
...
@@ -84,7 +93,7 @@ int main(int argc, char *argv[])
...
@@ -84,7 +93,7 @@ int main(int argc, char *argv[])
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
return
1
;
return
1
;
if
(
!
state
&&
!
pid
)
if
(
!
state
&&
!
pid
&&
keys
<=
0
)
state
=
pid
=
true
;
state
=
pid
=
true
;
if
(
state
||
test_state
)
{
if
(
state
||
test_state
)
{
...
@@ -105,5 +114,17 @@ int main(int argc, char *argv[])
...
@@ -105,5 +114,17 @@ int main(int argc, char *argv[])
printf
(
"pid:%10d
\n
"
,
initpid
);
printf
(
"pid:%10d
\n
"
,
initpid
);
}
}
for
(
i
=
0
;
i
<
keys
;
i
++
)
{
char
*
val
;
val
=
lxc_cmd_get_config_item
(
my_args
.
name
,
key
[
i
],
my_args
.
lxcpath
[
0
]);
if
(
val
)
{
printf
(
"%s = %s
\n
"
,
key
[
i
],
val
);
free
(
val
);
}
else
{
fprintf
(
stderr
,
"%s unset or invalid
\n
"
,
key
[
i
]);
}
}
return
0
;
return
0
;
}
}
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