[lxc-devel] [PATCH] fix systemd lxc-net vs lxc ordering

Serge Hallyn serge.hallyn at ubuntu.com
Mon Jun 29 16:40:32 UTC 2015


The lxc init job must not start until lxc networking has been
setup.  This requires lxc-net to have complete, not just
started.  To that end,

1. lxc-net now does its work in ExecPreStart rather than
ExecStart

2. lxc now specifies lxc-net in After, not Wants.  So if lxc-net
fails, lxc won't start and try to autostart containers.  (If you
want lxc-net to do nothing, setting USE_LXC_BRIDGE="false" in
/etc/default/lxc is the way to do that, but lxc-net should still
run successfully.)

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 config/init/systemd/lxc-net.service.in | 2 +-
 config/init/systemd/lxc.service.in     | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/config/init/systemd/lxc-net.service.in b/config/init/systemd/lxc-net.service.in
index 0467c0f..1e3681a 100644
--- a/config/init/systemd/lxc-net.service.in
+++ b/config/init/systemd/lxc-net.service.in
@@ -6,7 +6,7 @@ Before=lxc.service
 [Service]
 Type=oneshot
 RemainAfterExit=yes
-ExecStart=@LIBEXECDIR@/lxc/lxc-net start
+ExecStartPre=@LIBEXECDIR@/lxc/lxc-net start
 ExecStop=@LIBEXECDIR@/lxc/lxc-net stop
 
 [Install]
diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
index a256141..7d191dc 100644
--- a/config/init/systemd/lxc.service.in
+++ b/config/init/systemd/lxc.service.in
@@ -1,7 +1,6 @@
 [Unit]
 Description=LXC Container Initialization and Autoboot Code
-After=syslog.target network.target
-Wants=lxc-net.service
+After=syslog.target network.target lxc-net.service
 
 [Service]
 Type=oneshot
-- 
2.1.4



More information about the lxc-devel mailing list