[lxc-devel] [PATCH 1/1] lxc/conf.c Heuristic determination of autodev condition...

Christian Seiler christian at iwakd.de
Thu Oct 3 22:30:32 UTC 2013


Hi there,

> The initial heuristic, in this case, is the existence
> of /etc/systemd/system in the container to enable autodev.  This is 
> the
> heuristic used in the lxc-fedora template but it applicable to all
> systemd containers, as far as I can determine.

Just a quick note about the specific implementation (I don't
have an opinion on the merits of having such a heuristic):
I think that checking for /etc/systemd/system is not necessarily
a good idea to detect systemd. The reason is that for example
Debian Wheezy (and older SuSE versions and probably lots of other
things out there) can have that directory, while still using
sysvinit. The reason is that since the distribution allows for
switching between systemd and sysvinit (and in Debian's case
also upstart), some packages come with files for all of the
different init systems. And while unit files in general are
located in /lib/systemd and not /etc/systemd, the symlinks for
aliases are actually created in /etc (at least for Debian). So
this will use autodev not only for systemd-based distros, but
also for Debian. (Which probably wouldn't be much of a problem
I guess, but it defeats the purpose of your heuristic.)

I think a better heuristic would be (very pseudo-y code):

if autodev < 0
   if readlink("/sbin/init") contains "systemd"
        goto possibly_autodev
   else if lxc-start command cotains "systemd"
        goto possibly_autodev
   else
        autodev = off
        goto end
   end if

   possibly_autodev:
        if lxc.mount / lxc.mount.entry contain an entry for
        /dev
             autodev = off
        else
             autodev = on
        end if

   end:
end if

(Btw. do I see correctly that there is currently no
configuration option, to specify the default command for
lxc-start? I think that whould be neat if such a thing
existed.)

-- Christian





More information about the lxc-devel mailing list