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
6c544cb3
Commit
6c544cb3
authored
Nov 13, 2013
by
Marek Majkowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it possible to share UTS namespace
parent
46926165
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
5 deletions
+32
-5
lxc-start.sgml.in
doc/lxc-start.sgml.in
+15
-0
conf.c
src/lxc/conf.c
+5
-3
lxc_start.c
src/lxc/lxc_start.c
+4
-0
start.c
src/lxc/start.c
+8
-2
No files found.
doc/lxc-start.sgml.in
View file @
6c544cb3
...
@@ -217,6 +217,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
...
@@ -217,6 +217,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
</listitem>
</listitem>
</varlistentry>
</varlistentry>
<varlistentry>
<term>
<option>--share-uts <replaceable>name|pid</replaceable></option>
</term>
<listitem>
<para>
Inherit a UTS namespace from
a <replaceable>name</replaceable> container or
a <replaceable>pid</replaceable>. The starting LXC will
not set the hostname, but the container OS may do it
anyway.
</para>
</listitem>
</varlistentry>
</variablelist>
</variablelist>
</refsect1>
</refsect1>
...
...
src/lxc/conf.c
View file @
6c544cb3
...
@@ -3141,9 +3141,11 @@ int ttys_shift_ids(struct lxc_conf *c)
...
@@ -3141,9 +3141,11 @@ int ttys_shift_ids(struct lxc_conf *c)
int
lxc_setup
(
const
char
*
name
,
struct
lxc_conf
*
lxc_conf
,
const
char
*
lxcpath
,
struct
cgroup_process_info
*
cgroup_info
)
int
lxc_setup
(
const
char
*
name
,
struct
lxc_conf
*
lxc_conf
,
const
char
*
lxcpath
,
struct
cgroup_process_info
*
cgroup_info
)
{
{
if
(
setup_utsname
(
lxc_conf
->
utsname
))
{
if
(
lxc_conf
->
inherit_ns_fd
[
LXC_NS_UTS
]
==
-
1
)
{
ERROR
(
"failed to setup the utsname for '%s'"
,
name
);
if
(
setup_utsname
(
lxc_conf
->
utsname
))
{
return
-
1
;
ERROR
(
"failed to setup the utsname for '%s'"
,
name
);
return
-
1
;
}
}
}
if
(
setup_network
(
&
lxc_conf
->
network
))
{
if
(
setup_network
(
&
lxc_conf
->
network
))
{
...
...
src/lxc/lxc_start.c
View file @
6c544cb3
...
@@ -53,6 +53,7 @@
...
@@ -53,6 +53,7 @@
#define OPT_SHARE_NET OPT_USAGE+1
#define OPT_SHARE_NET OPT_USAGE+1
#define OPT_SHARE_IPC OPT_USAGE+2
#define OPT_SHARE_IPC OPT_USAGE+2
#define OPT_SHARE_UTS OPT_USAGE+3
lxc_log_define
(
lxc_start_ui
,
lxc_start
);
lxc_log_define
(
lxc_start_ui
,
lxc_start
);
...
@@ -153,6 +154,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
...
@@ -153,6 +154,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
case
'p'
:
args
->
pidfile
=
arg
;
break
;
case
'p'
:
args
->
pidfile
=
arg
;
break
;
case
OPT_SHARE_NET
:
args
->
share_ns
[
LXC_NS_NET
]
=
arg
;
break
;
case
OPT_SHARE_NET
:
args
->
share_ns
[
LXC_NS_NET
]
=
arg
;
break
;
case
OPT_SHARE_IPC
:
args
->
share_ns
[
LXC_NS_IPC
]
=
arg
;
break
;
case
OPT_SHARE_IPC
:
args
->
share_ns
[
LXC_NS_IPC
]
=
arg
;
break
;
case
OPT_SHARE_UTS
:
args
->
share_ns
[
LXC_NS_UTS
]
=
arg
;
break
;
}
}
return
0
;
return
0
;
}
}
...
@@ -167,6 +169,7 @@ static const struct option my_longopts[] = {
...
@@ -167,6 +169,7 @@ static const struct option my_longopts[] = {
{
"pidfile"
,
required_argument
,
0
,
'p'
},
{
"pidfile"
,
required_argument
,
0
,
'p'
},
{
"share-net"
,
required_argument
,
0
,
OPT_SHARE_NET
},
{
"share-net"
,
required_argument
,
0
,
OPT_SHARE_NET
},
{
"share-ipc"
,
required_argument
,
0
,
OPT_SHARE_IPC
},
{
"share-ipc"
,
required_argument
,
0
,
OPT_SHARE_IPC
},
{
"share-uts"
,
required_argument
,
0
,
OPT_SHARE_UTS
},
LXC_COMMON_OPTIONS
LXC_COMMON_OPTIONS
};
};
...
@@ -190,6 +193,7 @@ Options :\n\
...
@@ -190,6 +193,7 @@ Options :\n\
-s, --define KEY=VAL Assign VAL to configuration variable KEY
\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-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
\
--share-ipc=NAME Share an IPC namespace with another container or pid
\n
\
--share-uts=NAME Share a UTS namespace with another container or pid
\n
\
"
,
"
,
.
options
=
my_longopts
,
.
options
=
my_longopts
,
.
parser
=
my_parser
,
.
parser
=
my_parser
,
...
...
src/lxc/start.c
View file @
6c544cb3
...
@@ -721,13 +721,13 @@ int lxc_spawn(struct lxc_handler *handler)
...
@@ -721,13 +721,13 @@ int lxc_spawn(struct lxc_handler *handler)
int
preserve_mask
=
0
,
i
;
int
preserve_mask
=
0
,
i
;
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
if
(
handler
->
conf
->
inherit_ns_fd
[
i
]
>
-
1
)
if
(
handler
->
conf
->
inherit_ns_fd
[
i
]
!=
-
1
)
preserve_mask
|=
ns_info
[
i
].
clone_flag
;
preserve_mask
|=
ns_info
[
i
].
clone_flag
;
if
(
lxc_sync_init
(
handler
))
if
(
lxc_sync_init
(
handler
))
return
-
1
;
return
-
1
;
handler
->
clone_flags
=
CLONE_NEW
UTS
|
CLONE_NEW
PID
|
CLONE_NEWNS
;
handler
->
clone_flags
=
CLONE_NEWPID
|
CLONE_NEWNS
;
if
(
!
lxc_list_empty
(
&
handler
->
conf
->
id_map
))
{
if
(
!
lxc_list_empty
(
&
handler
->
conf
->
id_map
))
{
INFO
(
"Cloning a new user namespace"
);
INFO
(
"Cloning a new user namespace"
);
handler
->
clone_flags
|=
CLONE_NEWUSER
;
handler
->
clone_flags
|=
CLONE_NEWUSER
;
...
@@ -772,6 +772,12 @@ int lxc_spawn(struct lxc_handler *handler)
...
@@ -772,6 +772,12 @@ int lxc_spawn(struct lxc_handler *handler)
INFO
(
"Inheriting an IPC namespace"
);
INFO
(
"Inheriting an IPC namespace"
);
}
}
if
(
handler
->
conf
->
inherit_ns_fd
[
LXC_NS_UTS
]
==
-
1
)
{
handler
->
clone_flags
|=
CLONE_NEWUTS
;
}
else
{
INFO
(
"Inheriting a UTS namespace"
);
}
cgroup_meta
=
lxc_cgroup_load_meta
();
cgroup_meta
=
lxc_cgroup_load_meta
();
if
(
!
cgroup_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