Package: lxc
Version: 0.8.0-1
Severity: wishlist
Tags: patch
Dear Maintainer,
Actually when calling, "/etc/init.d/lxc stop", lxc-halt will get called
for every containers which have auto-start enabled.
As mentioned in #683443, this doesn't work for containers which have
rootfs on a block device (the host system cannot chroot into a container
in this case).
On the other hand, the newly introduced lxc-shutdown requires the
administrator to modify each container's inittab (or whatever /sbin/init
variant is used).
I feel there's no "one size fits all"-solution. So my suggestion
(implemented in the attached patch) would be to delegate this choice to
the administrator, via an LXC_SHUTDOWN entry in /etc/default/lxc.
The patch also adds a debconf entry which will ask which shutdown system
should be used.
Thanks !
Cheers,
Marc
-- System Information:
Debian Release: wheezy/sid
APT prefers testing
APT policy: (700, 'testing'), (500, 'testing-proposed-updates'), (500,
'stable'), (300, 'unstable'), (100, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 3.2.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages lxc depends on:
ii debconf [debconf-2.0] 1.5.46
ii libapparmor1 2.7.103-4
ii libc6 2.13-35
ii libcap2 1:2.22-1.2
ii multiarch-support 2.13-35
Versions of packages lxc recommends:
ii cdebootstrap 0.5.9
ii debootstrap 1.0.42
ii libcap2-bin 1:2.22-1.2
lxc suggests no packages.
-- debconf information excluded
diff -ru lxc-0.8.0.orig/debian/lxc.config lxc-0.8.0/debian/lxc.config
--- lxc-0.8.0.orig/debian/lxc.config 2012-11-12 15:19:19.000000000 +0100
+++ lxc-0.8.0/debian/lxc.config 2012-11-25 11:05:14.540766013 +0100
@@ -13,6 +13,8 @@
db_set lxc/auto "${LXC_AUTO}"
db_set lxc/directory "${LXC_DIRECTORY}"
+
+ db_set lxc/shutdown "${LXC_SHUTDOWN}"
fi
db_settitle lxc/title
@@ -23,4 +25,8 @@
db_input high lxc/directory "${LXC_DIRECTORY}" || true
db_go
+db_settitle lxc/title
+db_input high lxc/shutdown "${LXC_SHUTDOWN}" || true
+db_go
+
db_stop
diff -ru lxc-0.8.0.orig/debian/lxc.init lxc-0.8.0/debian/lxc.init
--- lxc-0.8.0.orig/debian/lxc.init 2012-11-12 15:19:19.000000000 +0100
+++ lxc-0.8.0/debian/lxc.init 2012-11-24 21:21:16.144670238 +0100
@@ -30,6 +30,7 @@
fi
LXC_AUTO="${LXC_AUTO:-true}"
+LXC_SHUTDOWN="${LXC_SHUTDOWN:-halt}"
Lxc ()
{
@@ -99,13 +100,13 @@
stop)
log_daemon_msg "Stopping Linux Containers"
- Lxc halt
+ Lxc "${LXC_SHUTDOWN}"
;;
restart|force-reload)
log_daemon_msg "Restarting Linux Containers"
- Lxc stop
+ Lxc "${LXC_SHUTDOWN}"
Lxc start
;;
diff -ru lxc-0.8.0.orig/debian/lxc.postinst lxc-0.8.0/debian/lxc.postinst
--- lxc-0.8.0.orig/debian/lxc.postinst 2012-11-12 15:19:19.000000000 +0100
+++ lxc-0.8.0/debian/lxc.postinst 2012-11-25 11:34:50.731098562 +0100
@@ -14,6 +14,9 @@
db_get lxc/directory
LXC_DIRECTORY="${RET:-/var/lib/lxc}" # string (w/o empty)
+ db_get lxc/shutdown
+ LXC_SHUTDOWN="${RET:-halt}" # string (w/o empty)
+
db_stop
if [ ! -e "${_CONFFILE}" ]
@@ -24,6 +27,7 @@
LXC_AUTO="${LXC_AUTO}"
LXC_DIRECTORY="${LXC_DIRECTORY}"
+LXC_SHUTDOWN="${LXC_SHUTDOWN}"
EOF
fi
diff -ru lxc-0.8.0.orig/debian/lxc.templates lxc-0.8.0/debian/lxc.templates
--- lxc-0.8.0.orig/debian/lxc.templates 2012-11-12 15:19:19.000000000 +0100
+++ lxc-0.8.0/debian/lxc.templates 2012-11-25 11:18:17.765711440 +0100
@@ -20,3 +20,17 @@
Containers.
.
If unsure, use /var/lib/lxc (default).
+
+Template: lxc/shutdown
+Type: string
+Default: halt
+_Description: LXC shutdown method
+ Different lxc subcommands can be used to shutdown Linux Containers. All of
+ them have drawbacks.
+ .
+ lxc-halt(1) won't work for containers which have a dedicated block device as
+ rootfs. lxc-shutdown(1) requires the container's inittab to be configured to
+ respond to SIGINT and SIGPWR signals. lxc-stop(1) kills all the processes
+ inside the container, without allowing them to terminate cleanly.
+ .
+ If unsure, use halt (default).