Discussion:
[lxc-devel] [PATCH] have systemd service call lxc-autostart via script
Dwight Engen
2014-05-01 19:33:58 UTC
Permalink
- reuse the sysvinit script to ensure that if the lxc is configured to use
a bridge setup by libvirt, the bridge will be available before starting
the container

- made the sysvinit script check for the existance of ifconfig, and fall
back to ip link list if available

- made the lxc service also dependant on the network.target

- autoconfized the paths in the service file and sysvinit script

Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66 ------------------------------
config/init/sysvinit/lxc.in | 82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 +
8 files changed, 117 insertions(+), 85 deletions(-)
delete mode 100644 config/init/systemd/lxc.service
create mode 100644 config/init/systemd/lxc.service.in
delete mode 100755 config/init/sysvinit/lxc
create mode 100755 config/init/sysvinit/lxc.in

diff --git a/.gitignore b/.gitignore
index 8145f81..77b1ceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc

doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
index de5ee50..bbc7baa 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system

-install-systemd: lxc.service lxc-devsetup
+lxc-autostart: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+ -e 's|[@]SYSCONFDIR[@]|$(sysconfdir)|g' \
+ -e 's|[@]LOCALSTATEDIR[@]|$(localstatedir)|g' \
+ -e 's|[@]BINDIR[@]|$(bindir)|g' \
+ < $< > $@-t && \
+ chmod a+x $@-t && \
+ mv $@-t $@
+BUILT_SOURCES = lxc-autostart
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/

@@ -13,7 +23,7 @@ uninstall-systemd:
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) || :

-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart

install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service b/config/init/systemd/lxc.service
deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
new file mode 100644
index 0000000..2f293eb
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStartPre=@libexecdir@/lxc/lxc-devsetup
+ExecStart=@libexecdir@/lxc/lxc-autostart start
+ExecStop=@libexecdir@/lxc/lxc-autostart stop
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for autostart.
-#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[ ]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[ ]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for autostart.
+#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+sysconfdir="@SYSCONFDIR@"
+bindir="@BINDIR@"
+localstatedir="@LOCALSTATEDIR@"
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: " "$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..f4286c2 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart
%endif

%if %{with_python}
--
1.9.0
Stéphane Graber
2014-05-01 20:06:02 UTC
Permalink
Post by Dwight Engen
- reuse the sysvinit script to ensure that if the lxc is configured to use
a bridge setup by libvirt, the bridge will be available before starting
the container
- made the sysvinit script check for the existance of ifconfig, and fall
back to ip link list if available
- made the lxc service also dependant on the network.target
- autoconfized the paths in the service file and sysvinit script
Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66 ------------------------------
config/init/sysvinit/lxc.in | 82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 +
8 files changed, 117 insertions(+), 85 deletions(-)
delete mode 100644 config/init/systemd/lxc.service
create mode 100644 config/init/systemd/lxc.service.in
delete mode 100755 config/init/sysvinit/lxc
create mode 100755 config/init/sysvinit/lxc.in
diff --git a/.gitignore b/.gitignore
index 8145f81..77b1ceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc
doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
index de5ee50..bbc7baa 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
-install-systemd: lxc.service lxc-devsetup
+lxc-autostart: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+BUILT_SOURCES = lxc-autostart
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart
install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service b/config/init/systemd/lxc.service
deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
new file mode 100644
index 0000000..2f293eb
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
^ That still seems wrong to me, lxc-autostart is a standard binary in BINDIR.
Post by Dwight Engen
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for autostart.
-#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[ ]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[ ]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for autostart.
+#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: " "$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..f4286c2 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart
%endif
%if %{with_python}
--
1.9.0
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/03434d37/attachment.sig>
Dwight Engen
2014-05-01 20:22:18 UTC
Permalink
On Thu, 1 May 2014 16:06:02 -0400
Post by Stéphane Graber
Post by Dwight Engen
- reuse the sysvinit script to ensure that if the lxc is configured
to use a bridge setup by libvirt, the bridge will be available
before starting the container
- made the sysvinit script check for the existance of ifconfig, and
fall back to ip link list if available
- made the lxc service also dependant on the network.target
- autoconfized the paths in the service file and sysvinit script
Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66
------------------------------ config/init/sysvinit/lxc.in |
82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 + 8 files changed, 117
insertions(+), 85 deletions(-) delete mode 100644
config/init/systemd/lxc.service create mode 100644
config/init/systemd/lxc.service.in delete mode 100755
config/init/sysvinit/lxc create mode 100755
config/init/sysvinit/lxc.in
diff --git a/.gitignore b/.gitignore
index 8145f81..77b1ceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc
doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am
b/config/init/systemd/Makefile.am index de5ee50..bbc7baa 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
-install-systemd: lxc.service lxc-devsetup
+lxc-autostart: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+BUILT_SOURCES = lxc-autostart
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart
install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service
b/config/init/systemd/lxc.service deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in
b/config/init/systemd/lxc.service.in new file mode 100644
index 0000000..2f293eb
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
^ That still seems wrong to me, lxc-autostart is a standard binary in BINDIR.
Perhaps I should have called this script a different name:
@libexecdir@/lxc/lxc-autostart is a shell script (generated from the
sysvinit script by the build system) that calls @bindir@/lxc-autostart
after waiting for the bridge to come online.
Post by Stéphane Graber
Post by Dwight Engen
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for
autostart. -#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[
]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[
]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart
-a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in
b/config/init/sysvinit/lxc.in new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for
autostart. +#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link'
"$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: "
"$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..f4286c2 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart
%endif
%if %{with_python}
--
1.9.0
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
Stéphane Graber
2014-05-01 20:45:59 UTC
Permalink
Post by Dwight Engen
On Thu, 1 May 2014 16:06:02 -0400
Post by Stéphane Graber
Post by Dwight Engen
- reuse the sysvinit script to ensure that if the lxc is configured
to use a bridge setup by libvirt, the bridge will be available
before starting the container
- made the sysvinit script check for the existance of ifconfig, and
fall back to ip link list if available
- made the lxc service also dependant on the network.target
- autoconfized the paths in the service file and sysvinit script
Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66
------------------------------ config/init/sysvinit/lxc.in |
82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 + 8 files changed, 117
insertions(+), 85 deletions(-) delete mode 100644
config/init/systemd/lxc.service create mode 100644
config/init/systemd/lxc.service.in delete mode 100755
config/init/sysvinit/lxc create mode 100755
config/init/sysvinit/lxc.in
diff --git a/.gitignore b/.gitignore
index 8145f81..77b1ceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc
doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am
b/config/init/systemd/Makefile.am index de5ee50..bbc7baa 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
-install-systemd: lxc.service lxc-devsetup
+lxc-autostart: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+BUILT_SOURCES = lxc-autostart
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart
install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service
b/config/init/systemd/lxc.service deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in
b/config/init/systemd/lxc.service.in new file mode 100644
index 0000000..2f293eb
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
^ That still seems wrong to me, lxc-autostart is a standard binary in BINDIR.
@libexecdir@/lxc/lxc-autostart is a shell script (generated from the
after waiting for the bridge to come online.
Oh, I see, I should have read the whole diff :)

Can we maybe call it lxc-autostart-helper or something like that to
clear up any confusion?
Post by Dwight Engen
Post by Stéphane Graber
Post by Dwight Engen
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for
autostart. -#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[
]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[
]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in
b/config/init/sysvinit/lxc.in new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for
autostart. +#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link'
"$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: "
"$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..f4286c2 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart
%endif
%if %{with_python}
--
1.9.0
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/a022c082/attachment-0001.sig>
Dwight Engen
2014-05-01 21:00:40 UTC
Permalink
On Thu, 1 May 2014 16:45:59 -0400
Post by Stéphane Graber
Post by Dwight Engen
On Thu, 1 May 2014 16:06:02 -0400
Post by Stéphane Graber
Post by Dwight Engen
- reuse the sysvinit script to ensure that if the lxc is
configured to use a bridge setup by libvirt, the bridge will be
available before starting the container
- made the sysvinit script check for the existance of ifconfig,
and fall back to ip link list if available
- made the lxc service also dependant on the network.target
- autoconfized the paths in the service file and sysvinit script
Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66
------------------------------
config/init/sysvinit/lxc.in | 82
++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 + 8 files changed, 117
insertions(+), 85 deletions(-) delete mode 100644
config/init/systemd/lxc.service create mode 100644
config/init/systemd/lxc.service.in delete mode 100755
config/init/sysvinit/lxc create mode 100755
config/init/sysvinit/lxc.in
diff --git a/.gitignore b/.gitignore
index 8145f81..77b1ceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc
doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am
b/config/init/systemd/Makefile.am index de5ee50..bbc7baa 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
-install-systemd: lxc.service lxc-devsetup
+lxc-autostart: ../sysvinit/lxc.in $(top_builddir)/config.status
+
$(AM_V_GEN)sed \
+ -e
+ -e
+ -e
&& \
&& \
+BUILT_SOURCES = lxc-autostart
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service
$(DESTDIR)$(SYSTEMD_UNIT_DIR)/
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart
install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service
b/config/init/systemd/lxc.service deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in
b/config/init/systemd/lxc.service.in new file mode 100644
index 0000000..2f293eb
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
^ That still seems wrong to me, lxc-autostart is a standard binary in BINDIR.
@libexecdir@/lxc/lxc-autostart is a shell script (generated from the
sysvinit script by the build system) that calls
@bindir@/lxc-autostart after waiting for the bridge to come online.
Oh, I see, I should have read the whole diff :)
Can we maybe call it lxc-autostart-helper or something like that to
clear up any confusion?
Sure, I'll send up a v2 patch shortly.
Post by Stéphane Graber
Post by Dwight Engen
Post by Stéphane Graber
Post by Dwight Engen
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for
autostart. -#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[
]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[
]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
" /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
" /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0
{start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in
b/config/init/sysvinit/lxc.in new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for
autostart. +#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link'
"$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit
0; } +
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: "
"$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: "
"$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0
{start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..f4286c2 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart
%endif
%if %{with_python}
--
1.9.0
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
Michael H. Warfield
2014-05-01 21:14:12 UTC
Permalink
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".

Regards,
Mike
Post by Stéphane Graber
Post by Dwight Engen
- reuse the sysvinit script to ensure that if the lxc is configured to use
a bridge setup by libvirt, the bridge will be available before starting
the container
- made the sysvinit script check for the existance of ifconfig, and fall
back to ip link list if available
- made the lxc service also dependant on the network.target
- autoconfized the paths in the service file and sysvinit script
Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66 ------------------------------
config/init/sysvinit/lxc.in | 82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 +
8 files changed, 117 insertions(+), 85 deletions(-)
delete mode 100644 config/init/systemd/lxc.service
create mode 100644 config/init/systemd/lxc.service.in
delete mode 100755 config/init/sysvinit/lxc
create mode 100755 config/init/sysvinit/lxc.in
diff --git a/.gitignore b/.gitignore
index 8145f81..77b1ceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc
doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
index de5ee50..bbc7baa 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
-install-systemd: lxc.service lxc-devsetup
+lxc-autostart: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+BUILT_SOURCES = lxc-autostart
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart
install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service b/config/init/systemd/lxc.service
deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
new file mode 100644
index 0000000..2f293eb
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
^ That still seems wrong to me, lxc-autostart is a standard binary in BINDIR.
Post by Dwight Engen
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for autostart.
-#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[ ]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[ ]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for autostart.
+#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: " "$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..f4286c2 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart
%endif
%if %{with_python}
--
1.9.0
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/527e57b4/attachment.sig>
Stéphane Graber
2014-05-01 21:31:50 UTC
Permalink
Post by Michael H. Warfield
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".
I can see why you'd auto-start both the null group and say a "boot"
group, but I don't think we should auto-start them all.

A reason is that I use those groups as a way to easily start a group of
interdependent containers, when I need those, I do "lxc-autostart -g
blah" and all containers that have lxc.group = blah and lxc.start.auto =
1 will start properly sorted, with the right delays, ...). I however
don't necessarily want those to start at boot.
Post by Michael H. Warfield
Regards,
Mike
Post by Stéphane Graber
Post by Dwight Engen
- reuse the sysvinit script to ensure that if the lxc is configured to use
a bridge setup by libvirt, the bridge will be available before starting
the container
- made the sysvinit script check for the existance of ifconfig, and fall
back to ip link list if available
- made the lxc service also dependant on the network.target
- autoconfized the paths in the service file and sysvinit script
Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66 ------------------------------
config/init/sysvinit/lxc.in | 82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 +
8 files changed, 117 insertions(+), 85 deletions(-)
delete mode 100644 config/init/systemd/lxc.service
create mode 100644 config/init/systemd/lxc.service.in
delete mode 100755 config/init/sysvinit/lxc
create mode 100755 config/init/sysvinit/lxc.in
diff --git a/.gitignore b/.gitignore
index 8145f81..77b1ceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc
doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
index de5ee50..bbc7baa 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
-install-systemd: lxc.service lxc-devsetup
+lxc-autostart: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+BUILT_SOURCES = lxc-autostart
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart
install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service b/config/init/systemd/lxc.service
deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
new file mode 100644
index 0000000..2f293eb
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
^ That still seems wrong to me, lxc-autostart is a standard binary in BINDIR.
Post by Dwight Engen
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for autostart.
-#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[ ]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[ ]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for autostart.
+#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: " "$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..f4286c2 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart
%endif
%if %{with_python}
--
1.9.0
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/e029a005/attachment.sig>
Michael H. Warfield
2014-05-01 21:51:15 UTC
Permalink
Post by Stéphane Graber
Post by Michael H. Warfield
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".
I can see why you'd auto-start both the null group and say a "boot"
group, but I don't think we should auto-start them all.
OTOH, I wanted to group my services "WittsEnd", "WittsEnd-DNS",
"WittsEnd-Web", "WittsEnd-DB" so they could be filtered and managed as
groups but I want them all to start at boot, maybe by groups (boot the
DNS first and then the DB and then the Web). I would control if they
autoboot at boot time with the autoboot parameter. The order grouping
can be handled now with some of the other options but, if autoboot does
not mean we autoboot the container then we chose the wrong name for the
parameter.

