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
8cecbd38
Commit
8cecbd38
authored
Oct 06, 2015
by
Wolfgang Bumiller
Committed by
Stéphane Graber
Oct 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preserve container namespace
Signed-off-by:
Wolfgang Bumiller
<
w.bumiller@proxmox.com
>
Acked-by:
Serge E. Hallyn
<
serge.hallyn@ubuntu.com
>
parent
5b657f6b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
start.c
src/lxc/start.c
+18
-0
start.h
src/lxc/start.h
+1
-0
No files found.
src/lxc/start.c
View file @
8cecbd38
...
@@ -372,6 +372,7 @@ out_sigfd:
...
@@ -372,6 +372,7 @@ out_sigfd:
struct
lxc_handler
*
lxc_init
(
const
char
*
name
,
struct
lxc_conf
*
conf
,
const
char
*
lxcpath
)
struct
lxc_handler
*
lxc_init
(
const
char
*
name
,
struct
lxc_conf
*
conf
,
const
char
*
lxcpath
)
{
{
int
i
;
struct
lxc_handler
*
handler
;
struct
lxc_handler
*
handler
;
handler
=
malloc
(
sizeof
(
*
handler
));
handler
=
malloc
(
sizeof
(
*
handler
));
...
@@ -385,6 +386,9 @@ struct lxc_handler *lxc_init(const char *name, struct lxc_conf *conf, const char
...
@@ -385,6 +386,9 @@ struct lxc_handler *lxc_init(const char *name, struct lxc_conf *conf, const char
handler
->
lxcpath
=
lxcpath
;
handler
->
lxcpath
=
lxcpath
;
handler
->
pinfd
=
-
1
;
handler
->
pinfd
=
-
1
;
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
handler
->
nsfd
[
i
]
=
-
1
;
lsm_init
();
lsm_init
();
handler
->
name
=
strdup
(
name
);
handler
->
name
=
strdup
(
name
);
...
@@ -475,10 +479,19 @@ out_free:
...
@@ -475,10 +479,19 @@ out_free:
void
lxc_fini
(
const
char
*
name
,
struct
lxc_handler
*
handler
)
void
lxc_fini
(
const
char
*
name
,
struct
lxc_handler
*
handler
)
{
{
int
i
;
/* The STOPPING state is there for future cleanup code
/* The STOPPING state is there for future cleanup code
* which can take awhile
* which can take awhile
*/
*/
lxc_set_state
(
name
,
handler
,
STOPPING
);
lxc_set_state
(
name
,
handler
,
STOPPING
);
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
{
if
(
handler
->
nsfd
[
i
]
!=
-
1
)
{
close
(
handler
->
nsfd
[
i
]);
handler
->
nsfd
[
i
]
=
-
1
;
}
}
lxc_set_state
(
name
,
handler
,
STOPPED
);
lxc_set_state
(
name
,
handler
,
STOPPED
);
if
(
run_lxc_hooks
(
name
,
"post-stop"
,
handler
->
conf
,
handler
->
lxcpath
,
NULL
))
if
(
run_lxc_hooks
(
name
,
"post-stop"
,
handler
->
conf
,
handler
->
lxcpath
,
NULL
))
...
@@ -976,6 +989,11 @@ static int lxc_spawn(struct lxc_handler *handler)
...
@@ -976,6 +989,11 @@ static int lxc_spawn(struct lxc_handler *handler)
goto
out_delete_net
;
goto
out_delete_net
;
}
}
if
(
preserve_ns
(
handler
->
nsfd
,
handler
->
clone_flags
,
handler
->
pid
)
<
0
)
{
ERROR
(
"failed to store namespace references"
);
goto
out_delete_net
;
}
if
(
attach_ns
(
saved_ns_fd
))
if
(
attach_ns
(
saved_ns_fd
))
WARN
(
"failed to restore saved namespaces"
);
WARN
(
"failed to restore saved namespaces"
);
...
...
src/lxc/start.h
View file @
8cecbd38
...
@@ -75,6 +75,7 @@ struct lxc_handler {
...
@@ -75,6 +75,7 @@ struct lxc_handler {
void
*
cgroup_data
;
void
*
cgroup_data
;
int
ttysock
[
2
];
// socketpair for child->parent tty fd passing
int
ttysock
[
2
];
// socketpair for child->parent tty fd passing
bool
backgrounded
;
// indicates whether should we close std{in,out,err} on start
bool
backgrounded
;
// indicates whether should we close std{in,out,err} on start
int
nsfd
[
LXC_NS_MAX
];
};
};
...
...
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