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
3c93577b
Commit
3c93577b
authored
Nov 12, 2013
by
Marek Majkowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create --share-ipc option
parent
d4afa440
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
1 deletion
+33
-1
lxc-start.sgml.in
doc/lxc-start.sgml.in
+10
-0
arguments.h
src/lxc/arguments.h
+1
-0
lxc_start.c
src/lxc/lxc_start.c
+15
-0
start.c
src/lxc/start.c
+7
-1
No files found.
doc/lxc-start.sgml.in
View file @
3c93577b
...
...
@@ -58,6 +58,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
<arg choice="opt">-s KEY=VAL</arg>
<arg choice="opt">-C</arg>
<arg choice="opt">--share-net <replaceable>name|pid</replaceable></arg>
<arg choice="opt">--share-ipc <replaceable>name|pid</replaceable></arg>
<arg choice="opt">command</arg>
</cmdsynopsis>
</refsynopsisdiv>
...
...
@@ -203,6 +204,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--share-ipc <replaceable>name|pid</replaceable></option>
</term>
<listitem>
<para>
Inherit an IPC namespace from
a <replaceable>name</replaceable> container or
a <replaceable>pid</replaceable>.
</para>
</listitem>
</varlistentry>
...
...
src/lxc/arguments.h
View file @
3c93577b
...
...
@@ -55,6 +55,7 @@ struct lxc_arguments {
/* for lxc-start */
const
char
*
share_net
;
const
char
*
share_ipc
;
/* for lxc-checkpoint/restart */
const
char
*
statefile
;
...
...
src/lxc/lxc_start.c
View file @
3c93577b
...
...
@@ -52,6 +52,7 @@
#include "arguments.h"
#define OPT_SHARE_NET OPT_USAGE+1
#define OPT_SHARE_IPC OPT_USAGE+2
lxc_log_define
(
lxc_start_ui
,
lxc_start
);
...
...
@@ -146,6 +147,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
case
's'
:
return
lxc_config_define_add
(
&
defines
,
arg
);
case
'p'
:
args
->
pidfile
=
arg
;
break
;
case
OPT_SHARE_NET
:
args
->
share_net
=
arg
;
break
;
case
OPT_SHARE_IPC
:
args
->
share_ipc
=
arg
;
break
;
}
return
0
;
}
...
...
@@ -159,6 +161,7 @@ static const struct option my_longopts[] = {
{
"close-all-fds"
,
no_argument
,
0
,
'C'
},
{
"pidfile"
,
required_argument
,
0
,
'p'
},
{
"share-net"
,
required_argument
,
0
,
OPT_SHARE_NET
},
{
"share-ipc"
,
required_argument
,
0
,
OPT_SHARE_IPC
},
LXC_COMMON_OPTIONS
};
...
...
@@ -181,6 +184,7 @@ Options :\n\
Note: --daemon implies --close-all-fds
\n
\
-s, --define KEY=VAL Assign VAL to configuration variable KEY
\n
\
--share-net=NAME Share a network namespace with another container or pid
\n
\
--share-ipc=NAME Share an IPC namespace with another container or pid
\n
\
"
,
.
options
=
my_longopts
,
.
parser
=
my_parser
,
...
...
@@ -308,6 +312,17 @@ int main(int argc, char *argv[])
conf
->
inherit_ns_fd
[
LXC_NS_NET
]
=
fd
;
}
if
(
my_args
.
share_ipc
!=
NULL
)
{
int
pid
=
pid_from_lxcname
(
my_args
.
share_ipc
,
lxcpath
);
if
(
pid
<
1
)
goto
out
;
int
fd
=
open_ns
(
pid
,
"ipc"
);
if
(
fd
<
0
)
goto
out
;
conf
->
inherit_ns_fd
[
LXC_NS_IPC
]
=
fd
;
}
if
(
my_args
.
daemonize
)
{
c
->
want_daemonize
(
c
);
}
...
...
src/lxc/start.c
View file @
3c93577b
...
...
@@ -727,7 +727,7 @@ int lxc_spawn(struct lxc_handler *handler)
if
(
lxc_sync_init
(
handler
))
return
-
1
;
handler
->
clone_flags
=
CLONE_NEWUTS
|
CLONE_NEWPID
|
CLONE_NEW
IPC
|
CLONE_NEW
NS
;
handler
->
clone_flags
=
CLONE_NEWUTS
|
CLONE_NEWPID
|
CLONE_NEWNS
;
if
(
!
lxc_list_empty
(
&
handler
->
conf
->
id_map
))
{
INFO
(
"Cloning a new user namespace"
);
handler
->
clone_flags
|=
CLONE_NEWUSER
;
...
...
@@ -766,6 +766,12 @@ int lxc_spawn(struct lxc_handler *handler)
INFO
(
"Inheriting a net namespace"
);
}
if
(
handler
->
conf
->
inherit_ns_fd
[
LXC_NS_IPC
]
==
-
1
)
{
handler
->
clone_flags
|=
CLONE_NEWIPC
;
}
else
{
INFO
(
"Inheriting an IPC namespace"
);
}
cgroup_meta
=
lxc_cgroup_load_meta
();
if
(
!
cgroup_meta
)
{
...
...
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