Perhaps we need a parameter in /etc/lxc/lxc.conf that can specify what
groups to boot at boot time? The fact that this is not parameterized,
it works in a way that forces me to modify the system scripts with is
(cough) suboptimal. Alternatively, if a container could belong to
multiple groups, say "WittsEnd-DB,boot" then anything belonging to the
boot group would autoboot at boot (I'm sounding like I have a stutter
now) would then autoboot.
Post by Stéphane Graber
A reason is that I use those groups as a way to easily start a group of
interdependent containers, when I need those, I do "lxc-autostart -g
blah" and all containers that have lxc.group = blah and lxc.start.auto =
1 will start properly sorted, with the right delays, ...). I however
don't necessarily want those to start at boot.
That's fine for you but it's not how I need them to work in a production
environment when I reboot the iron. What you do after the iron is up is
not an "autoboot" condition but one where you are boot and controlling
groups. A friend of mine has "ByTheSea" and my son has "Malamaber" on
my colo iron. Using groups is great for me to shut down all the
"Malamber" containers collectively but I want all of them coming up if I
flip the BRS (Big Red Switch) on the iron.

I've suggested two options above that could accommodate both paradigms.
Parameter in /etc/lxc/lxc.conf or multiple group memberships. Thoughts?

Regards,
Mike
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Dwight Engen
- reuse the sysvinit script to ensure that if the lxc is configured to use
a bridge setup by libvirt, the bridge will be available before starting
the container
- made the sysvinit script check for the existance of ifconfig, and fall
back to ip link list if available
- made the lxc service also dependant on the network.target
- autoconfized the paths in the service file and sysvinit script
Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66 ------------------------------
config/init/sysvinit/lxc.in | 82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 +
8 files changed, 117 insertions(+), 85 deletions(-)
delete mode 100644 config/init/systemd/lxc.service
create mode 100644 config/init/systemd/lxc.service.in
delete mode 100755 config/init/sysvinit/lxc
create mode 100755 config/init/sysvinit/lxc.in
diff --git a/.gitignore b/.gitignore
index 8145f81..77b1ceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc
doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
index de5ee50..bbc7baa 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
-install-systemd: lxc.service lxc-devsetup
+lxc-autostart: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+BUILT_SOURCES = lxc-autostart
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart
install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service b/config/init/systemd/lxc.service
deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
new file mode 100644
index 0000000..2f293eb
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
^ That still seems wrong to me, lxc-autostart is a standard binary in BINDIR.
Post by Dwight Engen
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for autostart.
-#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[ ]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[ ]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for autostart.
+#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: " "$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..f4286c2 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart
%endif
%if %{with_python}
--
1.9.0
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/4a22e046/attachment.sig>
Stéphane Graber
2014-05-01 21:57:47 UTC
Permalink
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Michael H. Warfield
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".
I can see why you'd auto-start both the null group and say a "boot"
group, but I don't think we should auto-start them all.
OTOH, I wanted to group my services "WittsEnd", "WittsEnd-DNS",
"WittsEnd-Web", "WittsEnd-DB" so they could be filtered and managed as
groups but I want them all to start at boot, maybe by groups (boot the
DNS first and then the DB and then the Web). I would control if they
autoboot at boot time with the autoboot parameter. The order grouping
can be handled now with some of the other options but, if autoboot does
not mean we autoboot the container then we chose the wrong name for the
parameter.
Perhaps we need a parameter in /etc/lxc/lxc.conf that can specify what
groups to boot at boot time? The fact that this is not parameterized,
it works in a way that forces me to modify the system scripts with is
(cough) suboptimal. Alternatively, if a container could belong to
multiple groups, say "WittsEnd-DB,boot" then anything belonging to the
boot group would autoboot at boot (I'm sounding like I have a stutter
now) would then autoboot.
Post by Stéphane Graber
A reason is that I use those groups as a way to easily start a group of
interdependent containers, when I need those, I do "lxc-autostart -g
blah" and all containers that have lxc.group = blah and lxc.start.auto =
1 will start properly sorted, with the right delays, ...). I however
don't necessarily want those to start at boot.
That's fine for you but it's not how I need them to work in a production
environment when I reboot the iron. What you do after the iron is up is
not an "autoboot" condition but one where you are boot and controlling
groups. A friend of mine has "ByTheSea" and my son has "Malamaber" on
my colo iron. Using groups is great for me to shut down all the
"Malamber" containers collectively but I want all of them coming up if I
flip the BRS (Big Red Switch) on the iron.
I've suggested two options above that could accommodate both paradigms.
Parameter in /etc/lxc/lxc.conf or multiple group memberships. Thoughts?
Multiple group memberships is already supported, lxc.group is stored as
a list so you could do as I suggested in my previous e-mail and have the
init script call ("lxc-autostart && lxc-autostart -g boot") then have
the containers you want to start at boot time have the lxc.group = boot
on top of any existing lxc.group they may already have.

Support for a list of groups to auto-start in /etc/lxc/lxc.conf was also
part of the original specification, however this hasn't been implemented
yet, mostly because the parser for lxc.conf is rather minimal and it
seemed to much of a pain at the time :)

Regardless, patches are welcome for that bit :)
Post by Michael H. Warfield
Regards,
Mike
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Dwight Engen
- reuse the sysvinit script to ensure that if the lxc is configured to use
a bridge setup by libvirt, the bridge will be available before starting
the container
- made the sysvinit script check for the existance of ifconfig, and fall
back to ip link list if available
- made the lxc service also dependant on the network.target
- autoconfized the paths in the service file and sysvinit script
Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66 ------------------------------
config/init/sysvinit/lxc.in | 82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 +
8 files changed, 117 insertions(+), 85 deletions(-)
delete mode 100644 config/init/systemd/lxc.service
create mode 100644 config/init/systemd/lxc.service.in
delete mode 100755 config/init/sysvinit/lxc
create mode 100755 config/init/sysvinit/lxc.in
diff --git a/.gitignore b/.gitignore
index 8145f81..77b1ceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc
doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
index de5ee50..bbc7baa 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
-install-systemd: lxc.service lxc-devsetup
+lxc-autostart: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+BUILT_SOURCES = lxc-autostart
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart
install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service b/config/init/systemd/lxc.service
deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
new file mode 100644
index 0000000..2f293eb
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
^ That still seems wrong to me, lxc-autostart is a standard binary in BINDIR.
Post by Dwight Engen
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for autostart.
-#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[ ]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[ ]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for autostart.
+#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: " "$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..f4286c2 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart
%endif
%if %{with_python}
--
1.9.0
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/e93f5988/attachment-0001.sig>
Serge Hallyn
2014-05-01 22:07:03 UTC
Permalink
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Michael H. Warfield
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".
I can see why you'd auto-start both the null group and say a "boot"
group, but I don't think we should auto-start them all.
OTOH, I wanted to group my services "WittsEnd", "WittsEnd-DNS",
"WittsEnd-Web", "WittsEnd-DB" so they could be filtered and managed as
groups but I want them all to start at boot, maybe by groups (boot the
DNS first and then the DB and then the Web). I would control if they
autoboot at boot time with the autoboot parameter. The order grouping
can be handled now with some of the other options but, if autoboot does
not mean we autoboot the container then we chose the wrong name for the
parameter.
Perhaps we need a parameter in /etc/lxc/lxc.conf that can specify what
groups to boot at boot time? The fact that this is not parameterized,
it works in a way that forces me to modify the system scripts with is
(cough) suboptimal. Alternatively, if a container could belong to
multiple groups, say "WittsEnd-DB,boot" then anything belonging to the
boot group would autoboot at boot (I'm sounding like I have a stutter
now) would then autoboot.
Post by Stéphane Graber
A reason is that I use those groups as a way to easily start a group of
interdependent containers, when I need those, I do "lxc-autostart -g
blah" and all containers that have lxc.group = blah and lxc.start.auto =
1 will start properly sorted, with the right delays, ...). I however
don't necessarily want those to start at boot.
That's fine for you but it's not how I need them to work in a production
environment when I reboot the iron. What you do after the iron is up is
not an "autoboot" condition but one where you are boot and controlling
groups. A friend of mine has "ByTheSea" and my son has "Malamaber" on
my colo iron. Using groups is great for me to shut down all the
"Malamber" containers collectively but I want all of them coming up if I
flip the BRS (Big Red Switch) on the iron.
I've suggested two options above that could accommodate both paradigms.
Parameter in /etc/lxc/lxc.conf or multiple group memberships. Thoughts?
Multiple group memberships is already supported, lxc.group is stored as
a list so you could do as I suggested in my previous e-mail and have the
init script call ("lxc-autostart && lxc-autostart -g boot") then have
the containers you want to start at boot time have the lxc.group = boot
on top of any existing lxc.group they may already have.
Support for a list of groups to auto-start in /etc/lxc/lxc.conf was also
It seems to me cleaner to put a list of groups to auto-start at
boot in /etc/default/lxc. It's something for only the init script
to care about, not lxc itself.
Post by Stéphane Graber
part of the original specification, however this hasn't been implemented
yet, mostly because the parser for lxc.conf is rather minimal and it
seemed to much of a pain at the time :)
Regardless, patches are welcome for that bit :)
Post by Michael H. Warfield
Regards,
Mike
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Dwight Engen
- reuse the sysvinit script to ensure that if the lxc is configured to use
a bridge setup by libvirt, the bridge will be available before starting
the container
- made the sysvinit script check for the existance of ifconfig, and fall
back to ip link list if available
- made the lxc service also dependant on the network.target
- autoconfized the paths in the service file and sysvinit script
Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66 ------------------------------
config/init/sysvinit/lxc.in | 82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 +
8 files changed, 117 insertions(+), 85 deletions(-)
delete mode 100644 config/init/systemd/lxc.service
create mode 100644 config/init/systemd/lxc.service.in
delete mode 100755 config/init/sysvinit/lxc
create mode 100755 config/init/sysvinit/lxc.in
diff --git a/.gitignore b/.gitignore
index 8145f81..77b1ceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc
doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
index de5ee50..bbc7baa 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
-install-systemd: lxc.service lxc-devsetup
+lxc-autostart: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+BUILT_SOURCES = lxc-autostart
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart
install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service b/config/init/systemd/lxc.service
deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
new file mode 100644
index 0000000..2f293eb
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
^ That still seems wrong to me, lxc-autostart is a standard binary in BINDIR.
Post by Dwight Engen
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for autostart.
-#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[ ]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[ ]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for autostart.
+#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: " "$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..f4286c2 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart
%endif
%if %{with_python}
--
1.9.0
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
Michael H. Warfield
2014-05-01 22:16:36 UTC
Permalink
Post by Serge Hallyn
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Michael H. Warfield
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".
I can see why you'd auto-start both the null group and say a "boot"
group, but I don't think we should auto-start them all.
OTOH, I wanted to group my services "WittsEnd", "WittsEnd-DNS",
"WittsEnd-Web", "WittsEnd-DB" so they could be filtered and managed as
groups but I want them all to start at boot, maybe by groups (boot the
DNS first and then the DB and then the Web). I would control if they
autoboot at boot time with the autoboot parameter. The order grouping
can be handled now with some of the other options but, if autoboot does
not mean we autoboot the container then we chose the wrong name for the
parameter.
Perhaps we need a parameter in /etc/lxc/lxc.conf that can specify what
groups to boot at boot time? The fact that this is not parameterized,
it works in a way that forces me to modify the system scripts with is
(cough) suboptimal. Alternatively, if a container could belong to
multiple groups, say "WittsEnd-DB,boot" then anything belonging to the
boot group would autoboot at boot (I'm sounding like I have a stutter
now) would then autoboot.
Post by Stéphane Graber
A reason is that I use those groups as a way to easily start a group of
interdependent containers, when I need those, I do "lxc-autostart -g
blah" and all containers that have lxc.group = blah and lxc.start.auto =
1 will start properly sorted, with the right delays, ...). I however
don't necessarily want those to start at boot.
That's fine for you but it's not how I need them to work in a production
environment when I reboot the iron. What you do after the iron is up is
not an "autoboot" condition but one where you are boot and controlling
groups. A friend of mine has "ByTheSea" and my son has "Malamaber" on
my colo iron. Using groups is great for me to shut down all the
"Malamber" containers collectively but I want all of them coming up if I
flip the BRS (Big Red Switch) on the iron.
I've suggested two options above that could accommodate both paradigms.
Parameter in /etc/lxc/lxc.conf or multiple group memberships. Thoughts?
Multiple group memberships is already supported, lxc.group is stored as
a list so you could do as I suggested in my previous e-mail and have the
init script call ("lxc-autostart && lxc-autostart -g boot") then have
the containers you want to start at boot time have the lxc.group = boot
on top of any existing lxc.group they may already have.
Support for a list of groups to auto-start in /etc/lxc/lxc.conf was also
It seems to me cleaner to put a list of groups to auto-start at
boot in /etc/default/lxc. It's something for only the init script
to care about, not lxc itself.
Yeah, in the Fedora / RedHat / CentOS / (presumably) Oracle world that
might be a sourcible file in /etc/sysconfig/lxc which the initscript
would pick up and pass to lxc-autostart as a parameter. That would be a
distro specific thing then.
Post by Serge Hallyn
Post by Stéphane Graber
part of the original specification, however this hasn't been implemented
yet, mostly because the parser for lxc.conf is rather minimal and it
seemed to much of a pain at the time :)
Regardless, patches are welcome for that bit :)
Post by Michael H. Warfield
Regards,
Mike
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Dwight Engen
- reuse the sysvinit script to ensure that if the lxc is configured to use
a bridge setup by libvirt, the bridge will be available before starting
the container
- made the sysvinit script check for the existance of ifconfig, and fall
back to ip link list if available
- made the lxc service also dependant on the network.target
- autoconfized the paths in the service file and sysvinit script
Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66 ------------------------------
config/init/sysvinit/lxc.in | 82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 +
8 files changed, 117 insertions(+), 85 deletions(-)
delete mode 100644 config/init/systemd/lxc.service
create mode 100644 config/init/systemd/lxc.service.in
delete mode 100755 config/init/sysvinit/lxc
create mode 100755 config/init/sysvinit/lxc.in
diff --git a/.gitignore b/.gitignore
index 8145f81..77b1ceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc
doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
index de5ee50..bbc7baa 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
-install-systemd: lxc.service lxc-devsetup
+lxc-autostart: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+BUILT_SOURCES = lxc-autostart
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart
install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service b/config/init/systemd/lxc.service
deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
new file mode 100644
index 0000000..2f293eb
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
^ That still seems wrong to me, lxc-autostart is a standard binary in BINDIR.
Post by Dwight Engen
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for autostart.
-#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[ ]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[ ]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for autostart.
+#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: " "$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..f4286c2 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart
%endif
%if %{with_python}
--
1.9.0
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/a9863f0a/attachment.sig>
Michael H. Warfield
2014-05-02 00:29:31 UTC
Permalink
Post by Serge Hallyn
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Michael H. Warfield
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".
I can see why you'd auto-start both the null group and say a "boot"
group, but I don't think we should auto-start them all.
OTOH, I wanted to group my services "WittsEnd", "WittsEnd-DNS",
"WittsEnd-Web", "WittsEnd-DB" so they could be filtered and managed as
groups but I want them all to start at boot, maybe by groups (boot the
DNS first and then the DB and then the Web). I would control if they
autoboot at boot time with the autoboot parameter. The order grouping
can be handled now with some of the other options but, if autoboot does
not mean we autoboot the container then we chose the wrong name for the
parameter.
Perhaps we need a parameter in /etc/lxc/lxc.conf that can specify what
groups to boot at boot time? The fact that this is not parameterized,
it works in a way that forces me to modify the system scripts with is
(cough) suboptimal. Alternatively, if a container could belong to
multiple groups, say "WittsEnd-DB,boot" then anything belonging to the
boot group would autoboot at boot (I'm sounding like I have a stutter
now) would then autoboot.
Post by Stéphane Graber
A reason is that I use those groups as a way to easily start a group of
interdependent containers, when I need those, I do "lxc-autostart -g
blah" and all containers that have lxc.group = blah and lxc.start.auto =
1 will start properly sorted, with the right delays, ...). I however
don't necessarily want those to start at boot.
That's fine for you but it's not how I need them to work in a production
environment when I reboot the iron. What you do after the iron is up is
not an "autoboot" condition but one where you are boot and controlling
groups. A friend of mine has "ByTheSea" and my son has "Malamaber" on
my colo iron. Using groups is great for me to shut down all the
"Malamber" containers collectively but I want all of them coming up if I
flip the BRS (Big Red Switch) on the iron.
I've suggested two options above that could accommodate both paradigms.
Parameter in /etc/lxc/lxc.conf or multiple group memberships. Thoughts?
Multiple group memberships is already supported, lxc.group is stored as
a list so you could do as I suggested in my previous e-mail and have the
init script call ("lxc-autostart && lxc-autostart -g boot") then have
the containers you want to start at boot time have the lxc.group = boot
on top of any existing lxc.group they may already have.
Support for a list of groups to auto-start in /etc/lxc/lxc.conf was also
It seems to me cleaner to put a list of groups to auto-start at
boot in /etc/default/lxc. It's something for only the init script
to care about, not lxc itself.
Possibly so, possibly no. I'm ambivalent about that, over and above the
fact that it shoves it off onto distro dependent default locations and
formations.

