[lxc-devel] [PATCH] Improve check for systemd in the template for Fedora

Michael H. Warfield mhw at WittsEnd.com
Wed Aug 14 01:29:42 UTC 2013


Woa!  Hold!  Time out.  Do not do this.

On Tue, 2013-08-13 at 16:36 +0900, Satoshi Matsumoto wrote: 
> Configure the guest init based on whether the PID 1 process is systemd
> or not.

> In the template for Fedora, currently the guest is configured based on
> whether the /bin/systemd exists in the host or not.

No...  It should be based on if systemd exists in the guest or not.  If
not, I (we) have a bug.  I thought that was under a chroot.  If not, I
will check it and fix it.

> This doesn't work
> correctly because the /usr/bin/systemd symlink has been removed from the
> systemd package in Fedora 20 (Rawhide) and Arch Linux.

Oh great...  More headaches and pains due to the abomination and debacle
of moving everything out of /bin /lib /sbin and into /usr/{*}.  Few
things have been thought out less and had wider repercussions...

Ok...  I agree we have to do something better but you can not do this.

You are trying to check if systemd is running in the host in determining
if you should configure systemd in the guest.  This is wrong.  What if
this is being run on an Ubuntu (or Arch or CentOS or other) host for a
Fedora guest?  It will not work.  Systemd will not be running in the
host but the guest must be configured properly for systemd.  The
template should be as distro agnostic as possible (none of them are but
it's a goal).

> Signed-off-by: Satoshi Matsumoto <kaorimatz at gmail.com>
> ---
> I've proposed this patch as a pull request on the github [1], and got a
> comment that the original code may not make sense. In
> configure_fedora_systemd() and configure_fedora_init(), we are
> configuring the guest init not the host init, so it seems to be correct
> to configure the guest init based on whether the guest is based on
> systemd or not. In that case, I think the code should look like this:

But the guest is not running.  Doing the test based on what the init (1)
process is running is wrong because that's the host, not the guest.  You
can not do that.  You have to configure what the guest will be using.
What you're proposing will work in a homogeneous environment but has a
high probability of failing disasterously in a heterogenous environment.

We can have a discussion about how to adapt this to Fedora 20 (will the
random acts of terrorism yet end???).

> if [ $release -gt 14 ]; then
>   configure_fedora_systemd
> else
>   configure_fedora_init
> fi

That much is correct.  It's the release version of the guest.

> [1] https://github.com/lxc/lxc/pull/29

>  templates/lxc-fedora.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

> diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in
> index 23728c6..36c3d21 100644
> --- a/templates/lxc-fedora.in
> +++ b/templates/lxc-fedora.in
> @@ -567,7 +567,7 @@ if [ $? -ne 0 ]; then
>      exit 1
>  fi

> -type /bin/systemd >/dev/null 2>&1


Crap.  That's wrong.  That will have to be fixed but not the way you
propose.  Thank you for finding that.

> +test $(ps --no-headers -o comm 1) = 'systemd'

That's the host systemd.  That's not what may be running in the guest.

>  if [ $? -ne 0 ]; then
>      configure_fedora_init

This is configuring the guest.  Non-sequitaur.  It does not follow that
one follows the other.

>  else
> -- 
> 1.8.3.1

Regards,
Mike
-- 
Michael H. Warfield (AI4NB) | (770) 985-6132 |  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/20130813/99a170c1/attachment.pgp>


More information about the lxc-devel mailing list