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
c097467f
Unverified
Commit
c097467f
authored
Feb 19, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start: lxc_fini()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
2170b263
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
20 deletions
+34
-20
start.c
src/lxc/start.c
+34
-20
No files found.
src/lxc/start.c
View file @
c097467f
...
@@ -838,7 +838,7 @@ out_close_maincmd_fd:
...
@@ -838,7 +838,7 @@ out_close_maincmd_fd:
void
lxc_fini
(
const
char
*
name
,
struct
lxc_handler
*
handler
)
void
lxc_fini
(
const
char
*
name
,
struct
lxc_handler
*
handler
)
{
{
int
i
,
r
c
;
int
i
,
r
et
;
pid_t
self
;
pid_t
self
;
struct
lxc_list
*
cur
,
*
next
;
struct
lxc_list
*
cur
,
*
next
;
char
*
namespaces
[
LXC_NS_MAX
+
1
];
char
*
namespaces
[
LXC_NS_MAX
+
1
];
...
@@ -855,14 +855,14 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
...
@@ -855,14 +855,14 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
continue
;
continue
;
if
(
handler
->
conf
->
hooks_version
==
0
)
if
(
handler
->
conf
->
hooks_version
==
0
)
r
c
=
asprintf
(
&
namespaces
[
namespace_count
],
r
et
=
asprintf
(
&
namespaces
[
namespace_count
],
"%s:/proc/%d/fd/%d"
,
ns_info
[
i
].
proc_name
,
"%s:/proc/%d/fd/%d"
,
ns_info
[
i
].
proc_name
,
self
,
handler
->
nsfd
[
i
]);
self
,
handler
->
nsfd
[
i
]);
else
else
r
c
=
asprintf
(
&
namespaces
[
namespace_count
],
r
et
=
asprintf
(
&
namespaces
[
namespace_count
],
"/proc/%d/fd/%d"
,
self
,
handler
->
nsfd
[
i
]);
"/proc/%d/fd/%d"
,
self
,
handler
->
nsfd
[
i
]);
if
(
r
c
==
-
1
)
{
if
(
r
et
==
-
1
)
{
SYSERROR
(
"Failed to allocate memory
.
"
);
SYSERROR
(
"Failed to allocate memory"
);
break
;
break
;
}
}
...
@@ -871,8 +871,8 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
...
@@ -871,8 +871,8 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
continue
;
continue
;
}
}
r
c
=
setenv
(
ns_info
[
i
].
env_name
,
namespaces
[
namespace_count
],
1
);
r
et
=
setenv
(
ns_info
[
i
].
env_name
,
namespaces
[
namespace_count
],
1
);
if
(
r
c
<
0
)
if
(
r
et
<
0
)
SYSERROR
(
"Failed to set environment variable %s=%s"
,
SYSERROR
(
"Failed to set environment variable %s=%s"
,
ns_info
[
i
].
env_name
,
namespaces
[
namespace_count
]);
ns_info
[
i
].
env_name
,
namespaces
[
namespace_count
]);
else
else
...
@@ -883,16 +883,26 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
...
@@ -883,16 +883,26 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
}
}
namespaces
[
namespace_count
]
=
NULL
;
namespaces
[
namespace_count
]
=
NULL
;
if
(
handler
->
conf
->
reboot
&&
setenv
(
"LXC_TARGET"
,
"reboot"
,
1
))
if
(
handler
->
conf
->
reboot
)
{
SYSERROR
(
"Failed to set environment variable: LXC_TARGET=reboot."
);
ret
=
setenv
(
"LXC_TARGET"
,
"reboot"
,
1
);
if
(
ret
<
0
)
SYSERROR
(
"Failed to set environment variable: "
"LXC_TARGET=reboot"
);
}
if
(
!
handler
->
conf
->
reboot
&&
setenv
(
"LXC_TARGET"
,
"stop"
,
1
))
if
(
!
handler
->
conf
->
reboot
)
{
SYSERROR
(
"Failed to set environment variable: LXC_TARGET=stop."
);
ret
=
setenv
(
"LXC_TARGET"
,
"stop"
,
1
);
if
(
ret
<
0
)
SYSERROR
(
"Failed to set environment variable: "
"LXC_TARGET=stop"
);
}
if
(
handler
->
conf
->
hooks_version
==
0
)
if
(
handler
->
conf
->
hooks_version
==
0
)
r
c
=
run_lxc_hooks
(
name
,
"stop"
,
handler
->
conf
,
namespaces
);
r
et
=
run_lxc_hooks
(
name
,
"stop"
,
handler
->
conf
,
namespaces
);
else
else
rc
=
run_lxc_hooks
(
name
,
"stop"
,
handler
->
conf
,
NULL
);
ret
=
run_lxc_hooks
(
name
,
"stop"
,
handler
->
conf
,
NULL
);
if
(
ret
<
0
)
ERROR
(
"Failed to run
\"
lxc.hook.stop
\"
hook"
);
while
(
namespace_count
--
)
while
(
namespace_count
--
)
free
(
namespaces
[
namespace_count
]);
free
(
namespaces
[
namespace_count
]);
...
@@ -925,18 +935,22 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
...
@@ -925,18 +935,22 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
}
}
if
(
run_lxc_hooks
(
name
,
"post-stop"
,
handler
->
conf
,
NULL
))
{
if
(
run_lxc_hooks
(
name
,
"post-stop"
,
handler
->
conf
,
NULL
))
{
ERROR
(
"Failed to run lxc.hook.post-stop for container
\"
%s
\"
.
"
,
name
);
ERROR
(
"Failed to run lxc.hook.post-stop for container
\"
%s
\"
"
,
name
);
if
(
handler
->
conf
->
reboot
)
{
if
(
handler
->
conf
->
reboot
)
{
WARN
(
"Container will be stopped instead of rebooted
.
"
);
WARN
(
"Container will be stopped instead of rebooted"
);
handler
->
conf
->
reboot
=
0
;
handler
->
conf
->
reboot
=
0
;
if
(
setenv
(
"LXC_TARGET"
,
"stop"
,
1
))
WARN
(
"Failed to set environment variable: LXC_TARGET=stop."
);
ret
=
setenv
(
"LXC_TARGET"
,
"stop"
,
1
);
if
(
ret
<
0
)
WARN
(
"Failed to set environment variable: "
"LXC_TARGET=stop"
);
}
}
}
}
/* Reset mask set by setup_signal_fd. */
/* Reset mask set by setup_signal_fd. */
if
(
sigprocmask
(
SIG_SETMASK
,
&
handler
->
oldmask
,
NULL
))
ret
=
sigprocmask
(
SIG_SETMASK
,
&
handler
->
oldmask
,
NULL
);
WARN
(
"Failed to restore signal mask."
);
if
(
ret
<
0
)
WARN
(
"%s - Failed to restore signal mask"
,
strerror
(
errno
));
lxc_console_delete
(
&
handler
->
conf
->
console
);
lxc_console_delete
(
&
handler
->
conf
->
console
);
lxc_delete_tty
(
&
handler
->
conf
->
tty_info
);
lxc_delete_tty
(
&
handler
->
conf
->
tty_info
);
...
@@ -952,8 +966,8 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
...
@@ -952,8 +966,8 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
continue
;
continue
;
/* close state client socket */
/* close state client socket */
close
(
client
->
clientfd
);
lxc_list_del
(
cur
);
lxc_list_del
(
cur
);
close
(
client
->
clientfd
);
free
(
cur
->
elem
);
free
(
cur
->
elem
);
free
(
cur
);
free
(
cur
);
}
}
...
...
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