It seems clear to me that we've got a problem with the unique nature of
the null group (i.e. when a group is not assigned to a group - I'll call
this group <NULL>). Since multiple group membership is allowed, we need
to take in to consideration the nature of this <NULL> group. If a
container is a member of ANY other group, it is automagically NOT a
member of the <NULL> group. Therefore, by it's nature, the <NULL> group
can not be joined with other groups in a multigroup set, giving rise to
the boot logic problem here.

By defaulting the autoboot process to the <NULL> group, we exacerbate
the problem because any membership in any group automatically removes
you from the <NULL> group so you can't automatically boot at boot time
if you are a member of any group. If we default the boot process to ANY
other group (boot, autoboot, etc) we avoid this problem because the
specific discreet group can then be joined to others. That's very
significant difference.

Short term, I would propose, in the autoboot process, to first boot any
members of a specific and agreed upon group like boot or autoboot (my
personal preference) and then boot any members of the <NULL> group in
all cases predicated that lxc.boot.autoboot = 1.

In the case of the systemd service and sysvinit scripts that Dwight and
I have been hashing over, I would propose, as a short term "fix"
something like this in the lxc sysvinit script:

# Start containers
wait_for_bridge
+ # Start autoboot containers first.
+ action $"Starting LXC autoboot containers: " /usr/bin/lxc-autostart -g autoboot
+ # Start NULL group containers last.
action $"Starting LXC containers: " /usr/bin/lxc-autostart

That should carry us over till we can get this parameterized at a deeper
level and does not conflict with any such parameterization.

What you do in Upstart is up to you.

The changes Dwight has submitted are complex enough in renames and files
that I'm not comfortable with submitting a patch until those are
incorporated. If Dwight wants to update his patch, I would support
that.

As a side note... We need to look forward to some utilities what would
add/set/delete/modify autoboot, delay, order and group options on
containers rather than forcing users to edit the individual config
files. These would likely be trivial shell scripts but they still need
to be done. Just rivets that need to be punched on the boiler.
Post by Serge Hallyn
Post by Stéphane Graber
part of the original specification, however this hasn't been implemented
yet, mostly because the parser for lxc.conf is rather minimal and it
seemed to much of a pain at the time :)
Regardless, patches are welcome for that bit :)
Regards,
Mike
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/4d05a43b/attachment.sig>
Michael H. Warfield
2014-05-01 22:07:21 UTC
Permalink
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Michael H. Warfield
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".
I can see why you'd auto-start both the null group and say a "boot"
group, but I don't think we should auto-start them all.
OTOH, I wanted to group my services "WittsEnd", "WittsEnd-DNS",
"WittsEnd-Web", "WittsEnd-DB" so they could be filtered and managed as
groups but I want them all to start at boot, maybe by groups (boot the
DNS first and then the DB and then the Web). I would control if they
autoboot at boot time with the autoboot parameter. The order grouping
can be handled now with some of the other options but, if autoboot does
not mean we autoboot the container then we chose the wrong name for the
parameter.
Perhaps we need a parameter in /etc/lxc/lxc.conf that can specify what
groups to boot at boot time? The fact that this is not parameterized,
it works in a way that forces me to modify the system scripts with is
(cough) suboptimal. Alternatively, if a container could belong to
multiple groups, say "WittsEnd-DB,boot" then anything belonging to the
boot group would autoboot at boot (I'm sounding like I have a stutter
now) would then autoboot.
Post by Stéphane Graber
A reason is that I use those groups as a way to easily start a group of
interdependent containers, when I need those, I do "lxc-autostart -g
blah" and all containers that have lxc.group = blah and lxc.start.auto =
1 will start properly sorted, with the right delays, ...). I however
don't necessarily want those to start at boot.
That's fine for you but it's not how I need them to work in a production
environment when I reboot the iron. What you do after the iron is up is
not an "autoboot" condition but one where you are boot and controlling
groups. A friend of mine has "ByTheSea" and my son has "Malamaber" on
my colo iron. Using groups is great for me to shut down all the
"Malamber" containers collectively but I want all of them coming up if I
flip the BRS (Big Red Switch) on the iron.
I've suggested two options above that could accommodate both paradigms.
Parameter in /etc/lxc/lxc.conf or multiple group memberships. Thoughts?
Multiple group memberships is already supported, lxc.group is stored as
a list so you could do as I suggested in my previous e-mail and have the
init script call ("lxc-autostart && lxc-autostart -g boot") then have
the containers you want to start at boot time have the lxc.group = boot
on top of any existing lxc.group they may already have.
Ok... I didn't realize that. Good to know. Can we also specify a list
of groups to boot with lxc-autostart that includes the null group? If
so, I might suggest a patch that would boot <NULL> and "boot".
Alternative there would be to run lxc-autostart twice. Once for <NULL>
and once for "-g boot". That would be a workaround for my case.

