[lxc-devel] [PATCH 5/5] Add distro config file /etc/lxc/lxc.conf

Dwight Engen dwight.engen at oracle.com
Wed Oct 17 17:19:21 UTC 2012


On Mon, 15 Oct 2012 14:49:26 -0500
Serge Hallyn <serge.hallyn at canonical.com> wrote:

> Quoting Dwight Engen (dwight.engen at oracle.com):
> > On Mon, 15 Oct 2012 12:42:57 -0500
> > Serge Hallyn <serge.hallyn at canonical.com> wrote:
> > 
> > > Quoting Dwight Engen (dwight.engen at oracle.com):
> > > > This allows a distro to put the distro specific default network
> > > > configuration (for example bridge device, link type), or other
> > > > lxc configuration in the case that -f is not passed by the user
> > > > to lxc-create, in which case lxc-create will use the distro
> > > > conf file as the basis for the containers config.
> > > 
> > > I think this is great.  Note though that debian does not have an
> > > lxcbr0, only Ubuntu does.
> > 
> > Ahh, so what should we use for distro detection? I went looking a
> > bit and systemd's configure.ac looks for an /etc/os-release but I
> > didn't find that on any distro I looked at except fedora 17, so I
> > don't think that will work for older distros. I guess we could use
> > lsb_release --id?
> 
> That would work.  Or since /etc/lsb-release on an ubuntu system will
> contain DISTRIB_ID=Ubuntu you can just do
> 
> [ -f /etc/lsb-release ] && grep -q DISTRIB_ID=Ubuntu /etc/lsb-release
> && osname=ubuntu || true

So what I did was look and see how other packages were detecting
the distribution, and I copied from what NetworkManager did. Renamed
lxc.conf.debian to lxc.conf.ubuntu. Note that HAVE_DEBIAN gets set for
both debian and ubuntu so the python stuff ends up in the right place.
Updated patch follows.
 
> > > This is getting "out there", but I wonder if, for the unknown os
> > > case, it would be reliable to look at the default nic, and check
> > > if it is a bridge, and use that bridge if so.
> > 
> > By "default nic" do you mean do something like `brctl show` and use
> > the first bridge name found?
> 
> Offhand I was thinking look at the device for 0.0.0.0 route in route
> -n output (or probably better '^default' in 'ip route' output), then
> check if it is on a bridge.  Not sure if there is a better way.
> 
> Anyway since distros can override this the empty default is fine.
> This would be cool, but might be fragile.  In my own case my default
> nic often changes anyway.

I decided not to try this right now :)




More information about the lxc-devel mailing list