[lxc-devel] [PATCH 2/2] Support files for systemd on Fedora.
Serge Hallyn
serge.hallyn at ubuntu.com
Thu Nov 21 17:04:46 UTC 2013
Thanks, Michael. I'll go ahead and apply the patch.
-serge
Quoting Michael H. Warfield (mhw at WittsEnd.com):
> On Wed, 2013-11-20 at 23:12 -0500, Michael H. Warfield wrote:
> > On Wed, 2013-11-20 at 21:39 -0600, Serge Hallyn wrote:
> > > Quoting Michael H. Warfield (mhw at WittsEnd.com):
> > > > Added a file "lxc.service" for a systemd service file.
> > > >
> > > > Added a file "lxc-devsetup" to setup /dev/ on startup to support autodev
> > > > in containers.
> > > >
> > > > Service file references lxc-devsetup as an ExecStartPre command. The
> > > > lxc-devsetup script is not dependent on systemd or Fedora and can
> > > > be used at bootup on any system.
> > > >
> > > > Modified lxc.spec.in to install the two new files on Fedora. The systemd
> > > > specific code in the lxc.spec file may need some review and conditionalize
> > > > for systemd on non-systemd rpm-based systems.
> >
> > > Will systemd care that the lxc-startup specified in ExecStart and
> > > ExecStop doesn't exist?
>
> > Not that I know of. And if it does, it's easy enough to stub off. But
> > that would be good to test.
>
> Let me qualify that a little bit. I realized my first answer was a bit
> short.
>
> If the ExecStart command does not exist, systemd will complain that the
> service failed if you try and start the service. But, the service is
> not "enabled" but default and, even if it was, has no fatal impact on
> the over all systemd operation. The logs will inform the user the
> startup command doesn't exist. No harm no foul and no negative impact.
>
> So, if this is installed, as is, on a target system, it has no impact at
> ll on anything until one of the two commands are run...
>
> systemctl start lxc.service
>
> and/or
>
> systemctl enable lxc.service
>
> In the case of the former, it will say the service failed and that the
> ExecStart command does not exist. No harm done and it informs the admin
> where he need to plug in his startup script.
>
> In the case of the later, rebooting the system will attempt to start
> lxc.service at boot time and fail but the failure will be informative
> and will not disrupt the boot process. Recurse back to case 1.
>
> Both of these cases are where I want to be right now. Once Stéphane has
> his pieces ready, we can glue them together with that ExecStart shim.
> ITMT, it gives us the framework on Fedora for setting up systemd and lxc
> to cooperate and others (such as myself) can use their own ExecStart
> scripts until these other pieces are ready.
>
> Regards,
> Mike
>
> > > > ---
> > > > lxc.spec.in | 8 ++++++++
> > > > src/lxc/lxc-devsetup | 26 ++++++++++++++++++++++++++
> > > > src/lxc/lxc.service | 18 ++++++++++++++++++
> > > > 3 files changed, 52 insertions(+)
> > > > create mode 100755 src/lxc/lxc-devsetup
> > > > create mode 100644 src/lxc/lxc.service
> > > >
> > > > diff --git a/lxc.spec.in b/lxc.spec.in
> > > > index a6c96a2..3ef5881 100644
> > > > --- a/lxc.spec.in
> > > > +++ b/lxc.spec.in
> > > > @@ -102,6 +102,11 @@ rm -rf %{buildroot}
> > > > make install DESTDIR=%{buildroot}
> > > > find %{buildroot} -type f -name '*.la' -exec rm -f {} ';'
> > > >
> > > > +# Install some of our systemd stuff...
> > > > +install -d -m 755 %{buildroot}/lib/systemd/system
> > > > +install -c -m 644 src/lxc/lxc.service %{buildroot}/lib/systemd/system
> > > > +install -c -m 755 src/lxc/lxc-devsetup %{buildroot}/%{_libexecdir}/%{name}
> > > > +
> > > > %clean
> > > > rm -rf %{buildroot}
> > > >
> > > > @@ -131,6 +136,8 @@ rm -rf %{buildroot}
> > > > %{_datadir}/lxc/*
> > > > %config(noreplace) %{_sysconfdir}/lxc/*
> > > >
> > > > +/lib/systemd/system/*
> > > > +
> > > > %files libs
> > > > %defattr(-,root,root)
> > > > %{_libdir}/*.so.*
> > > > @@ -140,6 +147,7 @@ rm -rf %{buildroot}
> > > > %endif
> > > > %{_localstatedir}/*
> > > > %attr(4555,root,root) %{_libexecdir}/%{name}/lxc-init
> > > > +%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
> > > >
> > > > %if %{with_lua}
> > > > %files lua
> > > > diff --git a/src/lxc/lxc-devsetup b/src/lxc/lxc-devsetup
> > > > new file mode 100755
> > > > index 0000000..583a001
> > > > --- /dev/null
> > > > +++ b/src/lxc/lxc-devsetup
> > > > @@ -0,0 +1,26 @@
> > > > +#!/bin/sh -
> > > > +
> > > > +# lxc.devsetup - Setup host /dev for container /dev subdirectories.
> > > > +
> > > > +if [[ ! -d /dev/.lxc ]]
> > > > +then
> > > > + echo "Creating /dev/.lxc"
> > > > + mkdir /dev/.lxc
> > > > + chmod 755 /dev/.lxc
> > > > +fi
> > > > +
> > > > +if grep -q "/dev devtmpfs " /proc/self/mounts
> > > > +then
> > > > + echo "/dev is devtmpfs"
> > > > +else
> > > > + echo "/dev is not devtmpfs - mounting tmpfs on .lxc"
> > > > + mount -t tmpfs tmpfs /dev/.lxc
> > > > +fi
> > > > +
> > > > +if [[ ! -d /dev/.lxc/user ]]
> > > > +then
> > > > + echo "Creating /dev/.lxc/user"
> > > > + mkdir /dev/.lxc/user
> > > > + chmod 1777 /dev/.lxc/user
> > > > +fi
> > > > +
> > > > diff --git a/src/lxc/lxc.service b/src/lxc/lxc.service
> > > > new file mode 100644
> > > > index 0000000..d3d3238
> > > > --- /dev/null
> > > > +++ b/src/lxc/lxc.service
> > > > @@ -0,0 +1,18 @@
> > > > +[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
> > > > +
> > > > --
> > > > 1.8.3.1
> > > >
> > > >
> > > > --
> > > > 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!
> > > >
> > >
> > >
> > >
> > > > ------------------------------------------------------------------------------
> > > > November Webinars for C, C++, Fortran Developers
> > > > Accelerate application performance with scalable programming models. Explore
> > > > techniques for threading, error checking, porting, and tuning. Get the most
> > > > from the latest Intel processors and coprocessors. See abstracts and register
> > > > http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
> > >
> > > > _______________________________________________
> > > > Lxc-devel mailing list
> > > > Lxc-devel at lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/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!
>
More information about the lxc-devel
mailing list