Funny. With multiple group membership and the use of a boot group, that
almost makes the autoboot parameter redundant. :-P Or, maybe, closer
to the openvz "disabled" parameter. I'll have to think on that a bit.
Post by Stéphane Graber
Support for a list of groups to auto-start in /etc/lxc/lxc.conf was also
part of the original specification, however this hasn't been implemented
yet, mostly because the parser for lxc.conf is rather minimal and it
seemed to much of a pain at the time :)
Yeah I know. I've got battle scars from working on parsers too. Here
there be dragons.
Post by Stéphane Graber
Regardless, patches are welcome for that bit :)
Post by Michael H. Warfield
Regards,
Mike
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Dwight Engen
- reuse the sysvinit script to ensure that if the lxc is configured to use
a bridge setup by libvirt, the bridge will be available before starting
the container
- made the sysvinit script check for the existance of ifconfig, and fall
back to ip link list if available
- made the lxc service also dependant on the network.target
- autoconfized the paths in the service file and sysvinit script
Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66 ------------------------------
config/init/sysvinit/lxc.in | 82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 +
8 files changed, 117 insertions(+), 85 deletions(-)
delete mode 100644 config/init/systemd/lxc.service
create mode 100644 config/init/systemd/lxc.service.in
delete mode 100755 config/init/sysvinit/lxc
create mode 100755 config/init/sysvinit/lxc.in
diff --git a/.gitignore b/.gitignore
index 8145f81..77b1ceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc
doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
index de5ee50..bbc7baa 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
-install-systemd: lxc.service lxc-devsetup
+lxc-autostart: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+BUILT_SOURCES = lxc-autostart
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart
install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service b/config/init/systemd/lxc.service
deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
new file mode 100644
index 0000000..2f293eb
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
^ That still seems wrong to me, lxc-autostart is a standard binary in BINDIR.
Post by Dwight Engen
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for autostart.
-#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[ ]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[ ]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for autostart.
+#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: " "$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..f4286c2 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart
%endif
%if %{with_python}
--
1.9.0
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 478 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/02726d3e/attachment.sig>
Stéphane Graber
2014-05-01 22:17:46 UTC
Permalink
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Michael H. Warfield
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".
I can see why you'd auto-start both the null group and say a "boot"
group, but I don't think we should auto-start them all.
OTOH, I wanted to group my services "WittsEnd", "WittsEnd-DNS",
"WittsEnd-Web", "WittsEnd-DB" so they could be filtered and managed as
groups but I want them all to start at boot, maybe by groups (boot the
DNS first and then the DB and then the Web). I would control if they
autoboot at boot time with the autoboot parameter. The order grouping
can be handled now with some of the other options but, if autoboot does
not mean we autoboot the container then we chose the wrong name for the
parameter.
Perhaps we need a parameter in /etc/lxc/lxc.conf that can specify what
groups to boot at boot time? The fact that this is not parameterized,
it works in a way that forces me to modify the system scripts with is
(cough) suboptimal. Alternatively, if a container could belong to
multiple groups, say "WittsEnd-DB,boot" then anything belonging to the
boot group would autoboot at boot (I'm sounding like I have a stutter
now) would then autoboot.
Post by Stéphane Graber
A reason is that I use those groups as a way to easily start a group of
interdependent containers, when I need those, I do "lxc-autostart -g
blah" and all containers that have lxc.group = blah and lxc.start.auto =
1 will start properly sorted, with the right delays, ...). I however
don't necessarily want those to start at boot.
That's fine for you but it's not how I need them to work in a production
environment when I reboot the iron. What you do after the iron is up is
not an "autoboot" condition but one where you are boot and controlling
groups. A friend of mine has "ByTheSea" and my son has "Malamaber" on
my colo iron. Using groups is great for me to shut down all the
"Malamber" containers collectively but I want all of them coming up if I
flip the BRS (Big Red Switch) on the iron.
I've suggested two options above that could accommodate both paradigms.
Parameter in /etc/lxc/lxc.conf or multiple group memberships. Thoughts?
Multiple group memberships is already supported, lxc.group is stored as
a list so you could do as I suggested in my previous e-mail and have the
init script call ("lxc-autostart && lxc-autostart -g boot") then have
the containers you want to start at boot time have the lxc.group = boot
on top of any existing lxc.group they may already have.
Ok... I didn't realize that. Good to know. Can we also specify a list
of groups to boot with lxc-autostart that includes the null group? If
so, I might suggest a patch that would boot <NULL> and "boot".
Alternative there would be to run lxc-autostart twice. Once for <NULL>
and once for "-g boot". That would be a workaround for my case.
Or we could support the rather weird "-g ,boot" which would stand for
"those that have lxc.group empty and those that have boot in lxc.group".
I don't think this works at the moment but could certainly be made to
work fairly easily.
Post by Michael H. Warfield
Funny. With multiple group membership and the use of a boot group, that
almost makes the autoboot parameter redundant. :-P Or, maybe, closer
to the openvz "disabled" parameter. I'll have to think on that a bit.
Post by Stéphane Graber
Support for a list of groups to auto-start in /etc/lxc/lxc.conf was also
part of the original specification, however this hasn't been implemented
yet, mostly because the parser for lxc.conf is rather minimal and it
seemed to much of a pain at the time :)
Yeah I know. I've got battle scars from working on parsers too. Here
there be dragons.
Post by Stéphane Graber
Regardless, patches are welcome for that bit :)
Post by Michael H. Warfield
Regards,
Mike
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Dwight Engen
- reuse the sysvinit script to ensure that if the lxc is configured to use
a bridge setup by libvirt, the bridge will be available before starting
the container
- made the sysvinit script check for the existance of ifconfig, and fall
back to ip link list if available
- made the lxc service also dependant on the network.target
- autoconfized the paths in the service file and sysvinit script
Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66 ------------------------------
config/init/sysvinit/lxc.in | 82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 +
8 files changed, 117 insertions(+), 85 deletions(-)
delete mode 100644 config/init/systemd/lxc.service
create mode 100644 config/init/systemd/lxc.service.in
delete mode 100755 config/init/sysvinit/lxc
create mode 100755 config/init/sysvinit/lxc.in
diff --git a/.gitignore b/.gitignore
index 8145f81..77b1ceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc
doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
index de5ee50..bbc7baa 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
-install-systemd: lxc.service lxc-devsetup
+lxc-autostart: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+BUILT_SOURCES = lxc-autostart
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart
install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service b/config/init/systemd/lxc.service
deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
new file mode 100644
index 0000000..2f293eb
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
^ That still seems wrong to me, lxc-autostart is a standard binary in BINDIR.
Post by Dwight Engen
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for autostart.
-#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[ ]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[ ]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for autostart.
+#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: " "$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..f4286c2 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart
%endif
%if %{with_python}
--
1.9.0
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/d8216935/attachment.sig>
Michael H. Warfield
2014-05-01 22:25:47 UTC
Permalink
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Michael H. Warfield
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".
I can see why you'd auto-start both the null group and say a "boot"
group, but I don't think we should auto-start them all.
OTOH, I wanted to group my services "WittsEnd", "WittsEnd-DNS",
"WittsEnd-Web", "WittsEnd-DB" so they could be filtered and managed as
groups but I want them all to start at boot, maybe by groups (boot the
DNS first and then the DB and then the Web). I would control if they
autoboot at boot time with the autoboot parameter. The order grouping
can be handled now with some of the other options but, if autoboot does
not mean we autoboot the container then we chose the wrong name for the
parameter.
Perhaps we need a parameter in /etc/lxc/lxc.conf that can specify what
groups to boot at boot time? The fact that this is not parameterized,
it works in a way that forces me to modify the system scripts with is
(cough) suboptimal. Alternatively, if a container could belong to
multiple groups, say "WittsEnd-DB,boot" then anything belonging to the
boot group would autoboot at boot (I'm sounding like I have a stutter
now) would then autoboot.
Post by Stéphane Graber
A reason is that I use those groups as a way to easily start a group of
interdependent containers, when I need those, I do "lxc-autostart -g
blah" and all containers that have lxc.group = blah and lxc.start.auto =
1 will start properly sorted, with the right delays, ...). I however
don't necessarily want those to start at boot.
That's fine for you but it's not how I need them to work in a production
environment when I reboot the iron. What you do after the iron is up is
not an "autoboot" condition but one where you are boot and controlling
groups. A friend of mine has "ByTheSea" and my son has "Malamaber" on
my colo iron. Using groups is great for me to shut down all the
"Malamber" containers collectively but I want all of them coming up if I
flip the BRS (Big Red Switch) on the iron.
I've suggested two options above that could accommodate both paradigms.
Parameter in /etc/lxc/lxc.conf or multiple group memberships. Thoughts?
Multiple group memberships is already supported, lxc.group is stored as
a list so you could do as I suggested in my previous e-mail and have the
init script call ("lxc-autostart && lxc-autostart -g boot") then have
the containers you want to start at boot time have the lxc.group = boot
on top of any existing lxc.group they may already have.
Ok... I didn't realize that. Good to know. Can we also specify a list
of groups to boot with lxc-autostart that includes the null group? If
so, I might suggest a patch that would boot <NULL> and "boot".
Alternative there would be to run lxc-autostart twice. Once for <NULL>
and once for "-g boot". That would be a workaround for my case.
Or we could support the rather weird "-g ,boot" which would stand for
"those that have lxc.group empty and those that have boot in lxc.group".
I don't think this works at the moment but could certainly be made to
work fairly easily.
Our minds are on the same track and it's not so weird and it certainly
has precedence on varying levels. The one that immediately pops to mind
(and screams caution) is the notation in rsync involving leading and
trailing slashes and how they're interpreted. This is simple in
comparison.
Post by Stéphane Graber
Post by Michael H. Warfield
Funny. With multiple group membership and the use of a boot group, that
almost makes the autoboot parameter redundant. :-P Or, maybe, closer
to the openvz "disabled" parameter. I'll have to think on that a bit.
Post by Stéphane Graber
Support for a list of groups to auto-start in /etc/lxc/lxc.conf was also
part of the original specification, however this hasn't been implemented
yet, mostly because the parser for lxc.conf is rather minimal and it
seemed to much of a pain at the time :)
Yeah I know. I've got battle scars from working on parsers too. Here
there be dragons.
Post by Stéphane Graber
Regardless, patches are welcome for that bit :)
[Big Snip]

Regards,
Mike
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/ccfbd15f/attachment.sig>
Michael H. Warfield
2014-05-01 22:22:02 UTC
Permalink
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Michael H. Warfield
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".
I can see why you'd auto-start both the null group and say a "boot"
group, but I don't think we should auto-start them all.
OTOH, I wanted to group my services "WittsEnd", "WittsEnd-DNS",
"WittsEnd-Web", "WittsEnd-DB" so they could be filtered and managed as
groups but I want them all to start at boot, maybe by groups (boot the
DNS first and then the DB and then the Web). I would control if they
autoboot at boot time with the autoboot parameter. The order grouping
can be handled now with some of the other options but, if autoboot does
not mean we autoboot the container then we chose the wrong name for the
parameter.
Perhaps we need a parameter in /etc/lxc/lxc.conf that can specify what
groups to boot at boot time? The fact that this is not parameterized,
it works in a way that forces me to modify the system scripts with is
(cough) suboptimal. Alternatively, if a container could belong to
multiple groups, say "WittsEnd-DB,boot" then anything belonging to the
boot group would autoboot at boot (I'm sounding like I have a stutter
now) would then autoboot.
Post by Stéphane Graber
A reason is that I use those groups as a way to easily start a group of
interdependent containers, when I need those, I do "lxc-autostart -g
blah" and all containers that have lxc.group = blah and lxc.start.auto =
1 will start properly sorted, with the right delays, ...). I however
don't necessarily want those to start at boot.
That's fine for you but it's not how I need them to work in a production
environment when I reboot the iron. What you do after the iron is up is
not an "autoboot" condition but one where you are boot and controlling
groups. A friend of mine has "ByTheSea" and my son has "Malamaber" on
my colo iron. Using groups is great for me to shut down all the
"Malamber" containers collectively but I want all of them coming up if I
flip the BRS (Big Red Switch) on the iron.
I've suggested two options above that could accommodate both paradigms.
Parameter in /etc/lxc/lxc.conf or multiple group memberships. Thoughts?
Multiple group memberships is already supported, lxc.group is stored as
a list so you could do as I suggested in my previous e-mail and have the
init script call ("lxc-autostart && lxc-autostart -g boot") then have
the containers you want to start at boot time have the lxc.group = boot
on top of any existing lxc.group they may already have.
Ok... I didn't realize that. Good to know. Can we also specify a list
of groups to boot with lxc-autostart that includes the null group? If
so, I might suggest a patch that would boot <NULL> and "boot".
Alternative there would be to run lxc-autostart twice. Once for <NULL>
and once for "-g boot". That would be a workaround for my case.
I know this null group thing is a corner case and I haven't looked at
the code yet but lxc-autostart specifies -g as a "comma separated list
of groups". The null group could be specified within that syntax...

Boot group "boot".
-g boot

Boot group <NULL> then "boot"
-g ,boot

Boot group "boot" then <NULL>
-g boot,

Boot group "boot" then <NULL> then "foo"
-g boot,,foo

I'm not going NEAR wildcarding or regexes but, is that plausable?

Regards,
Mike
Post by Michael H. Warfield
Funny. With multiple group membership and the use of a boot group, that
almost makes the autoboot parameter redundant. :-P Or, maybe, closer
to the openvz "disabled" parameter. I'll have to think on that a bit.
Post by Stéphane Graber
Support for a list of groups to auto-start in /etc/lxc/lxc.conf was also
part of the original specification, however this hasn't been implemented
yet, mostly because the parser for lxc.conf is rather minimal and it
seemed to much of a pain at the time :)
Yeah I know. I've got battle scars from working on parsers too. Here
there be dragons.
Post by Stéphane Graber
Regardless, patches are welcome for that bit :)
Post by Michael H. Warfield
Regards,
Mike
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Dwight Engen
- reuse the sysvinit script to ensure that if the lxc is configured to use
a bridge setup by libvirt, the bridge will be available before starting
the container
- made the sysvinit script check for the existance of ifconfig, and fall
back to ip link list if available
- made the lxc service also dependant on the network.target
- autoconfized the paths in the service file and sysvinit script
Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66 ------------------------------
config/init/sysvinit/lxc.in | 82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 +
8 files changed, 117 insertions(+), 85 deletions(-)
delete mode 100644 config/init/systemd/lxc.service
create mode 100644 config/init/systemd/lxc.service.in
delete mode 100755 config/init/sysvinit/lxc
create mode 100755 config/init/sysvinit/lxc.in
diff --git a/.gitignore b/.gitignore
index 8145f81..77b1ceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc
doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
index de5ee50..bbc7baa 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
-install-systemd: lxc.service lxc-devsetup
+lxc-autostart: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+BUILT_SOURCES = lxc-autostart
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart
install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service b/config/init/systemd/lxc.service
deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
new file mode 100644
index 0000000..2f293eb
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
^ That still seems wrong to me, lxc-autostart is a standard binary in BINDIR.
Post by Dwight Engen
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for autostart.
-#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[ ]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[ ]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for autostart.
+#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: " "$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..f4286c2 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart
%endif
%if %{with_python}
--
1.9.0
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/20134781/attachment-0001.sig>
Michael H. Warfield
2014-05-01 22:31:42 UTC
Permalink
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Stéphane Graber
Post by Michael H. Warfield
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".
I can see why you'd auto-start both the null group and say a "boot"
group, but I don't think we should auto-start them all.
OTOH, I wanted to group my services "WittsEnd", "WittsEnd-DNS",
"WittsEnd-Web", "WittsEnd-DB" so they could be filtered and managed as
groups but I want them all to start at boot, maybe by groups (boot the
DNS first and then the DB and then the Web). I would control if they
autoboot at boot time with the autoboot parameter. The order grouping
can be handled now with some of the other options but, if autoboot does
not mean we autoboot the container then we chose the wrong name for the
parameter.
Perhaps we need a parameter in /etc/lxc/lxc.conf that can specify what
groups to boot at boot time? The fact that this is not parameterized,
it works in a way that forces me to modify the system scripts with is
(cough) suboptimal. Alternatively, if a container could belong to
multiple groups, say "WittsEnd-DB,boot" then anything belonging to the
boot group would autoboot at boot (I'm sounding like I have a stutter
now) would then autoboot.
Post by Stéphane Graber
A reason is that I use those groups as a way to easily start a group of
interdependent containers, when I need those, I do "lxc-autostart -g
blah" and all containers that have lxc.group = blah and lxc.start.auto =
1 will start properly sorted, with the right delays, ...). I however
don't necessarily want those to start at boot.
That's fine for you but it's not how I need them to work in a production
environment when I reboot the iron. What you do after the iron is up is
not an "autoboot" condition but one where you are boot and controlling
groups. A friend of mine has "ByTheSea" and my son has "Malamaber" on
my colo iron. Using groups is great for me to shut down all the
"Malamber" containers collectively but I want all of them coming up if I
flip the BRS (Big Red Switch) on the iron.
I've suggested two options above that could accommodate both paradigms.
Parameter in /etc/lxc/lxc.conf or multiple group memberships. Thoughts?
Multiple group memberships is already supported, lxc.group is stored as
a list so you could do as I suggested in my previous e-mail and have the
init script call ("lxc-autostart && lxc-autostart -g boot") then have
the containers you want to start at boot time have the lxc.group = boot
on top of any existing lxc.group they may already have.
Support for a list of groups to auto-start in /etc/lxc/lxc.conf was also
part of the original specification, however this hasn't been implemented
yet, mostly because the parser for lxc.conf is rather minimal and it
seemed to much of a pain at the time :)
Well, wait a minute. Maybe it is and maybe it isn't. What if that
parameter was a direct analog of the -g parameter? IOW, you don't allow
multiple instantiations but just have a single parameter with a comma
separated list just like you have with -g? That seems pretty simple.
Just malloc a string and store it. You've already go the run-time
parser chopping up that csv string from the -g parameter (which would
obviously override).
Post by Stéphane Graber
Regardless, patches are welcome for that bit :)
I may look at this.

