[lxc-devel] Q: general lxc architecture

Andrian Nord nightnord at gmail.com
Tue Nov 10 22:29:55 UTC 2009


On Tue, Nov 10, 2009 at 09:40:46PM +0100, Daniel Lezcano wrote:
>  * finish with the /var/lxc/* cleanup and maybe change lxc-create and 
> lxc-destroy to a simple wrapper script doing roughly cp and rm.
Heh, just like I'm doing now (copying 'template' container, that sed'ing
config and fstab as s/template/<container>/) - maybe it make some sense
not to rm -Rf container config directory, but silently move it to
.<container>.destroyed, as vzctl does, so it could be reused if
container whould be ressurected (or user may just simply rm -Rf it
himself).

Still, if you want to just copy container, you need the source, which,
theoretically, should be user-modifitable. It could be some hardcoded
path/name or, maybe, do you plan something like global lxc.conf config?

>  * launch containers without creating it (not persistent in the system).
I.e. autocreating following some hardcoded defaults inside memory,
without producing corresponding disc structures? And how it will be
controlled by user, if he want to have other defaults? Or you mean
ability of start-time changing of particular config options, following
user to specify something like
lxc-execute -n lxc.temporary --hostname ssh.example.com /usr/sbin/sshd
where 'lxc.temporary' is name of some persistent configuration, which is
loaded as defaults?

>  * check and fix the lxc-debian and lxc-sshd to match the recent 
> modifications around the /var/lxc/*
And lxc-netstat, it assumes that initpid contained into
${lxcroot}/${name}/initpid

> Yes, that makes sense with the cleanup of /var/lxc. But there are some 
> clarifications to do around the owner of a container.
> eg. shall we let only root to create the containers and assign 
> permissions to it so a non-root user can use it ?

Hm, at least this is configurable by root. He may specify some
write-group for lxcpath, of for some specific containers only. Or he may
just make a simple sed+echo script and give sudo on it for specific
users =)

> I am fine with this patch, is it tested ? Shall I take it ?

When i've posted it i'd tested that it at compiles and changes LXCPATH
correctly. Now I've tested it more - with this patch and copied configs
all my 16 containers succesfully were restarted. So it works.

But, maybe it will be also usefull to move than all contents that are
installed currently into /etc/lxc/ (examples) into
${docdir}/examples, where they should be, theoretically?

Here comes additional patch for that. I don't sure if we really need
another configure switch for examples, but some distros like to provide
documentation themselfs, i.e. with additional compression, so this could
be useful for them.

Also, if everyone in agreement, that /etc/lxc/ is better placement for
configurations, maybe it could be done as default? It will break backward
compability, but everyone who uses git version must be awared of such
things and next release will probably need some migration-tool anyway.

Also, if you are planning to have some general lxc-utils' config (say
/etc/lxc/lxc.conf), maybe lxcpath should be pointed at
/etc/lxc/containers/ or something like that? (I'm currently using
/etc/lxc/common/ directory for internal use, i.e. for common for
containers configuration files that are bind'ed into container and
symliked at their systems path)

Patch moves etc/* contents into doc/examples/ and adds
--disable-examples configure switch which may be used not to install
examples. Default is to install them into ${docdir}/examples (commonly:
/usr/share/doc/lxc/examples)

Signed-off-by: Andrian Nord <NightNord at gmail.com>

diff --git a/Makefile.am b/Makefile.am
index 3933d2a..90b771b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,8 +2,8 @@
 
 ACLOCAL_AMFLAGS = -I config
 
-SUBDIRS = src etc scripts doc
-DIST_SUBDIRS = config src etc scripts doc
+SUBDIRS = src scripts doc
+DIST_SUBDIRS = config src scripts doc
 EXTRA_DIST = autogen.sh lxc.spec CONTRIBUTING MAINTAINERS ChangeLog
 
 pcdatadir = $(datadir)/pkgconfig
diff --git a/configure.ac b/configure.ac
index 5e4ac46..66f9b1b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,6 +25,12 @@ fi
 
 AM_CONDITIONAL([ENABLE_DOCBOOK], [test "x$have_docbook" = "xyes"])
 
+AC_ARG_ENABLE([examples],
+	[AC_HELP_STRING([--disable-examples], [do not install configuration examples])],
+	[], [enable_examples=yes])
+
+AM_CONDITIONAL([ENABLE_EXAMPLES], [test "x$enable_examples" = "xyes"])
+
 AS_AC_EXPAND(PREFIX, $prefix)
 AS_AC_EXPAND(LIBDIR, $libdir)
 AS_AC_EXPAND(BINDIR, $bindir)
@@ -107,13 +113,13 @@ AC_CONFIG_FILES([
 	src/lxc/lxc-setcap
 	src/lxc/lxc-version
 
-	etc/Makefile
-	etc/lxc-macvlan.conf
-	etc/lxc-no-netns.conf
-	etc/lxc-empty-netns.conf
-	etc/lxc-phys.conf
-	etc/lxc-veth.conf
-	etc/lxc-complex-config
+	doc/examples/Makefile
+	doc/examples/lxc-macvlan.conf
+	doc/examples/lxc-no-netns.conf
+	doc/examples/lxc-empty-netns.conf
+	doc/examples/lxc-phys.conf
+	doc/examples/lxc-veth.conf
+	doc/examples/lxc-complex-config
 ])
 AC_CONFIG_COMMANDS([default],[[]],[[]])
 AC_OUTPUT
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 9f7bf69..bd96c99 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,3 +1,5 @@
+SUBDIRS = examples
+DIST_SUBDIRS = examples
 
 EXTRA_DIST = \
 	FAQ.txt \
diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
new file mode 100644
index 0000000..0490a8b
--- /dev/null
+++ b/doc/examples/Makefile.am
@@ -0,0 +1,21 @@
+EXTRA_DIST = $(pkgexamples_DATA)
+
+if ENABLE_EXAMPLES
+pkgexamplesdir=$(docdir)/examples
+
+pkgexamples_DATA = \
+	lxc-macvlan.conf \
+	lxc-no-netns.conf \
+	lxc-empty-netns.conf \
+	lxc-phys.conf \
+	lxc-veth.conf \
+	lxc-complex-config
+endif
+
+noinst_DATA = \
+	lxc-macvlan.conf.in \
+	lxc-empty-netns.conf.in \
+	lxc-no-netns.conf.in \
+	lxc-phys.conf.in \
+	lxc-veth.conf.in \
+	lxc-complex-config.in
diff --git a/doc/examples/lxc-complex-config b/doc/examples/lxc-complex-config
new file mode 100644
index 0000000..f2e8ea3
--- /dev/null
+++ b/doc/examples/lxc-complex-config
@@ -0,0 +1,23 @@
+# Container with network a complex network mixing macvlan, veth and 
+# physical network devices
+lxc.utsname = complex
+lxc.network.type = veth
+lxc.network.flags = up
+lxc.network.link = br0
+lxc.network.hwaddr = 4a:49:43:49:79:bf
+lxc.network.ipv4 = 1.2.3.5/24
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597
+
+lxc.network.type = macvlan
+lxc.network.flags = up
+lxc.network.link = eth0
+lxc.network.hwaddr = 4a:49:43:49:79:bd
+lxc.network.ipv4 = 1.2.3.4/24
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596
+
+lxc.network.type = phys
+lxc.network.flags = up
+lxc.network.link = dummy0
+lxc.network.hwaddr = 4a:49:43:49:79:ff
+lxc.network.ipv4 = 1.2.3.6/24
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3297
diff --git a/doc/examples/lxc-complex-config.in b/doc/examples/lxc-complex-config.in
new file mode 100644
index 0000000..f2e8ea3
--- /dev/null
+++ b/doc/examples/lxc-complex-config.in
@@ -0,0 +1,23 @@
+# Container with network a complex network mixing macvlan, veth and 
+# physical network devices
+lxc.utsname = complex
+lxc.network.type = veth
+lxc.network.flags = up
+lxc.network.link = br0
+lxc.network.hwaddr = 4a:49:43:49:79:bf
+lxc.network.ipv4 = 1.2.3.5/24
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597
+
+lxc.network.type = macvlan
+lxc.network.flags = up
+lxc.network.link = eth0
+lxc.network.hwaddr = 4a:49:43:49:79:bd
+lxc.network.ipv4 = 1.2.3.4/24
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596
+
+lxc.network.type = phys
+lxc.network.flags = up
+lxc.network.link = dummy0
+lxc.network.hwaddr = 4a:49:43:49:79:ff
+lxc.network.ipv4 = 1.2.3.6/24
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3297
diff --git a/doc/examples/lxc-empty-netns.conf.in b/doc/examples/lxc-empty-netns.conf.in
new file mode 100644
index 0000000..aedc99f
--- /dev/null
+++ b/doc/examples/lxc-empty-netns.conf.in
@@ -0,0 +1,4 @@
+# Container with new network withtout network devices
+lxc.utsname = omega
+lxc.network.type = empty
+lxc.network.flags = up
diff --git a/doc/examples/lxc-macvlan.conf.in b/doc/examples/lxc-macvlan.conf.in
new file mode 100644
index 0000000..d42d4af
--- /dev/null
+++ b/doc/examples/lxc-macvlan.conf.in
@@ -0,0 +1,8 @@
+# Container with network virtualized using the macvlan device driver
+lxc.utsname = alpha
+lxc.network.type = macvlan
+lxc.network.flags = up
+lxc.network.link = eth0
+lxc.network.hwaddr = 4a:49:43:49:79:bd
+lxc.network.ipv4 = 1.2.3.4/24
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596
diff --git a/doc/examples/lxc-no-netns.conf.in b/doc/examples/lxc-no-netns.conf.in
new file mode 100644
index 0000000..2c21264
--- /dev/null
+++ b/doc/examples/lxc-no-netns.conf.in
@@ -0,0 +1,2 @@
+# Container with non-virtualized network
+lxc.utsname = delta
diff --git a/doc/examples/lxc-phys.conf.in b/doc/examples/lxc-phys.conf.in
new file mode 100644
index 0000000..7c33eab
--- /dev/null
+++ b/doc/examples/lxc-phys.conf.in
@@ -0,0 +1,9 @@
+# Container with network virtualized using a physical network device with name
+# 'eth0'
+lxc.utsname = gamma
+lxc.network.type = phys
+lxc.network.flags = up
+lxc.network.link = eth0
+lxc.network.hwaddr = 4a:49:43:49:79:ff
+lxc.network.ipv4 = 1.2.3.6/24
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3297
diff --git a/doc/examples/lxc-veth.conf.in b/doc/examples/lxc-veth.conf.in
new file mode 100644
index 0000000..0b1568f
--- /dev/null
+++ b/doc/examples/lxc-veth.conf.in
@@ -0,0 +1,9 @@
+# Container with network virtualized using a pre-configured bridge named br0 and
+# veth pair virtual network devices
+lxc.utsname = beta
+lxc.network.type = veth
+lxc.network.flags = up
+lxc.network.link = br0
+lxc.network.hwaddr = 4a:49:43:49:79:bf
+lxc.network.ipv4 = 1.2.3.5/24
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597
diff --git a/etc/.cvsignore b/etc/.cvsignore
deleted file mode 100644
index 72d0ae4..0000000
--- a/etc/.cvsignore
+++ /dev/null
@@ -1,9 +0,0 @@
-Makefile
-Makefile.in
-lxc-complex-config
-lxc-empty-netns.conf
-lxc-macvlan.conf
-lxc-no-netns.conf
-lxc-phys.conf
-lxc-veth.conf
-
diff --git a/etc/Makefile.am b/etc/Makefile.am
deleted file mode 100644
index aa7cc66..0000000
--- a/etc/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-pkgsysconfdir = $(sysconfdir)/$(PACKAGE)
-pkgsysconf_DATA = \
-	lxc-macvlan.conf \
-	lxc-no-netns.conf \
-	lxc-empty-netns.conf \
-	lxc-phys.conf \
-	lxc-veth.conf \
-	lxc-complex-config
-noinst_DATA = \
-	lxc-macvlan.conf.in \
-	lxc-empty-netns.conf.in \
-	lxc-no-netns.conf.in \
-	lxc-phys.conf.in \
-	lxc-veth.conf.in \
-	lxc-complex-config.in
diff --git a/etc/lxc-complex-config.in b/etc/lxc-complex-config.in
deleted file mode 100644
index f2e8ea3..0000000
--- a/etc/lxc-complex-config.in
+++ /dev/null
@@ -1,23 +0,0 @@
-# Container with network a complex network mixing macvlan, veth and 
-# physical network devices
-lxc.utsname = complex
-lxc.network.type = veth
-lxc.network.flags = up
-lxc.network.link = br0
-lxc.network.hwaddr = 4a:49:43:49:79:bf
-lxc.network.ipv4 = 1.2.3.5/24
-lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597
-
-lxc.network.type = macvlan
-lxc.network.flags = up
-lxc.network.link = eth0
-lxc.network.hwaddr = 4a:49:43:49:79:bd
-lxc.network.ipv4 = 1.2.3.4/24
-lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596
-
-lxc.network.type = phys
-lxc.network.flags = up
-lxc.network.link = dummy0
-lxc.network.hwaddr = 4a:49:43:49:79:ff
-lxc.network.ipv4 = 1.2.3.6/24
-lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3297
diff --git a/etc/lxc-empty-netns.conf.in b/etc/lxc-empty-netns.conf.in
deleted file mode 100644
index aedc99f..0000000
--- a/etc/lxc-empty-netns.conf.in
+++ /dev/null
@@ -1,4 +0,0 @@
-# Container with new network withtout network devices
-lxc.utsname = omega
-lxc.network.type = empty
-lxc.network.flags = up
diff --git a/etc/lxc-macvlan.conf.in b/etc/lxc-macvlan.conf.in
deleted file mode 100644
index d42d4af..0000000
--- a/etc/lxc-macvlan.conf.in
+++ /dev/null
@@ -1,8 +0,0 @@
-# Container with network virtualized using the macvlan device driver
-lxc.utsname = alpha
-lxc.network.type = macvlan
-lxc.network.flags = up
-lxc.network.link = eth0
-lxc.network.hwaddr = 4a:49:43:49:79:bd
-lxc.network.ipv4 = 1.2.3.4/24
-lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596
diff --git a/etc/lxc-no-netns.conf.in b/etc/lxc-no-netns.conf.in
deleted file mode 100644
index 2c21264..0000000
--- a/etc/lxc-no-netns.conf.in
+++ /dev/null
@@ -1,2 +0,0 @@
-# Container with non-virtualized network
-lxc.utsname = delta
diff --git a/etc/lxc-phys.conf.in b/etc/lxc-phys.conf.in
deleted file mode 100644
index 7c33eab..0000000
--- a/etc/lxc-phys.conf.in
+++ /dev/null
@@ -1,9 +0,0 @@
-# Container with network virtualized using a physical network device with name
-# 'eth0'
-lxc.utsname = gamma
-lxc.network.type = phys
-lxc.network.flags = up
-lxc.network.link = eth0
-lxc.network.hwaddr = 4a:49:43:49:79:ff
-lxc.network.ipv4 = 1.2.3.6/24
-lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3297
diff --git a/etc/lxc-veth.conf.in b/etc/lxc-veth.conf.in
deleted file mode 100644
index 0b1568f..0000000
--- a/etc/lxc-veth.conf.in
+++ /dev/null
@@ -1,9 +0,0 @@
-# Container with network virtualized using a pre-configured bridge named br0 and
-# veth pair virtual network devices
-lxc.utsname = beta
-lxc.network.type = veth
-lxc.network.flags = up
-lxc.network.link = br0
-lxc.network.hwaddr = 4a:49:43:49:79:bf
-lxc.network.ipv4 = 1.2.3.5/24
-lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597




More information about the lxc-devel mailing list