[lxc-devel] [PATCH 3/6] Add systemd unit for lxc.net

Serge Hallyn serge.hallyn at ubuntu.com
Thu Jul 31 17:53:32 UTC 2014


Quoting Martin Pitt (martin.pitt at ubuntu.com):
> This is the equivalent of the upstart lxc-net.conf to set up the LXC bridge.
> 
> This also drops "lxc.service" from tarballs. It is built source which depends
> on configure options, so the statically shipped file will not work on most
> systems.
> 
> https://launchpad.net/bugs/1312532
> ---

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

>  .gitignore                             |  1 +
>  config/init/systemd/Makefile.am        | 11 +++++++----
>  config/init/systemd/lxc-net.service.in | 10 ++++++++++
>  config/init/systemd/lxc.service.in     |  1 +
>  configure.ac                           |  1 +
>  5 files changed, 20 insertions(+), 4 deletions(-)
>  create mode 100644 config/init/systemd/lxc-net.service.in
> 
> diff --git a/.gitignore b/.gitignore
> index 26011e4..e6de18f 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -114,6 +114,7 @@ config/lt*.m4
>  config/bash/lxc
>  config/init/systemd/lxc-autostart-helper
>  config/init/systemd/lxc.service
> +config/init/systemd/lxc-net.service
>  config/init/sysvinit/lxc
>  
>  doc/*.1
> diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
> index 3bd221f..ed1e4ef 100644
> --- a/config/init/systemd/Makefile.am
> +++ b/config/init/systemd/Makefile.am
> @@ -1,6 +1,8 @@
>  EXTRA_DIST = \
>  	lxc-devsetup \
> -	lxc.service
> +	lxc.service.in \
> +	lxc-net.service.in \
> +	$(NULL)
>  
>  if INIT_SCRIPT_SYSTEMD
>  lxc-autostart-helper: ../sysvinit/lxc.in $(top_builddir)/config.status
> @@ -11,14 +13,15 @@ lxc-autostart-helper: ../sysvinit/lxc.in $(top_builddir)/config.status
>  	    < $< > $@-t &&                                      \
>  	    chmod a+x $@-t &&                                   \
>  	    mv $@-t $@
> -BUILT_SOURCES = lxc-autostart-helper
> +BUILT_SOURCES = lxc-autostart-helper lxc.service lxc-net.service
>  
> -install-systemd: lxc.service lxc-devsetup lxc-autostart-helper
> +install-systemd: lxc.service lxc-net.service lxc-devsetup lxc-autostart-helper
>  	$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
> -	$(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
> +	$(INSTALL_DATA) lxc.service lxc-net.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
>  
>  uninstall-systemd:
>  	rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
> +	rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc-net.service
>  	rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) || :
>  
>  pkglibexec_SCRIPTS = lxc-devsetup lxc-autostart-helper
> diff --git a/config/init/systemd/lxc-net.service.in b/config/init/systemd/lxc-net.service.in
> new file mode 100644
> index 0000000..37d1d69
> --- /dev/null
> +++ b/config/init/systemd/lxc-net.service.in
> @@ -0,0 +1,10 @@
> +[Unit]
> +Description=LXC network bridge setup
> +After=network.target
> +Before=lxc.service
> +
> +[Service]
> +Type=oneshot
> +RemainAfterExit=yes
> +ExecStart=@DATADIR@/lxc/lxc.net start
> +ExecStop=@DATADIR@/lxc/lxc.net stop
> diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
> index 0a428a3..c7f2813 100644
> --- a/config/init/systemd/lxc.service.in
> +++ b/config/init/systemd/lxc.service.in
> @@ -1,6 +1,7 @@
>  [Unit]
>  Description=LXC Container Initialization and Autoboot Code
>  After=syslog.target network.target
> +Wants=lxc-net.service
>  
>  [Service]
>  Type=oneshot
> diff --git a/configure.ac b/configure.ac
> index ded4c48..c0d7015 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -613,6 +613,7 @@ AC_CONFIG_FILES([
>  	config/init/sysvinit/lxc
>  	config/init/systemd/Makefile
>  	config/init/systemd/lxc.service
> +	config/init/systemd/lxc-net.service
>  	config/init/upstart/Makefile
>  	config/etc/Makefile
>  	config/templates/Makefile
> -- 
> 2.0.1
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list