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
c30e9b19
Unverified
Commit
c30e9b19
authored
Feb 19, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start: lxc_start()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
cfc62c60
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
26 deletions
+29
-26
start.c
src/lxc/start.c
+29
-26
No files found.
src/lxc/start.c
View file @
c30e9b19
...
@@ -1828,12 +1828,12 @@ int __lxc_start(const char *name, struct lxc_handler *handler,
...
@@ -1828,12 +1828,12 @@ int __lxc_start(const char *name, struct lxc_handler *handler,
struct
lxc_operations
*
ops
,
void
*
data
,
const
char
*
lxcpath
,
struct
lxc_operations
*
ops
,
void
*
data
,
const
char
*
lxcpath
,
bool
backgrounded
)
bool
backgrounded
)
{
{
int
status
;
int
ret
,
status
;
int
err
=
-
1
;
struct
lxc_conf
*
conf
=
handler
->
conf
;
struct
lxc_conf
*
conf
=
handler
->
conf
;
if
(
lxc_init
(
name
,
handler
)
<
0
)
{
ret
=
lxc_init
(
name
,
handler
);
ERROR
(
"Failed to initialize container
\"
%s
\"
."
,
name
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to initialize container
\"
%s
\"
"
,
name
);
return
-
1
;
return
-
1
;
}
}
handler
->
ops
=
ops
;
handler
->
ops
=
ops
;
...
@@ -1841,31 +1841,33 @@ int __lxc_start(const char *name, struct lxc_handler *handler,
...
@@ -1841,31 +1841,33 @@ int __lxc_start(const char *name, struct lxc_handler *handler,
handler
->
backgrounded
=
backgrounded
;
handler
->
backgrounded
=
backgrounded
;
if
(
!
attach_block_device
(
handler
->
conf
))
{
if
(
!
attach_block_device
(
handler
->
conf
))
{
ERROR
(
"Failed to attach block device
.
"
);
ERROR
(
"Failed to attach block device"
);
goto
out_fini_nonet
;
goto
out_fini_nonet
;
}
}
if
(
geteuid
()
==
0
&&
!
lxc_list_empty
(
&
conf
->
id_map
))
{
if
(
geteuid
()
==
0
&&
!
lxc_list_empty
(
&
conf
->
id_map
))
{
/* If the backing store is a device, mount it here and now. */
/* If the backing store is a device, mount it here and now. */
if
(
rootfs_is_blockdev
(
conf
))
{
if
(
rootfs_is_blockdev
(
conf
))
{
if
(
unshare
(
CLONE_NEWNS
)
<
0
)
{
ret
=
unshare
(
CLONE_NEWNS
);
ERROR
(
"Failed to unshare CLONE_NEWNS."
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to unshare CLONE_NEWNS"
);
goto
out_fini_nonet
;
goto
out_fini_nonet
;
}
}
INFO
(
"Unshared CLONE_NEWNS
.
"
);
INFO
(
"Unshared CLONE_NEWNS"
);
remount_all_slave
();
remount_all_slave
();
if
(
do_rootfs_setup
(
conf
,
name
,
lxcpath
)
<
0
)
{
ret
=
do_rootfs_setup
(
conf
,
name
,
lxcpath
);
ERROR
(
"Error setting up rootfs mount as root before spawn."
);
if
(
ret
<
0
)
{
ERROR
(
"Error setting up rootfs mount as root before spawn"
);
goto
out_fini_nonet
;
goto
out_fini_nonet
;
}
}
INFO
(
"Set up container rootfs as host root
.
"
);
INFO
(
"Set up container rootfs as host root"
);
}
}
}
}
err
=
lxc_spawn
(
handler
);
ret
=
lxc_spawn
(
handler
);
if
(
err
)
{
if
(
ret
<
0
)
{
ERROR
(
"Failed to spawn container
\"
%s
\"
.
"
,
name
);
ERROR
(
"Failed to spawn container
\"
%s
\"
"
,
name
);
goto
out_detach_blockdev
;
goto
out_detach_blockdev
;
}
}
/* close parent side of data socket */
/* close parent side of data socket */
...
@@ -1876,14 +1878,15 @@ int __lxc_start(const char *name, struct lxc_handler *handler,
...
@@ -1876,14 +1878,15 @@ int __lxc_start(const char *name, struct lxc_handler *handler,
handler
->
conf
->
reboot
=
0
;
handler
->
conf
->
reboot
=
0
;
err
=
lxc_poll
(
name
,
handler
);
ret
=
lxc_poll
(
name
,
handler
);
if
(
err
)
{
if
(
ret
)
{
ERROR
(
"LXC mainloop exited with error: %d
."
,
err
);
ERROR
(
"LXC mainloop exited with error: %d
"
,
ret
);
goto
out_abort
;
goto
out_abort
;
}
}
while
(
waitpid
(
handler
->
pid
,
&
status
,
0
)
<
0
&&
errno
==
EINTR
)
status
=
lxc_wait_for_pid_status
(
handler
->
pid
);
continue
;
if
(
status
<
0
)
SYSERROR
(
"Failed to retrieve status for %d"
,
handler
->
pid
);
/* If the child process exited but was not signaled, it didn't call
/* If the child process exited but was not signaled, it didn't call
* reboot. This should mean it was an lxc-execute which simply exited.
* reboot. This should mean it was an lxc-execute which simply exited.
...
@@ -1892,23 +1895,23 @@ int __lxc_start(const char *name, struct lxc_handler *handler,
...
@@ -1892,23 +1895,23 @@ int __lxc_start(const char *name, struct lxc_handler *handler,
if
(
WIFSIGNALED
(
status
))
{
if
(
WIFSIGNALED
(
status
))
{
switch
(
WTERMSIG
(
status
))
{
switch
(
WTERMSIG
(
status
))
{
case
SIGINT
:
/* halt */
case
SIGINT
:
/* halt */
DEBUG
(
"Container
\"
%s
\"
is halting
.
"
,
name
);
DEBUG
(
"Container
\"
%s
\"
is halting"
,
name
);
break
;
break
;
case
SIGHUP
:
/* reboot */
case
SIGHUP
:
/* reboot */
DEBUG
(
"Container
\"
%s
\"
is rebooting
.
"
,
name
);
DEBUG
(
"Container
\"
%s
\"
is rebooting"
,
name
);
handler
->
conf
->
reboot
=
1
;
handler
->
conf
->
reboot
=
1
;
break
;
break
;
case
SIGSYS
:
/* seccomp */
case
SIGSYS
:
/* seccomp */
DEBUG
(
"Container
\"
%s
\"
violated its seccomp policy
.
"
,
name
);
DEBUG
(
"Container
\"
%s
\"
violated its seccomp policy"
,
name
);
break
;
break
;
default:
default:
DEBUG
(
"Unknown exit status for container
\"
%s
\"
init %d
.
"
,
name
,
WTERMSIG
(
status
));
DEBUG
(
"Unknown exit status for container
\"
%s
\"
init %d"
,
name
,
WTERMSIG
(
status
));
break
;
break
;
}
}
}
}
err
=
lxc_restore_phys_nics_to_netns
(
handler
);
ret
=
lxc_restore_phys_nics_to_netns
(
handler
);
if
(
err
<
0
)
if
(
ret
<
0
)
ERROR
(
"Failed to move physical network devices back to parent "
ERROR
(
"Failed to move physical network devices back to parent "
"network namespace"
);
"network namespace"
);
...
@@ -1928,7 +1931,7 @@ out_detach_blockdev:
...
@@ -1928,7 +1931,7 @@ out_detach_blockdev:
out_fini_nonet:
out_fini_nonet:
lxc_fini
(
name
,
handler
);
lxc_fini
(
name
,
handler
);
return
err
;
return
ret
;
out_abort:
out_abort:
lxc_abort
(
name
,
handler
);
lxc_abort
(
name
,
handler
);
...
...
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