Regards,
Mike
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/09ca7951/attachment.sig>
Serge Hallyn
2014-05-01 21:57:04 UTC
Permalink
Post by Stéphane Graber
Post by Michael H. Warfield
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".
I can see why you'd auto-start both the null group and say a "boot"
group, but I don't think we should auto-start them all.
A reason is that I use those groups as a way to easily start a group of
interdependent containers, when I need those, I do "lxc-autostart -g
blah" and all containers that have lxc.group = blah and lxc.start.auto =
1 will start properly sorted, with the right delays, ...). I however
don't necessarily want those to start at boot.
And... do you have containers in lxc.cgroup = blah which you do not
want to have started when you do lxc-autostart -g blah?
Stéphane Graber
2014-05-01 21:59:58 UTC
Permalink
Post by Serge Hallyn
Post by Stéphane Graber
Post by Michael H. Warfield
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".
I can see why you'd auto-start both the null group and say a "boot"
group, but I don't think we should auto-start them all.
A reason is that I use those groups as a way to easily start a group of
interdependent containers, when I need those, I do "lxc-autostart -g
blah" and all containers that have lxc.group = blah and lxc.start.auto =
1 will start properly sorted, with the right delays, ...). I however
don't necessarily want those to start at boot.
And... do you have containers in lxc.cgroup = blah which you do not
want to have started when you do lxc-autostart -g blah?
At the moment, no because no tool except lxc-autostart currently read
lxc.group, however the fact we put this as lxc.group instead of
lxc.start.group in the original spec suggests that we wanted to
eventually use that for group operations outside of the autostart case.
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/72ccb475/attachment.sig>
Michael H. Warfield
2014-05-01 22:10:27 UTC
Permalink
Post by Stéphane Graber
Post by Serge Hallyn
Post by Stéphane Graber
Post by Michael H. Warfield
Related to this... Dwight and I have been bouncing a couple of things
back and forth and I noticed that lxc-autostart is being called from the
sysvinit scripts without the -a parameter. That means that any
container in a non-null group will not be autostart on boot. I feel
that's the wrong behavior. If autoboot = 1 then it should be autobooted
on boot. What you do after boot is up to you but I would expect it to
be "autoboot = 1" => "autobooted on bootup", not "autoboot = 1" =>
"autobooted on bootup if it's not in a group".
I can see why you'd auto-start both the null group and say a "boot"
group, but I don't think we should auto-start them all.
A reason is that I use those groups as a way to easily start a group of
interdependent containers, when I need those, I do "lxc-autostart -g
blah" and all containers that have lxc.group = blah and lxc.start.auto =
1 will start properly sorted, with the right delays, ...). I however
don't necessarily want those to start at boot.
And... do you have containers in lxc.cgroup = blah which you do not
want to have started when you do lxc-autostart -g blah?
At the moment, no because no tool except lxc-autostart currently read
lxc.group, however the fact we put this as lxc.group instead of
lxc.start.group in the original spec suggests that we wanted to
eventually use that for group operations outside of the autostart case.
Yeah, I agree with that. There are more possibilities here with that
group parameter, we just haven't explored them yet. Maybe adding a -g
option to lxc-ls and only get those members? It's got possibilities for
both our applications and higher level scripts.

Regards,
Mike
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/d57b9e40/attachment-0001.sig>
Dwight Engen
2014-05-01 21:17:52 UTC
Permalink
- reuse the sysvinit script to ensure that if the lxc is configured to use
a bridge setup by libvirt, the bridge will be available before starting
the container

- made the sysvinit script check for the existance of ifconfig, and fall
back to ip link list if available

- made the lxc service also dependant on the network.target

- autoconfized the paths in the service file and sysvinit script

Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
v2: rename script lxc-autostart to lxc-autostart-helper to avoid confusion

.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66 ------------------------------
config/init/sysvinit/lxc.in | 82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 +
8 files changed, 117 insertions(+), 85 deletions(-)
delete mode 100644 config/init/systemd/lxc.service
create mode 100644 config/init/systemd/lxc.service.in
delete mode 100755 config/init/sysvinit/lxc
create mode 100755 config/init/sysvinit/lxc.in

diff --git a/.gitignore b/.gitignore
index 8145f81..2b478cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart-helper
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc

doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
index de5ee50..fc374c5 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system

-install-systemd: lxc.service lxc-devsetup
+lxc-autostart-helper: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+ -e 's|[@]SYSCONFDIR[@]|$(sysconfdir)|g' \
+ -e 's|[@]LOCALSTATEDIR[@]|$(localstatedir)|g' \
+ -e 's|[@]BINDIR[@]|$(bindir)|g' \
+ < $< > $@-t && \
+ chmod a+x $@-t && \
+ mv $@-t $@
+BUILT_SOURCES = lxc-autostart-helper
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart-helper
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/

@@ -13,7 +23,7 @@ uninstall-systemd:
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) || :

-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart-helper

install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service b/config/init/systemd/lxc.service
deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
new file mode 100644
index 0000000..5f155b6
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStartPre=@libexecdir@/lxc/lxc-devsetup
+ExecStart=@libexecdir@/lxc/lxc-autostart-helper start
+ExecStop=@libexecdir@/lxc/lxc-autostart-helper stop
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for autostart.
-#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[ ]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[ ]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for autostart.
+#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+sysconfdir="@SYSCONFDIR@"
+bindir="@BINDIR@"
+localstatedir="@LOCALSTATEDIR@"
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: " "$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..c33e153 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart-helper
%endif

%if %{with_python}
--
1.9.0
Michael H. Warfield
2014-05-01 21:26:09 UTC
Permalink
Looks good to me with the provisio that I feel that autoboot on bootup
should be for all groups and not just the null group. Dwight told me in
another message that he did it that way because the Upstart script did
it that way. Was it an oversight or was it a decision? That can be a
separate patch to fix.

Regards,
Mike

