Re: [ptxdist] [PATCH v3] lxc: add new package
On Thu, Aug 30, 2018 at 04:10:35PM +0200, Michael Olbrich wrote: > On Thu, Aug 30, 2018 at 09:35:50AM +0200, Michael Grzeschik wrote: > > This patch adds support for the lxc container system. We install the > > userspace lib and application. > > > > To make sure all necessary kernel options are enabled use: > > $ CONFIG=/path/to/kernelconfig lxc-checkconfig > > > > Signed-off-by: Michael Grzeschik > > --- > > v1 -> v2: - prefixed used variables with PTXCONF_ : > > LXC_TEMPLATES, LXC_HOOKS, LXC_SELINUX > > - fixed used variable LXC_SYSTEMD_UNIT > > - added missing dir /usr/lib/lxc/rootfs > > - added dependency to busybox tools when using templates > > - added dependency to iptables when starting systemd.service > > - removed some extra commented unused options > > - removed hooks > > - only installing busybox template > > - added dependency to busybox_umount > > > > v2 -> v3: - removed the busybox template and its dependencies > > - added patch for dnsmasq to start without dns support > > - added install stage to include getent from toolchain > > > > ...te-new-lxcbr0-subnet-at-startup-time.patch | 134 +++ > > ...-net-start-dnsmasq-without-dnsserver.patch | 24 ++ > > patches/lxc-3.0.1/series | 2 + > > projectroot/etc/default/lxc-net | 7 + > > projectroot/etc/lxc/default.conf | 4 + > > rules/lxc.in | 61 + > > rules/lxc.make| 211 ++ > > 7 files changed, 443 insertions(+) > > create mode 100644 > > patches/lxc-3.0.1/0001-Allocate-new-lxcbr0-subnet-at-startup-time.patch > > create mode 100644 > > patches/lxc-3.0.1/0002-lxc-net-start-dnsmasq-without-dnsserver.patch > > create mode 100644 patches/lxc-3.0.1/series > > create mode 100644 projectroot/etc/default/lxc-net > > create mode 100644 projectroot/etc/lxc/default.conf > > create mode 100644 rules/lxc.in > > create mode 100644 rules/lxc.make > > > > diff --git > > a/patches/lxc-3.0.1/0001-Allocate-new-lxcbr0-subnet-at-startup-time.patch > > b/patches/lxc-3.0.1/0001-Allocate-new-lxcbr0-subnet-at-startup-time.patch > > new file mode 100644 > > index 0..a1fddbea4 > > --- /dev/null > > +++ > > b/patches/lxc-3.0.1/0001-Allocate-new-lxcbr0-subnet-at-startup-time.patch > > @@ -0,0 +1,134 @@ > > +From: =?UTF-8?q?St=C3=A9phane=20Graber?= > > +Date: Tue, 3 Nov 2015 11:42:58 -0500 > > +Subject: [PATCH] Allocate new lxcbr0 subnet at startup time > > + > > +--- > > + config/init/common/lxc-net.in | 100 > > ++ > > + 1 file changed, 91 insertions(+), 9 deletions(-) > > + > > +diff --git a/config/init/common/lxc-net.in b/config/init/common/lxc-net.in > > +index df9f1181d761..6837be1969c2 100644 > > +--- a/config/init/common/lxc-net.in > > b/config/init/common/lxc-net.in > > +@@ -24,6 +24,85 @@ LXC_IPV6_MASK="" > > + LXC_IPV6_NETWORK="" > > + LXC_IPV6_NAT="false" > > + > > ++write_lxc_net() > > ++{ > > ++local i=$1 > > ++cat >> $distrosysconfdir/lxc-net << EOF > > ++# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your > > ++# containers. Set to "false" if you'll use virbr0 or another existing > > ++# bridge, or mavlan to your host's NIC. > > ++USE_LXC_BRIDGE="true" > > ++ > > ++# If you change the LXC_BRIDGE to something other than lxcbr0, then > > ++# you will also need to update your /etc/lxc/default.conf as well as the > > ++# configuration (/var/lib/lxc//config) for any containers > > ++# already created using the default config to reflect the new bridge > > ++# name. > > ++# If you have the dnsmasq daemon installed, you'll also have to update > > ++# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon. > > ++LXC_BRIDGE="lxcbr0" > > ++LXC_ADDR="10.0.$i.1" > > ++LXC_NETMASK="255.255.255.0" > > ++LXC_NETWORK="10.0.$i.0/24" > > ++LXC_DHCP_RANGE="10.0.$i.2,10.0.$i.254" > > ++LXC_DHCP_MAX="253" > > ++# Uncomment the next line if you'd like to use a conf-file for the lxcbr0 > > ++# dnsmasq. For instance, you can use 'dhcp-host=mail1,10.0.3.100' to have > > ++# container 'mail1' always get ip address 10.0.3.100. > > ++#LXC_DHCP_CONFILE=/etc/lxc/dnsmasq.conf > > ++ > > ++# Uncomment the next line if you want lxcbr0's dnsmasq to resolve the .lxc > > ++# domain. You can then add "server=/lxc/10.0.$i.1' (or your actual > > \$LXC_ADDR) > > ++# to your system dnsmasq configuration file (normally /etc/dnsmasq.conf, > > ++# or /etc/NetworkManager/dnsmasq.d/lxc.conf on systems that use > > NetworkManager). > > ++# Once these changes are made, restart the lxc-net and network-manager > > services. > > ++# 'container1.lxc' will then resolve on your host. > > ++#LXC_DOMAIN="lxc" > > ++EOF > > ++} > > ++ > > ++configure_lxcbr0() > > ++{ > > ++local i=3 > > ++cat > $distrosysconfdir/lxc-net << EOF > > ++# This
Re: [ptxdist] [PATCH v3] lxc: add new package
On Thu, Aug 30, 2018 at 09:35:50AM +0200, Michael Grzeschik wrote: > This patch adds support for the lxc container system. We install the > userspace lib and application. > > To make sure all necessary kernel options are enabled use: > $ CONFIG=/path/to/kernelconfig lxc-checkconfig > > Signed-off-by: Michael Grzeschik > --- > v1 -> v2: - prefixed used variables with PTXCONF_ : > LXC_TEMPLATES, LXC_HOOKS, LXC_SELINUX > - fixed used variable LXC_SYSTEMD_UNIT > - added missing dir /usr/lib/lxc/rootfs > - added dependency to busybox tools when using templates > - added dependency to iptables when starting systemd.service > - removed some extra commented unused options > - removed hooks > - only installing busybox template > - added dependency to busybox_umount > > v2 -> v3: - removed the busybox template and its dependencies > - added patch for dnsmasq to start without dns support > - added install stage to include getent from toolchain > > ...te-new-lxcbr0-subnet-at-startup-time.patch | 134 +++ > ...-net-start-dnsmasq-without-dnsserver.patch | 24 ++ > patches/lxc-3.0.1/series | 2 + > projectroot/etc/default/lxc-net | 7 + > projectroot/etc/lxc/default.conf | 4 + > rules/lxc.in | 61 + > rules/lxc.make| 211 ++ > 7 files changed, 443 insertions(+) > create mode 100644 > patches/lxc-3.0.1/0001-Allocate-new-lxcbr0-subnet-at-startup-time.patch > create mode 100644 > patches/lxc-3.0.1/0002-lxc-net-start-dnsmasq-without-dnsserver.patch > create mode 100644 patches/lxc-3.0.1/series > create mode 100644 projectroot/etc/default/lxc-net > create mode 100644 projectroot/etc/lxc/default.conf > create mode 100644 rules/lxc.in > create mode 100644 rules/lxc.make > > diff --git > a/patches/lxc-3.0.1/0001-Allocate-new-lxcbr0-subnet-at-startup-time.patch > b/patches/lxc-3.0.1/0001-Allocate-new-lxcbr0-subnet-at-startup-time.patch > new file mode 100644 > index 0..a1fddbea4 > --- /dev/null > +++ b/patches/lxc-3.0.1/0001-Allocate-new-lxcbr0-subnet-at-startup-time.patch > @@ -0,0 +1,134 @@ > +From: =?UTF-8?q?St=C3=A9phane=20Graber?= > +Date: Tue, 3 Nov 2015 11:42:58 -0500 > +Subject: [PATCH] Allocate new lxcbr0 subnet at startup time > + > +--- > + config/init/common/lxc-net.in | 100 > ++ > + 1 file changed, 91 insertions(+), 9 deletions(-) > + > +diff --git a/config/init/common/lxc-net.in b/config/init/common/lxc-net.in > +index df9f1181d761..6837be1969c2 100644 > +--- a/config/init/common/lxc-net.in > b/config/init/common/lxc-net.in > +@@ -24,6 +24,85 @@ LXC_IPV6_MASK="" > + LXC_IPV6_NETWORK="" > + LXC_IPV6_NAT="false" > + > ++write_lxc_net() > ++{ > ++local i=$1 > ++cat >> $distrosysconfdir/lxc-net << EOF > ++# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your > ++# containers. Set to "false" if you'll use virbr0 or another existing > ++# bridge, or mavlan to your host's NIC. > ++USE_LXC_BRIDGE="true" > ++ > ++# If you change the LXC_BRIDGE to something other than lxcbr0, then > ++# you will also need to update your /etc/lxc/default.conf as well as the > ++# configuration (/var/lib/lxc//config) for any containers > ++# already created using the default config to reflect the new bridge > ++# name. > ++# If you have the dnsmasq daemon installed, you'll also have to update > ++# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon. > ++LXC_BRIDGE="lxcbr0" > ++LXC_ADDR="10.0.$i.1" > ++LXC_NETMASK="255.255.255.0" > ++LXC_NETWORK="10.0.$i.0/24" > ++LXC_DHCP_RANGE="10.0.$i.2,10.0.$i.254" > ++LXC_DHCP_MAX="253" > ++# Uncomment the next line if you'd like to use a conf-file for the lxcbr0 > ++# dnsmasq. For instance, you can use 'dhcp-host=mail1,10.0.3.100' to have > ++# container 'mail1' always get ip address 10.0.3.100. > ++#LXC_DHCP_CONFILE=/etc/lxc/dnsmasq.conf > ++ > ++# Uncomment the next line if you want lxcbr0's dnsmasq to resolve the .lxc > ++# domain. You can then add "server=/lxc/10.0.$i.1' (or your actual > \$LXC_ADDR) > ++# to your system dnsmasq configuration file (normally /etc/dnsmasq.conf, > ++# or /etc/NetworkManager/dnsmasq.d/lxc.conf on systems that use > NetworkManager). > ++# Once these changes are made, restart the lxc-net and network-manager > services. > ++# 'container1.lxc' will then resolve on your host. > ++#LXC_DOMAIN="lxc" > ++EOF > ++} > ++ > ++configure_lxcbr0() > ++{ > ++local i=3 > ++cat > $distrosysconfdir/lxc-net << EOF > ++# This file is auto-generated by lxc.postinst if it does not > ++# exist. Customizations will not be overridden. > ++EOF > ++# if lxcbr0 exists, keep using the same network > ++if ip addr show lxcbr0 > /dev/null 2>&1 ; then > ++i=`ip addr show lxcbr0 | grep "inet\>" | awk '{ print
[ptxdist] [PATCH v3] lxc: add new package
This patch adds support for the lxc container system. We install the userspace lib and application. To make sure all necessary kernel options are enabled use: $ CONFIG=/path/to/kernelconfig lxc-checkconfig Signed-off-by: Michael Grzeschik --- v1 -> v2: - prefixed used variables with PTXCONF_ : LXC_TEMPLATES, LXC_HOOKS, LXC_SELINUX - fixed used variable LXC_SYSTEMD_UNIT - added missing dir /usr/lib/lxc/rootfs - added dependency to busybox tools when using templates - added dependency to iptables when starting systemd.service - removed some extra commented unused options - removed hooks - only installing busybox template - added dependency to busybox_umount v2 -> v3: - removed the busybox template and its dependencies - added patch for dnsmasq to start without dns support - added install stage to include getent from toolchain ...te-new-lxcbr0-subnet-at-startup-time.patch | 134 +++ ...-net-start-dnsmasq-without-dnsserver.patch | 24 ++ patches/lxc-3.0.1/series | 2 + projectroot/etc/default/lxc-net | 7 + projectroot/etc/lxc/default.conf | 4 + rules/lxc.in | 61 + rules/lxc.make| 211 ++ 7 files changed, 443 insertions(+) create mode 100644 patches/lxc-3.0.1/0001-Allocate-new-lxcbr0-subnet-at-startup-time.patch create mode 100644 patches/lxc-3.0.1/0002-lxc-net-start-dnsmasq-without-dnsserver.patch create mode 100644 patches/lxc-3.0.1/series create mode 100644 projectroot/etc/default/lxc-net create mode 100644 projectroot/etc/lxc/default.conf create mode 100644 rules/lxc.in create mode 100644 rules/lxc.make diff --git a/patches/lxc-3.0.1/0001-Allocate-new-lxcbr0-subnet-at-startup-time.patch b/patches/lxc-3.0.1/0001-Allocate-new-lxcbr0-subnet-at-startup-time.patch new file mode 100644 index 0..a1fddbea4 --- /dev/null +++ b/patches/lxc-3.0.1/0001-Allocate-new-lxcbr0-subnet-at-startup-time.patch @@ -0,0 +1,134 @@ +From: =?UTF-8?q?St=C3=A9phane=20Graber?= +Date: Tue, 3 Nov 2015 11:42:58 -0500 +Subject: [PATCH] Allocate new lxcbr0 subnet at startup time + +--- + config/init/common/lxc-net.in | 100 ++ + 1 file changed, 91 insertions(+), 9 deletions(-) + +diff --git a/config/init/common/lxc-net.in b/config/init/common/lxc-net.in +index df9f1181d761..6837be1969c2 100644 +--- a/config/init/common/lxc-net.in b/config/init/common/lxc-net.in +@@ -24,6 +24,85 @@ LXC_IPV6_MASK="" + LXC_IPV6_NETWORK="" + LXC_IPV6_NAT="false" + ++write_lxc_net() ++{ ++local i=$1 ++cat >> $distrosysconfdir/lxc-net << EOF ++# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your ++# containers. Set to "false" if you'll use virbr0 or another existing ++# bridge, or mavlan to your host's NIC. ++USE_LXC_BRIDGE="true" ++ ++# If you change the LXC_BRIDGE to something other than lxcbr0, then ++# you will also need to update your /etc/lxc/default.conf as well as the ++# configuration (/var/lib/lxc//config) for any containers ++# already created using the default config to reflect the new bridge ++# name. ++# If you have the dnsmasq daemon installed, you'll also have to update ++# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon. ++LXC_BRIDGE="lxcbr0" ++LXC_ADDR="10.0.$i.1" ++LXC_NETMASK="255.255.255.0" ++LXC_NETWORK="10.0.$i.0/24" ++LXC_DHCP_RANGE="10.0.$i.2,10.0.$i.254" ++LXC_DHCP_MAX="253" ++# Uncomment the next line if you'd like to use a conf-file for the lxcbr0 ++# dnsmasq. For instance, you can use 'dhcp-host=mail1,10.0.3.100' to have ++# container 'mail1' always get ip address 10.0.3.100. ++#LXC_DHCP_CONFILE=/etc/lxc/dnsmasq.conf ++ ++# Uncomment the next line if you want lxcbr0's dnsmasq to resolve the .lxc ++# domain. You can then add "server=/lxc/10.0.$i.1' (or your actual \$LXC_ADDR) ++# to your system dnsmasq configuration file (normally /etc/dnsmasq.conf, ++# or /etc/NetworkManager/dnsmasq.d/lxc.conf on systems that use NetworkManager). ++# Once these changes are made, restart the lxc-net and network-manager services. ++# 'container1.lxc' will then resolve on your host. ++#LXC_DOMAIN="lxc" ++EOF ++} ++ ++configure_lxcbr0() ++{ ++local i=3 ++cat > $distrosysconfdir/lxc-net << EOF ++# This file is auto-generated by lxc.postinst if it does not ++# exist. Customizations will not be overridden. ++EOF ++# if lxcbr0 exists, keep using the same network ++if ip addr show lxcbr0 > /dev/null 2>&1 ; then ++i=`ip addr show lxcbr0 | grep "inet\>" | awk '{ print $2 }' | awk -F. '{ print $3 }'` ++write_lxc_net $i ++return ++fi ++# if no lxcbr0, find an open 10.0.a.0 network ++for l in `ip addr show | grep "inet\>" |awk '{ print $2 }' | grep '^10\.0\.' | sort -n`; do ++j=`echo $l | awk -F. '{ print $3 }'` ++