Acked-by: Michael H. Warfield <mhw at WittsEnd.com>
Post by Dwight Engen
- reuse the sysvinit script to ensure that if the lxc is configured to use
a bridge setup by libvirt, the bridge will be available before starting
the container
- made the sysvinit script check for the existance of ifconfig, and fall
back to ip link list if available
- made the lxc service also dependant on the network.target
- autoconfized the paths in the service file and sysvinit script
Reported-by: CDR <venefax at gmail.com>
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
v2: rename script lxc-autostart to lxc-autostart-helper to avoid confusion
.gitignore | 3 ++
config/init/systemd/Makefile.am | 14 ++++++-
config/init/systemd/lxc.service | 17 --------
config/init/systemd/lxc.service.in | 17 ++++++++
config/init/sysvinit/lxc | 66 ------------------------------
config/init/sysvinit/lxc.in | 82 ++++++++++++++++++++++++++++++++++++++
configure.ac | 2 +
lxc.spec.in | 1 +
8 files changed, 117 insertions(+), 85 deletions(-)
delete mode 100644 config/init/systemd/lxc.service
create mode 100644 config/init/systemd/lxc.service.in
delete mode 100755 config/init/sysvinit/lxc
create mode 100755 config/init/sysvinit/lxc.in
diff --git a/.gitignore b/.gitignore
index 8145f81..2b478cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,9 @@ config/missing
config/libtool.m4
config/lt*.m4
config/bash/lxc
+config/init/systemd/lxc-autostart-helper
+config/init/systemd/lxc.service
+config/init/sysvinit/lxc
doc/*.1
doc/*.5
diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
index de5ee50..fc374c5 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -5,7 +5,17 @@ EXTRA_DIST = \
if INIT_SCRIPT_SYSTEMD
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
-install-systemd: lxc.service lxc-devsetup
+lxc-autostart-helper: ../sysvinit/lxc.in $(top_builddir)/config.status
+ $(AM_V_GEN)sed \
+BUILT_SOURCES = lxc-autostart-helper
+
+install-systemd: lxc.service lxc-devsetup lxc-autostart-helper
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
-pkglibexec_SCRIPTS = lxc-devsetup
+pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart-helper
install-data-local: install-systemd
uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc.service b/config/init/systemd/lxc.service
deleted file mode 100644
index aa20b91..0000000
--- a/config/init/systemd/lxc.service
+++ /dev/null
@@ -1,17 +0,0 @@
-[Unit]
-Description=LXC Container Initialization and Autoboot Code
-After=syslog.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStartPre=/usr/libexec/lxc/lxc-devsetup
-ExecStart=/usr/libexec/lxc/lxc-startup start
-ExecStop=/usr/libexec/lxc/lxc-startup stop
-# Environment=BOOTUP=serial
-# Environment=CONSOLETYPE=serial
-StandardOutput=syslog
-StandardError=syslog
-
-[Install]
-WantedBy=multi-user.target
diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
new file mode 100644
index 0000000..5f155b6
--- /dev/null
+++ b/config/init/systemd/lxc.service.in
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config/init/sysvinit/lxc b/config/init/sysvinit/lxc
deleted file mode 100755
index 5ab3c46..0000000
--- a/config/init/sysvinit/lxc
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-#
-# lxc Start/Stop LXC autoboot containers
-#
-# chkconfig: 345 99 01
-# description: Starts/Stops all LXC containers configured for autostart.
-#
-### BEGIN INIT INFO
-# Provides: lxc
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Bring up/down LXC autostart containers
-# Description: Bring up/down LXC autostart containers
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-# Check for needed utility program
-[ -x /usr/bin/lxc-autostart ] || exit 1
-
-# If libvirtd is providing the bridge, it might not be
-# immediately available, so wait a bit for it before starting
-# up the containers or else any that use the bridge will fail
-# to start
-wait_for_bridge()
-{
- [ -f /etc/lxc/default.conf ] || { return 0; }
-
- BRNAME=`grep '^[ ]*lxc.network.link' /etc/lxc/default.conf | sed 's/^.*=[ ]*//'`
- if [ -z "$BRNAME" ]; then
- return 0
- fi
-
- for try in `seq 1 30`; do
- ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
- if [ $? = 0 ]; then
- return
- fi
- sleep 1
- done
-}
-
-# See how we were called.
-case "$1" in
- start)
- [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
-
- # Start containers
- wait_for_bridge
- action $"Starting LXC containers: " /usr/bin/lxc-autostart
- touch /var/lock/subsys/lxc
- ;;
- stop)
- action $"Stopping LXC containers: " /usr/bin/lxc-autostart -a -A -s
- rm -f /var/lock/subsys/lxc
- ;;
- restart|reload|force-reload)
- $0 stop
- $0 start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
- exit 2
-esac
-exit $?
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
new file mode 100755
index 0000000..b1a725c
--- /dev/null
+++ b/config/init/sysvinit/lxc.in
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for autostart.
+#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Check for needed utility program
+[ -x "$bindir"/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
+
+ which ifconfig >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ifconfig -a"
+ else
+ which ip >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ cmd="ip link list"
+ fi
+ fi
+ [ -n cmd ] || { return 0; }
+
+ BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
+ if [ -z "$BRNAME" ]; then
+ return 0
+ fi
+
+ for try in `seq 1 30`; do
+ eval $cmd |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f "$localstatedir"/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " "$bindir"/lxc-autostart
+ touch "$localstatedir"/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: " "$bindir"/lxc-autostart -a -A -s
+ rm -f "$localstatedir"/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/configure.ac b/configure.ac
index 474e354..6e0d8df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,9 @@ AC_CONFIG_FILES([
config/bash/lxc
config/init/Makefile
config/init/sysvinit/Makefile
+ config/init/sysvinit/lxc
config/init/systemd/Makefile
+ config/init/systemd/lxc.service
config/init/upstart/Makefile
config/etc/Makefile
config/templates/Makefile
diff --git a/lxc.spec.in b/lxc.spec.in
index 5c9fdc8..c33e153 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -156,6 +156,7 @@ rm -rf %{buildroot}
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-autostart-helper
%endif
%if %{with_python}
--
1.9.0
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140501/07ac6fcc/attachment-0001.sig>
Michael H. Warfield
2014-05-02 17:30:04 UTC
Permalink
Post by Michael H. Warfield
Looks good to me with the provisio that I feel that autoboot on bootup
should be for all groups and not just the null group. Dwight told me in
another message that he did it that way because the Upstart script did
it that way. Was it an oversight or was it a decision? That can be a
separate patch to fix.
I haven't seen Dwight's patch go in and I haven't seen any other
commentary about it or my suggested change. His patch fixes a reported
problem and my change supports allowing containers which are members of
designated groups to boot (which I require). Therefore, I'm submitting
this patch. Both "boot" and "autoboot" were suggested for names of the
autoboot group. I choose to use "onboot" just to make it a little
clearer and disambiguate it from some of the other options.

This patch is dependent on Dwight's patch Subject:
[PATCH v2] have systemd service call lxc-autostart via script

Regards,
Mike
--
Add a non-null group for autobooting

This adds a non-null group (onboot) to the sysvinit startup script
for autobooting containers. This allows for containers which are
in other groups to be included in the autoboot process.

This script is used by both the sysvinit systems and the systemd
systems.

Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>
---
config/init/sysvinit/lxc.in | 3 +++
1 file changed, 3 insertions(+)

diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
index b1a725c..0b802af 100644
--- a/config/init/sysvinit/lxc.in
+++ b/config/init/sysvinit/lxc.in
@@ -64,6 +64,9 @@ case "$1" in

# Start containers
wait_for_bridge
+ # Start autoboot containers first.
+ action $"Starting LXC onboot containers: " /usr/bin/lxc-autostart -g onboot
+ # Start NULL group containers last.
action $"Starting LXC containers: " "$bindir"/lxc-autostart
touch "$localstatedir"/lock/subsys/lxc
;;
--
1.9.0
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140502/8dd85013/attachment.sig>
Serge Hallyn
2014-05-02 21:03:19 UTC
Permalink
Post by Michael H. Warfield
Post by Michael H. Warfield
Looks good to me with the provisio that I feel that autoboot on bootup
should be for all groups and not just the null group. Dwight told me in
another message that he did it that way because the Upstart script did
it that way. Was it an oversight or was it a decision? That can be a
separate patch to fix.
I haven't seen Dwight's patch go in and I haven't seen any other
commentary about it or my suggested change. His patch fixes a reported
problem and my change supports allowing containers which are members of
designated groups to boot (which I require). Therefore, I'm submitting
this patch. Both "boot" and "autoboot" were suggested for names of the
autoboot group. I choose to use "onboot" just to make it a little
clearer and disambiguate it from some of the other options.
[PATCH v2] have systemd service call lxc-autostart via script
Regards,
Mike
--
Add a non-null group for autobooting
This adds a non-null group (onboot) to the sysvinit startup script
for autobooting containers. This allows for containers which are
in other groups to be included in the autoboot process.
This script is used by both the sysvinit systems and the systemd
systems.
Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>
While this is the right place to do it, I don't think we should encourage
differences among init systems... So we should either do it in upstart
as well, or not do it at all imo. Otherwise admins will become very
confused.
Post by Michael H. Warfield
---
config/init/sysvinit/lxc.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
index b1a725c..0b802af 100644
--- a/config/init/sysvinit/lxc.in
+++ b/config/init/sysvinit/lxc.in
@@ -64,6 +64,9 @@ case "$1" in
# Start containers
wait_for_bridge
+ # Start autoboot containers first.
+ action $"Starting LXC onboot containers: " /usr/bin/lxc-autostart -g onboot
+ # Start NULL group containers last.
action $"Starting LXC containers: " "$bindir"/lxc-autostart
touch "$localstatedir"/lock/subsys/lxc
;;
--
1.9.0
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
Michael H. Warfield
2014-05-02 21:09:48 UTC
Permalink
Post by Serge Hallyn
Post by Michael H. Warfield
Post by Michael H. Warfield
Looks good to me with the provisio that I feel that autoboot on bootup
should be for all groups and not just the null group. Dwight told me in
another message that he did it that way because the Upstart script did
it that way. Was it an oversight or was it a decision? That can be a
separate patch to fix.
I haven't seen Dwight's patch go in and I haven't seen any other
commentary about it or my suggested change. His patch fixes a reported
problem and my change supports allowing containers which are members of
designated groups to boot (which I require). Therefore, I'm submitting
this patch. Both "boot" and "autoboot" were suggested for names of the
autoboot group. I choose to use "onboot" just to make it a little
clearer and disambiguate it from some of the other options.
[PATCH v2] have systemd service call lxc-autostart via script
Regards,
Mike
--
Add a non-null group for autobooting
This adds a non-null group (onboot) to the sysvinit startup script
for autobooting containers. This allows for containers which are
in other groups to be included in the autoboot process.
This script is used by both the sysvinit systems and the systemd
systems.
Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>
While this is the right place to do it, I don't think we should encourage
differences among init systems... So we should either do it in upstart
as well, or not do it at all imo. Otherwise admins will become very
confused.
I absolutely agree but I haven't been involved in that one. I would
strongly recommend that someone update the Upstart stuff. Do you want
me to look at it or do you want someone more familiar with Upstart to
look at it? I'll take a look.

Regards,
Mike
Post by Serge Hallyn
Post by Michael H. Warfield
---
config/init/sysvinit/lxc.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
index b1a725c..0b802af 100644
--- a/config/init/sysvinit/lxc.in
+++ b/config/init/sysvinit/lxc.in
@@ -64,6 +64,9 @@ case "$1" in
# Start containers
wait_for_bridge
+ # Start autoboot containers first.
+ action $"Starting LXC onboot containers: " /usr/bin/lxc-autostart -g onboot
+ # Start NULL group containers last.
action $"Starting LXC containers: " "$bindir"/lxc-autostart
touch "$localstatedir"/lock/subsys/lxc
;;
--
1.9.0
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140502/9cef3d5b/attachment.sig>
Michael H. Warfield
2014-05-02 21:20:11 UTC
Permalink
Post by Michael H. Warfield
Post by Serge Hallyn
Post by Michael H. Warfield
Post by Michael H. Warfield
Looks good to me with the provisio that I feel that autoboot on bootup
should be for all groups and not just the null group. Dwight told me in
another message that he did it that way because the Upstart script did
it that way. Was it an oversight or was it a decision? That can be a
separate patch to fix.
I haven't seen Dwight's patch go in and I haven't seen any other
commentary about it or my suggested change. His patch fixes a reported
problem and my change supports allowing containers which are members of
designated groups to boot (which I require). Therefore, I'm submitting
this patch. Both "boot" and "autoboot" were suggested for names of the
autoboot group. I choose to use "onboot" just to make it a little
clearer and disambiguate it from some of the other options.
[PATCH v2] have systemd service call lxc-autostart via script
Regards,
Mike
--
Add a non-null group for autobooting
This adds a non-null group (onboot) to the sysvinit startup script
for autobooting containers. This allows for containers which are
in other groups to be included in the autoboot process.
This script is used by both the sysvinit systems and the systemd
systems.
Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>
While this is the right place to do it, I don't think we should encourage
differences among init systems... So we should either do it in upstart
as well, or not do it at all imo. Otherwise admins will become very
confused.
I absolutely agree but I haven't been involved in that one. I would
strongly recommend that someone update the Upstart stuff. Do you want
me to look at it or do you want someone more familiar with Upstart to
look at it? I'll take a look.
I just had a look in that area and I have no idea what those files are
doing. I gather they're doing an "lxc-autostart -L" and then picking
off the first parameter as a container name to start in "lxc-instance"
and I can see where "order" might be handled by "lxc-autostart -L" in
the output but where is the "delay" parameter managed? The "simple"
thing would be to prepend another loop. I'll submit a patch for that.
Someone should look in more depth at what that's doing wrt the delay
parameter.

Regards,
Mike
Post by Michael H. Warfield
Post by Serge Hallyn
Post by Michael H. Warfield
---
config/init/sysvinit/lxc.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
index b1a725c..0b802af 100644
--- a/config/init/sysvinit/lxc.in
+++ b/config/init/sysvinit/lxc.in
@@ -64,6 +64,9 @@ case "$1" in
# Start containers
wait_for_bridge
+ # Start autoboot containers first.
+ action $"Starting LXC onboot containers: " /usr/bin/lxc-autostart -g onboot
+ # Start NULL group containers last.
action $"Starting LXC containers: " "$bindir"/lxc-autostart
touch "$localstatedir"/lock/subsys/lxc
;;
--
1.9.0
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140502/5d3c618b/attachment-0001.sig>
Stéphane Graber
2014-05-02 21:37:37 UTC
Permalink
Post by Michael H. Warfield
Post by Michael H. Warfield
Post by Serge Hallyn
Post by Michael H. Warfield
Post by Michael H. Warfield
Looks good to me with the provisio that I feel that autoboot on bootup
should be for all groups and not just the null group. Dwight told me in
another message that he did it that way because the Upstart script did
it that way. Was it an oversight or was it a decision? That can be a
separate patch to fix.
I haven't seen Dwight's patch go in and I haven't seen any other
commentary about it or my suggested change. His patch fixes a reported
problem and my change supports allowing containers which are members of
designated groups to boot (which I require). Therefore, I'm submitting
this patch. Both "boot" and "autoboot" were suggested for names of the
autoboot group. I choose to use "onboot" just to make it a little
clearer and disambiguate it from some of the other options.
[PATCH v2] have systemd service call lxc-autostart via script
Regards,
Mike
--
Add a non-null group for autobooting
This adds a non-null group (onboot) to the sysvinit startup script
for autobooting containers. This allows for containers which are
in other groups to be included in the autoboot process.
This script is used by both the sysvinit systems and the systemd
systems.
Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>
While this is the right place to do it, I don't think we should encourage
differences among init systems... So we should either do it in upstart
as well, or not do it at all imo. Otherwise admins will become very
confused.
I absolutely agree but I haven't been involved in that one. I would
strongly recommend that someone update the Upstart stuff. Do you want
me to look at it or do you want someone more familiar with Upstart to
look at it? I'll take a look.
I just had a look in that area and I have no idea what those files are
doing. I gather they're doing an "lxc-autostart -L" and then picking
off the first parameter as a container name to start in "lxc-instance"
and I can see where "order" might be handled by "lxc-autostart -L" in
the output but where is the "delay" parameter managed? The "simple"
thing would be to prepend another loop. I'll submit a patch for that.
Someone should look in more depth at what that's doing wrt the delay
parameter.
We use upstart instances for the containers so they show up in "initctl
list" as separate jobs which can be stopped or restarted.

The upstart job calls lxc-autostart in list mode which will spit out the
order in which the containers would be started, for each of those there
are two columns, the first is the container name, the second is the
delay.

The job then does "(start lxc-instance NAME=$1 && sleep $2) || true"
which will trigger the instance and wait for the delay before moving on.


I haven't looked at the rest of your change yet, but assuming you added
the "empty" value to lxc-autostart as we suggested earlier, it should
just be a matter of replacing "lxc-autostart -L" by "lxc-autostart -L -g
,boot".
Post by Michael H. Warfield
Regards,
Mike
Post by Michael H. Warfield
Post by Serge Hallyn
Post by Michael H. Warfield
---
config/init/sysvinit/lxc.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
index b1a725c..0b802af 100644
--- a/config/init/sysvinit/lxc.in
+++ b/config/init/sysvinit/lxc.in
@@ -64,6 +64,9 @@ case "$1" in
# Start containers
wait_for_bridge
+ # Start autoboot containers first.
+ action $"Starting LXC onboot containers: " /usr/bin/lxc-autostart -g onboot
+ # Start NULL group containers last.
action $"Starting LXC containers: " "$bindir"/lxc-autostart
touch "$localstatedir"/lock/subsys/lxc
;;
--
1.9.0
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140502/d640d4e5/attachment.sig>
Stéphane Graber
2014-05-02 21:41:25 UTC
Permalink
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Michael H. Warfield
Post by Serge Hallyn
Post by Michael H. Warfield
Post by Michael H. Warfield
Looks good to me with the provisio that I feel that autoboot on bootup
should be for all groups and not just the null group. Dwight told me in
another message that he did it that way because the Upstart script did
it that way. Was it an oversight or was it a decision? That can be a
separate patch to fix.
I haven't seen Dwight's patch go in and I haven't seen any other
commentary about it or my suggested change. His patch fixes a reported
problem and my change supports allowing containers which are members of
designated groups to boot (which I require). Therefore, I'm submitting
this patch. Both "boot" and "autoboot" were suggested for names of the
autoboot group. I choose to use "onboot" just to make it a little
clearer and disambiguate it from some of the other options.
[PATCH v2] have systemd service call lxc-autostart via script
Regards,
Mike
--
Add a non-null group for autobooting
This adds a non-null group (onboot) to the sysvinit startup script
for autobooting containers. This allows for containers which are
in other groups to be included in the autoboot process.
This script is used by both the sysvinit systems and the systemd
systems.
Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>
While this is the right place to do it, I don't think we should encourage
differences among init systems... So we should either do it in upstart
as well, or not do it at all imo. Otherwise admins will become very
confused.
I absolutely agree but I haven't been involved in that one. I would
strongly recommend that someone update the Upstart stuff. Do you want
me to look at it or do you want someone more familiar with Upstart to
look at it? I'll take a look.
I just had a look in that area and I have no idea what those files are
doing. I gather they're doing an "lxc-autostart -L" and then picking
off the first parameter as a container name to start in "lxc-instance"
and I can see where "order" might be handled by "lxc-autostart -L" in
the output but where is the "delay" parameter managed? The "simple"
thing would be to prepend another loop. I'll submit a patch for that.
Someone should look in more depth at what that's doing wrt the delay
parameter.
We use upstart instances for the containers so they show up in "initctl
list" as separate jobs which can be stopped or restarted.
The upstart job calls lxc-autostart in list mode which will spit out the
order in which the containers would be started, for each of those there
are two columns, the first is the container name, the second is the
delay.
The job then does "(start lxc-instance NAME=$1 && sleep $2) || true"
which will trigger the instance and wait for the delay before moving on.
I haven't looked at the rest of your change yet, but assuming you added
the "empty" value to lxc-autostart as we suggested earlier, it should
just be a matter of replacing "lxc-autostart -L" by "lxc-autostart -L -g
,boot".
Just went and looked at the submitted patch now (sorry), so yeah, two
loops in the upstart job should do the trick.

onboot seems reasonable as a name, it may be worth documenting it
somewhere though, probably in lxc.container.conf in the lxc.group
section.
Post by Stéphane Graber
Post by Michael H. Warfield
Regards,
Mike
Post by Michael H. Warfield
Post by Serge Hallyn
Post by Michael H. Warfield
---
config/init/sysvinit/lxc.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
index b1a725c..0b802af 100644
--- a/config/init/sysvinit/lxc.in
+++ b/config/init/sysvinit/lxc.in
@@ -64,6 +64,9 @@ case "$1" in
# Start containers
wait_for_bridge
+ # Start autoboot containers first.
+ action $"Starting LXC onboot containers: " /usr/bin/lxc-autostart -g onboot
+ # Start NULL group containers last.
action $"Starting LXC containers: " "$bindir"/lxc-autostart
touch "$localstatedir"/lock/subsys/lxc
;;
--
1.9.0
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140502/c23b0c3b/attachment-0001.sig>
Michael H. Warfield
2014-05-02 21:52:11 UTC
Permalink
Post by Stéphane Graber
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Michael H. Warfield
Post by Serge Hallyn
Post by Michael H. Warfield
Post by Michael H. Warfield
Looks good to me with the provisio that I feel that autoboot on bootup
should be for all groups and not just the null group. Dwight told me in
another message that he did it that way because the Upstart script did
it that way. Was it an oversight or was it a decision? That can be a
separate patch to fix.
I haven't seen Dwight's patch go in and I haven't seen any other
commentary about it or my suggested change. His patch fixes a reported
problem and my change supports allowing containers which are members of
designated groups to boot (which I require). Therefore, I'm submitting
this patch. Both "boot" and "autoboot" were suggested for names of the
autoboot group. I choose to use "onboot" just to make it a little
clearer and disambiguate it from some of the other options.
[PATCH v2] have systemd service call lxc-autostart via script
Regards,
Mike
--
Add a non-null group for autobooting
This adds a non-null group (onboot) to the sysvinit startup script
for autobooting containers. This allows for containers which are
in other groups to be included in the autoboot process.
This script is used by both the sysvinit systems and the systemd
systems.
Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>
While this is the right place to do it, I don't think we should encourage
differences among init systems... So we should either do it in upstart
as well, or not do it at all imo. Otherwise admins will become very
confused.
I absolutely agree but I haven't been involved in that one. I would
strongly recommend that someone update the Upstart stuff. Do you want
me to look at it or do you want someone more familiar with Upstart to
look at it? I'll take a look.
I just had a look in that area and I have no idea what those files are
doing. I gather they're doing an "lxc-autostart -L" and then picking
off the first parameter as a container name to start in "lxc-instance"
and I can see where "order" might be handled by "lxc-autostart -L" in
the output but where is the "delay" parameter managed? The "simple"
thing would be to prepend another loop. I'll submit a patch for that.
Someone should look in more depth at what that's doing wrt the delay
parameter.
We use upstart instances for the containers so they show up in "initctl
list" as separate jobs which can be stopped or restarted.
The upstart job calls lxc-autostart in list mode which will spit out the
order in which the containers would be started, for each of those there
are two columns, the first is the container name, the second is the
delay.
The job then does "(start lxc-instance NAME=$1 && sleep $2) || true"
which will trigger the instance and wait for the delay before moving on.
I haven't looked at the rest of your change yet, but assuming you added
the "empty" value to lxc-autostart as we suggested earlier, it should
just be a matter of replacing "lxc-autostart -L" by "lxc-autostart -L -g
,boot".
Just went and looked at the submitted patch now (sorry), so yeah, two
loops in the upstart job should do the trick.
onboot seems reasonable as a name, it may be worth documenting it
somewhere though, probably in lxc.container.conf in the lxc.group
section.
Absolutely concur. Any "magic cookie" groups (and this is the only one)
should be documented. Hopefully, we can change that in the future with
a configurable option but this buys us some time.

Regards,
Mike
Post by Stéphane Graber
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Michael H. Warfield
Post by Serge Hallyn
Post by Michael H. Warfield
---
config/init/sysvinit/lxc.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
index b1a725c..0b802af 100644
--- a/config/init/sysvinit/lxc.in
+++ b/config/init/sysvinit/lxc.in
@@ -64,6 +64,9 @@ case "$1" in
# Start containers
wait_for_bridge
+ # Start autoboot containers first.
+ action $"Starting LXC onboot containers: " /usr/bin/lxc-autostart -g onboot
+ # Start NULL group containers last.
action $"Starting LXC containers: " "$bindir"/lxc-autostart
touch "$localstatedir"/lock/subsys/lxc
;;
--
1.9.0
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140502/2d3b72ae/attachment.sig>
Michael H. Warfield
2014-05-03 22:17:39 UTC
Permalink
Post by Stéphane Graber
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Michael H. Warfield
Post by Serge Hallyn
Post by Michael H. Warfield
Post by Michael H. Warfield
Looks good to me with the provisio that I feel that autoboot on bootup
should be for all groups and not just the null group. Dwight told me in
another message that he did it that way because the Upstart script did
it that way. Was it an oversight or was it a decision? That can be a
separate patch to fix.
I haven't seen Dwight's patch go in and I haven't seen any other
commentary about it or my suggested change. His patch fixes a reported
problem and my change supports allowing containers which are members of
designated groups to boot (which I require). Therefore, I'm submitting
this patch. Both "boot" and "autoboot" were suggested for names of the
autoboot group. I choose to use "onboot" just to make it a little
clearer and disambiguate it from some of the other options.
[PATCH v2] have systemd service call lxc-autostart via script
Regards,
Mike
--
Add a non-null group for autobooting
This adds a non-null group (onboot) to the sysvinit startup script
for autobooting containers. This allows for containers which are
in other groups to be included in the autoboot process.
This script is used by both the sysvinit systems and the systemd
systems.
Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>
While this is the right place to do it, I don't think we should encourage
differences among init systems... So we should either do it in upstart
as well, or not do it at all imo. Otherwise admins will become very
confused.
I absolutely agree but I haven't been involved in that one. I would
strongly recommend that someone update the Upstart stuff. Do you want
me to look at it or do you want someone more familiar with Upstart to
look at it? I'll take a look.
I just had a look in that area and I have no idea what those files are
doing. I gather they're doing an "lxc-autostart -L" and then picking
off the first parameter as a container name to start in "lxc-instance"
and I can see where "order" might be handled by "lxc-autostart -L" in
the output but where is the "delay" parameter managed? The "simple"
thing would be to prepend another loop. I'll submit a patch for that.
Someone should look in more depth at what that's doing wrt the delay
parameter.
We use upstart instances for the containers so they show up in "initctl
list" as separate jobs which can be stopped or restarted.
The upstart job calls lxc-autostart in list mode which will spit out the
order in which the containers would be started, for each of those there
are two columns, the first is the container name, the second is the
delay.
The job then does "(start lxc-instance NAME=$1 && sleep $2) || true"
which will trigger the instance and wait for the delay before moving on.
I haven't looked at the rest of your change yet, but assuming you added
the "empty" value to lxc-autostart as we suggested earlier, it should
just be a matter of replacing "lxc-autostart -L" by "lxc-autostart -L -g
,boot".
Just went and looked at the submitted patch now (sorry), so yeah, two
loops in the upstart job should do the trick.
onboot seems reasonable as a name, it may be worth documenting it
somewhere though, probably in lxc.container.conf in the lxc.group
section.
Actually, I was thinking in maybe both lxc.container.conf and lxc-start.
Something along these lines...
--
Autostart and System Boot


LXC Autostart is used as part of the LXC system service when enabled to
run at host system bootup and shutdown. It's used to select which
containers to start in what order and how much to delay between each
startup.


Each container can be part of any number of groups or no group at all.
Two groups are special. One is the NULL group, i.e. the container does
not belong to any group. The other group is the "onboot" group.


When the system boots with the LXC service enabled, it will first
attempt to boot any containers with lxc.start.auto == 1 that is a member
of the "onboot" group. The startup will be in order of lxc.start.order.
If an lxc.start.delay has been specified, that delay will be honored
before attempting to start the next container to give the current
container time to begin initialization and reduce overloading the host
system. After starting the members of the "onboot" group, the LXC system
will proceed to boot containers with lxc.start.auto == 1 which are not
members of any group (the NULL group) and proceed as with the onboot
group.
--
Written for lxc-autostart. Rehash appropriately for lxc.container.conf.
Post by Stéphane Graber
Post by Stéphane Graber
Post by Michael H. Warfield
Regards,
Mike
Post by Michael H. Warfield
Post by Serge Hallyn
Post by Michael H. Warfield
---
config/init/sysvinit/lxc.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
index b1a725c..0b802af 100644
--- a/config/init/sysvinit/lxc.in
+++ b/config/init/sysvinit/lxc.in
@@ -64,6 +64,9 @@ case "$1" in
# Start containers
wait_for_bridge
+ # Start autoboot containers first.
+ action $"Starting LXC onboot containers: " /usr/bin/lxc-autostart -g onboot
+ # Start NULL group containers last.
action $"Starting LXC containers: " "$bindir"/lxc-autostart
touch "$localstatedir"/lock/subsys/lxc
;;
--
1.9.0
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140503/dfc45ea6/attachment.sig>
Michael H. Warfield
2014-05-07 21:30:03 UTC
Permalink
This is a part of (now) 4 patches controlling the autoboot process.
Dwight submitted the first patch to change the sysvinit script and the
systemd service to use the sysvinit script during the autoboot process.

Subject: [PATCH v2] have systemd service call lxc-autostart via script

I then submitted 2 patches under:

Subject: [PATCH] Add a non-null group for autobooting

The first patch added the "onboot" group to the sysvinit script and the
second added the same functionality to the Upstart lxc.conf file so our
three major init systems behave coherently.

This now completes the set by adding documentation to the lxc-autostart
and lxc.container.conf man pages documented the boot up behavior and and
the various start options.

All four patches need to be applied in concert.

Regards,
Mike

--
Documentation for Autoboot behaviour.

Added sections to lxc-autostart and lxc.container.config to document
the behavior of the LXC service at host system boot time with regards
to the lxc.group and lxc.start.auto parameters.

Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>
---
doc/lxc-autostart.sgml.in | 30 ++++++++++++++++++++++++++++++
doc/lxc.container.conf.sgml.in | 23 +++++++++++++++++++++++
2 files changed, 53 insertions(+)

diff --git a/doc/lxc-autostart.sgml.in b/doc/lxc-autostart.sgml.in
index 3d423dd..116d7bc 100644
--- a/doc/lxc-autostart.sgml.in
+++ b/doc/lxc-autostart.sgml.in
@@ -185,6 +185,36 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
</variablelist>
</refsect1>

+ <refsect1>
+ <title>Autostart and System Boot</title>
+
+ <para>
+ The <command>lxc-autostart</command> command is used as part of the
+ LXC system service, when enabled to run on host system at bootup and at
+ shutdown. It's used to select which containers to start in what order
+ and how much to delay between each startup when the host system boots.
+ </para>
+
+ <para>
+ Each container can be part of any number of groups or no group at all.
+ Two groups are special. One is the NULL group, i.e. the container does
+ not belong to any group. The other group is the "onboot" group.
+ </para>
+
+ <para>
+ When the system boots with the LXC service enabled, it will first
+ attempt to boot any containers with lxc.start.auto == 1 that is a member
+ of the "onboot" group. The startup will be in order of lxc.start.order.
+ If an lxc.start.delay has been specified, that delay will be honored
+ before attempting to start the next container to give the current
+ container time to begin initialization and reduce overloading the host
+ system. After starting the members of the "onboot" group, the LXC system
+ will proceed to boot containers with lxc.start.auto == 1 which are not
+ members of any group (the NULL group) and proceed as with the onboot
+ group.
+ </para>
+ </refsect1>
+
&seealso;

<refsect1>
diff --git a/doc/lxc.container.conf.sgml.in b/doc/lxc.container.conf.sgml.in
index 6e96889..bbae448 100644
--- a/doc/lxc.container.conf.sgml.in
+++ b/doc/lxc.container.conf.sgml.in
@@ -1464,6 +1464,29 @@ mknod errno 0
</varlistentry>
</variablelist>
</refsect2>
+
+ <refsect2>
+ <title>Autostart and System Boot</title>
+ <para>
+ Each container can be part of any number of groups or no group at all.
+ Two groups are special. One is the NULL group, i.e. the container does
+ not belong to any group. The other group is the "onboot" group.
+ </para>
+
+ <para>
+ When the system boots with the LXC service enabled, it will first
+ attempt to boot any containers with lxc.start.auto == 1 that is a member
+ of the "onboot" group. The startup will be in order of lxc.start.order.
+ If an lxc.start.delay has been specified, that delay will be honored
+ before attempting to start the next container to give the current
+ container time to begin initialization and reduce overloading the host
+ system. After starting the members of the "onboot" group, the LXC system
+ will proceed to boot containers with lxc.start.auto == 1 which are not
+ members of any group (the NULL group) and proceed as with the onboot
+ group.
+ </para>
+
+ </refsect2>
</refsect1>

<refsect1>
--
1.9.0
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140507/00cafb2f/attachment.sig>
Serge Hallyn
2014-05-09 03:22:57 UTC
Permalink
Post by Michael H. Warfield
This is a part of (now) 4 patches controlling the autoboot process.
Dwight submitted the first patch to change the sysvinit script and the
systemd service to use the sysvinit script during the autoboot process.
Subject: [PATCH v2] have systemd service call lxc-autostart via script
Subject: [PATCH] Add a non-null group for autobooting
The first patch added the "onboot" group to the sysvinit script and the
second added the same functionality to the Upstart lxc.conf file so our
three major init systems behave coherently.
This now completes the set by adding documentation to the lxc-autostart
and lxc.container.conf man pages documented the boot up behavior and and
the various start options.
All four patches need to be applied in concert.
Regards,
Mike
--
Documentation for Autoboot behaviour.
Added sections to lxc-autostart and lxc.container.config to document
the behavior of the LXC service at host system boot time with regards
to the lxc.group and lxc.start.auto parameters.
Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>
Thanks Michael, sorry about the delay.

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
Post by Michael H. Warfield
---
doc/lxc-autostart.sgml.in | 30 ++++++++++++++++++++++++++++++
doc/lxc.container.conf.sgml.in | 23 +++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/doc/lxc-autostart.sgml.in b/doc/lxc-autostart.sgml.in
index 3d423dd..116d7bc 100644
--- a/doc/lxc-autostart.sgml.in
+++ b/doc/lxc-autostart.sgml.in
@@ -185,6 +185,36 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
</variablelist>
</refsect1>
+ <refsect1>
+ <title>Autostart and System Boot</title>
+
+ <para>
+ The <command>lxc-autostart</command> command is used as part of the
+ LXC system service, when enabled to run on host system at bootup and at
+ shutdown. It's used to select which containers to start in what order
+ and how much to delay between each startup when the host system boots.
+ </para>
+
+ <para>
+ Each container can be part of any number of groups or no group at all.
+ Two groups are special. One is the NULL group, i.e. the container does
+ not belong to any group. The other group is the "onboot" group.
+ </para>
+
+ <para>
+ When the system boots with the LXC service enabled, it will first
+ attempt to boot any containers with lxc.start.auto == 1 that is a member
+ of the "onboot" group. The startup will be in order of lxc.start.order.
+ If an lxc.start.delay has been specified, that delay will be honored
+ before attempting to start the next container to give the current
+ container time to begin initialization and reduce overloading the host
+ system. After starting the members of the "onboot" group, the LXC system
+ will proceed to boot containers with lxc.start.auto == 1 which are not
+ members of any group (the NULL group) and proceed as with the onboot
+ group.
+ </para>
+ </refsect1>
+
&seealso;
<refsect1>
diff --git a/doc/lxc.container.conf.sgml.in b/doc/lxc.container.conf.sgml.in
index 6e96889..bbae448 100644
--- a/doc/lxc.container.conf.sgml.in
+++ b/doc/lxc.container.conf.sgml.in
@@ -1464,6 +1464,29 @@ mknod errno 0
</varlistentry>
</variablelist>
</refsect2>
+
+ <refsect2>
+ <title>Autostart and System Boot</title>
+ <para>
+ Each container can be part of any number of groups or no group at all.
+ Two groups are special. One is the NULL group, i.e. the container does
+ not belong to any group. The other group is the "onboot" group.
+ </para>
+
+ <para>
+ When the system boots with the LXC service enabled, it will first
+ attempt to boot any containers with lxc.start.auto == 1 that is a member
+ of the "onboot" group. The startup will be in order of lxc.start.order.
+ If an lxc.start.delay has been specified, that delay will be honored
+ before attempting to start the next container to give the current
+ container time to begin initialization and reduce overloading the host
+ system. After starting the members of the "onboot" group, the LXC system
+ will proceed to boot containers with lxc.start.auto == 1 which are not
+ members of any group (the NULL group) and proceed as with the onboot
+ group.
+ </para>
+
+ </refsect2>
</refsect1>
<refsect1>
--
1.9.0
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
Christian Seiler
2014-05-02 21:50:52 UTC
Permalink
Hi,
Post by Stéphane Graber
We use upstart instances for the containers so they show up in "initctl
list" as separate jobs which can be stopped or restarted.
Btw. we could do something similar for the systemd case if we implement
the autostart functionality with a generator (in that case, the generate
could also detect whether we have to wait for the bridge or not for each
container individually, so that containers with for example empty
networking can be started faster) and use transient units for manually
started backgrounded containers.

I'll see if I can hack something together over the weekend.

Regards,
Christian
Michael H. Warfield
2014-05-02 21:55:41 UTC
Permalink
Post by Christian Seiler
Hi,
Post by Stéphane Graber
We use upstart instances for the containers so they show up in "initctl
list" as separate jobs which can be stopped or restarted.
Btw. we could do something similar for the systemd case if we implement
the autostart functionality with a generator (in that case, the generate
could also detect whether we have to wait for the bridge or not for each
container individually, so that containers with for example empty
networking can be started faster) and use transient units for manually
started backgrounded containers.
I've stated before that I really want to avoid the generator case as it
just simply does not have the level of granularity that we can provide.
Right now, calling lxc-autostart with the appropriate parameters does
the right thing.
Post by Christian Seiler
I'll see if I can hack something together over the weekend.
Give it your best shot taking into account order, groups, and delays.
I'll look it over. It has to be congruent with the other init systems.
Post by Christian Seiler
Regards,
Christian
Regards,
Mike
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140502/69959bda/attachment.sig>
Michael H. Warfield
2014-05-03 22:13:02 UTC
Permalink
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Michael H. Warfield
Post by Serge Hallyn
Post by Michael H. Warfield
Post by Michael H. Warfield
Looks good to me with the provisio that I feel that autoboot on bootup
should be for all groups and not just the null group. Dwight told me in
another message that he did it that way because the Upstart script did
it that way. Was it an oversight or was it a decision? That can be a
separate patch to fix.
I haven't seen Dwight's patch go in and I haven't seen any other
commentary about it or my suggested change. His patch fixes a reported
problem and my change supports allowing containers which are members of
designated groups to boot (which I require). Therefore, I'm submitting
this patch. Both "boot" and "autoboot" were suggested for names of the
autoboot group. I choose to use "onboot" just to make it a little
clearer and disambiguate it from some of the other options.
[PATCH v2] have systemd service call lxc-autostart via script
Regards,
Mike
--
Add a non-null group for autobooting
This adds a non-null group (onboot) to the sysvinit startup script
for autobooting containers. This allows for containers which are
in other groups to be included in the autoboot process.
This script is used by both the sysvinit systems and the systemd
systems.
Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>
While this is the right place to do it, I don't think we should encourage
differences among init systems... So we should either do it in upstart
as well, or not do it at all imo. Otherwise admins will become very
confused.
I absolutely agree but I haven't been involved in that one. I would
strongly recommend that someone update the Upstart stuff. Do you want
me to look at it or do you want someone more familiar with Upstart to
look at it? I'll take a look.
I just had a look in that area and I have no idea what those files are
doing. I gather they're doing an "lxc-autostart -L" and then picking
off the first parameter as a container name to start in "lxc-instance"
and I can see where "order" might be handled by "lxc-autostart -L" in
the output but where is the "delay" parameter managed? The "simple"
thing would be to prepend another loop. I'll submit a patch for that.
Someone should look in more depth at what that's doing wrt the delay
parameter.
We use upstart instances for the containers so they show up in "initctl
list" as separate jobs which can be stopped or restarted.
The upstart job calls lxc-autostart in list mode which will spit out the
order in which the containers would be started, for each of those there
are two columns, the first is the container name, the second is the
delay.
The job then does "(start lxc-instance NAME=$1 && sleep $2) || true"
which will trigger the instance and wait for the delay before moving on.
I haven't looked at the rest of your change yet, but assuming you added
the "empty" value to lxc-autostart as we suggested earlier, it should
just be a matter of replacing "lxc-autostart -L" by "lxc-autostart -L -g
,boot".
I agree. I've been looking at the lxc-autostart code but I'm aways off
from doing that. That change will not be incompatible with doing it in
two calls or two loops now. It'll just make it easier for adding a boot
group list down the road.

Regards,
Mike
Post by Stéphane Graber
Post by Michael H. Warfield
Post by Michael H. Warfield
Post by Serge Hallyn
Post by Michael H. Warfield
---
config/init/sysvinit/lxc.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/config/init/sysvinit/lxc.in b/config/init/sysvinit/lxc.in
index b1a725c..0b802af 100644
--- a/config/init/sysvinit/lxc.in
+++ b/config/init/sysvinit/lxc.in
@@ -64,6 +64,9 @@ case "$1" in
# Start containers
wait_for_bridge
+ # Start autoboot containers first.
+ action $"Starting LXC onboot containers: " /usr/bin/lxc-autostart -g onboot
+ # Start NULL group containers last.
action $"Starting LXC containers: " "$bindir"/lxc-autostart
touch "$localstatedir"/lock/subsys/lxc
;;
--
1.9.0
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
_______________________________________________
lxc-devel mailing list
lxc-devel at lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140503/cf815607/attachment.sig>
Serge Hallyn
2014-05-02 21:27:38 UTC
Permalink
Post by Michael H. Warfield
Post by Serge Hallyn
Post by Michael H. Warfield
Post by Michael H. Warfield
Looks good to me with the provisio that I feel that autoboot on bootup
should be for all groups and not just the null group. Dwight told me in
another message that he did it that way because the Upstart script did
it that way. Was it an oversight or was it a decision? That can be a
separate patch to fix.
I haven't seen Dwight's patch go in and I haven't seen any other
commentary about it or my suggested change. His patch fixes a reported
problem and my change supports allowing containers which are members of
designated groups to boot (which I require). Therefore, I'm submitting
this patch. Both "boot" and "autoboot" were suggested for names of the
autoboot group. I choose to use "onboot" just to make it a little
clearer and disambiguate it from some of the other options.
[PATCH v2] have systemd service call lxc-autostart via script
Regards,
Mike
--
Add a non-null group for autobooting
This adds a non-null group (onboot) to the sysvinit startup script
for autobooting containers. This allows for containers which are
in other groups to be included in the autoboot process.
This script is used by both the sysvinit systems and the systemd
systems.
Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>
Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
Post by Michael H. Warfield
Post by Serge Hallyn
While this is the right place to do it, I don't think we should encourage
differences among init systems... So we should either do it in upstart
as well, or not do it at all imo. Otherwise admins will become very
confused.
I absolutely agree but I haven't been involved in that one. I would
strongly recommend that someone update the Upstart stuff. Do you want
Agreed. Anyway your patch looks ok to me, but let's just wait and see
what Stéphane thinks... if he's happy with it then he or I can do the
usptart bit.

thanks,
-serge
Michael H. Warfield
2014-05-02 21:35:29 UTC
Permalink
Post by Serge Hallyn
Post by Michael H. Warfield
Post by Serge Hallyn
Post by Michael H. Warfield
Post by Michael H. Warfield
Looks good to me with the provisio that I feel that autoboot on bootup
should be for all groups and not just the null group. Dwight told me in
another message that he did it that way because the Upstart script did
it that way. Was it an oversight or was it a decision? That can be a
separate patch to fix.
I haven't seen Dwight's patch go in and I haven't seen any other
commentary about it or my suggested change. His patch fixes a reported
problem and my change supports allowing containers which are members of
designated groups to boot (which I require). Therefore, I'm submitting
this patch. Both "boot" and "autoboot" were suggested for names of the
autoboot group. I choose to use "onboot" just to make it a little
clearer and disambiguate it from some of the other options.
[PATCH v2] have systemd service call lxc-autostart via script
Regards,
Mike
--
Add a non-null group for autobooting
This adds a non-null group (onboot) to the sysvinit startup script
for autobooting containers. This allows for containers which are
in other groups to be included in the autoboot process.
This script is used by both the sysvinit systems and the systemd
systems.
Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>
Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
Post by Michael H. Warfield
Post by Serge Hallyn
While this is the right place to do it, I don't think we should encourage
differences among init systems... So we should either do it in upstart
as well, or not do it at all imo. Otherwise admins will become very
confused.
I absolutely agree but I haven't been involved in that one. I would
strongly recommend that someone update the Upstart stuff. Do you want
Agreed. Anyway your patch looks ok to me, but let's just wait and see
what Stéphane thinks... if he's happy with it then he or I can do the
usptart bit.
Food for thought, I threw together a patch. Take it or pitch it. WAG.
Post by Serge Hallyn
thanks,
-serge
Regards,
Mike
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140502/4ab0ab8a/attachment.sig>
Loading...