Daniel Lezcano [Thu, 21 Jan 2010 13:48:42 +0000 (14:48 +0100)]
drop capabilities
Hello everyone!
I've written a patch which adds a new config keyword
'lxc.cap.drop'. This keyword allows to specify capabilities which are
dropped before executing the container binary.
Reworked-by: Daniel Lezcano <daniel.lezcano@free.fr> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: Michael Holzt <lxc@my.fqdn.org> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Taisuke Yamada [Mon, 18 Jan 2010 22:08:12 +0000 (23:08 +0100)]
Added -e to lxc-console to change command character (defaults to '^a')
I noticed lxc-console uses '^a' as command-mode prefix to
escape out of console session, so created a patch to make it
configurable. With this, you can do
lxc-console -n foo -e ^t
and exit the session with 'Ctrl+t q'.
For emacs-binding addicts (like me), it's always nice to
let shell handle '^a' as 'beginning-of-line' command...
Signed-off-by: Taisuke Yamada <tai@rakugaki.org> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Clement Calmels [Mon, 18 Jan 2010 22:08:12 +0000 (23:08 +0100)]
use getline instead of fgets
The getline function allocate the needed memory. Fix buffer can lead
to 'hard to find' bug. I don't test the pivot_root part but the other
parts are ok.
Signed-off-by: Clement Calmels <clement.calmels@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Cedric Le Goater [Wed, 13 Jan 2010 17:51:15 +0000 (18:51 +0100)]
use different log categories in commands
lxc_<cmd>.c and <cmd>.c files use the same log category : lxc_<cmd>.
The symbol is multiply defined and linking statically lxc commands is
not possible.
The patch introduces new log categories with a '_ui' suffix to
differentiate the command line interface from the library routine.
Reported-by: Ciprian Dorin, Craciun <ciprian.craciun@gmail.com> Signed-off-by: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
code to break chroot taken from
http://www.bpfh.net/simes/computing/chroot-break.html
Now this can be fixed. As our container has his own mount namespace, we can
easily pivot_root into the rootfs and then unmount all old mounts. The patch
attached add a new config keyword which contains the path to a temporary
mount for the old rootfs (inside the container). This stops the chroot break
method shown before.
Daniel Lezcano [Mon, 28 Dec 2009 21:10:11 +0000 (22:10 +0100)]
add macvlan vepa and bridge mode
The future kernel 2.6.33 will incorporate the macvlan bridge
mode where all the macvlan will be able to communicate if they are
using the same physical interface. This is an interesting feature
to have containers to communicate together. If we are outside of the
container, we have to setup a macvlan on the same physical interface than
the containers and use it to communicate with them.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Daniel Lezcano [Sun, 27 Dec 2009 21:36:09 +0000 (22:36 +0100)]
cleanup lxc-debian script
The lxc-debian is epurated and consolidated with a better
error handling.
This script is no longer interactive but it installs in a specified
place the debian rootfs.
This script is not supposed to be called directly so it will fall in
libexec path very soon. This script is called by lxc-create
as a template with the right option and the right place.
The debian network configuration is by dhcp.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Jamal Hadi Salim [Tue, 15 Dec 2009 09:14:27 +0000 (10:14 +0100)]
Introduce per netdev priv structure
Some devices like veth or vlans have a bit of extra details that
are specific to them. Example veth.pair and vlan.vlanid.
Separate them from the common so we can update cleanly in the future.
Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca> Acked-by: Daniel Lezcano <daniel.lezcano@free.fr> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Jamal Hadi Salim [Tue, 15 Dec 2009 09:14:27 +0000 (10:14 +0100)]
Add VLAN support in config
This adds ability to migrate vlan interfaces into namespaces
by specifying them in a config
Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca> Acked-by: Daniel Lezcano <daniel.lezcano@free.fr> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Jamal Hadi Salim [Tue, 15 Dec 2009 09:14:26 +0000 (10:14 +0100)]
Add utility u16 get/put
Add utility functions to parse a u16 and put a u16 on a
netlink message
Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca> Acked-by: Daniel Lezcano <daniel.lezcano@free.fr> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Andrian Nord [Thu, 26 Nov 2009 15:46:25 +0000 (16:46 +0100)]
"Default" configuration may destroy host system
If you're running (by mistake or typo) (via lxc-start) container that does not
exists it will run with lxc.rootfs=/, meaning that /sbin/init will
restart initialization procedure, efficiently messing host's system,
that may lead to unpredictable results or even destroy (make inaccessible) host
system (by reseting network configuration or something like that).
(Actually, it _did_ destroy system of everyone who tested this).
Actually, I finally lost any meaning of having such a feature for
full-system containers. You may not use hosts's FS - it's described at
above. You may not use some temporary directory - that's nonsense.
This patch forbinds starting container via lxc-start without rcfile and
custom start program, but probably it fixes only small part of problem.
I really don't see much sense in such a feature without ability of
overriding 'default' setting with command line switches. Anyway, default
behaviour should be as save as possible.
Signed-off-by: Andrian Nord <NightNord@gmail.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Daniel Lezcano [Thu, 26 Nov 2009 15:46:24 +0000 (16:46 +0100)]
pass lxc_conf to the lxc_start function instead of the rcfile
The rcfile is parsed in the lxc_start function. This is not the place
to do that. Let's the caller to do that.
In the meantime, we have the lxc_conf structure filled right before
calling the lxc_start function so we can do some sanity check on the
configuration to not break the system when we launch the container.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Sven Wegener [Thu, 26 Nov 2009 15:46:23 +0000 (16:46 +0100)]
use correct number of ttys during setup
commit 985d15b106c8959ff130ba5425c2abbe36dc2cca "fix fdleak and errors
in lxc_create_tty()" created a zero-sized malloc(), causing memory
corruption. use config->tty like all the other code does.
Signed-off-by: Sven Wegener <sven.wegener@stealer.net> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Michael Tokarev [Thu, 26 Nov 2009 15:46:23 +0000 (16:46 +0100)]
allow lxc.network.pair to specify host-side name for veth interface
Currently we allocate veth device with random name on host side,
so that things like firewall rules or accounting does not work
at all. Fix this by recognizing yet anothe keyword to specify
the host-side device name: lxc.network.pair, and use it instead
of random name if specified.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Michel Normand [Thu, 26 Nov 2009 15:46:22 +0000 (16:46 +0100)]
lxc-ps to limit its search to containers
The purpose of this patch is to limit the search
of pids to those in containers by looking at first
in the /cgroup/<name>/tasks when --lxc or --names options
are specified by user.
The idea is to speedup the output when only few
container names are specified while the machine
is running with many processes.
Signed-off-by: Michel Normand <michel.mno@free.fr> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Michel Normand [Thu, 26 Nov 2009 15:46:22 +0000 (16:46 +0100)]
lxc-ls to report also active containers
With previous changes that allow to start a container
without the need to create it; the lxc-ls was only reporting
the created containers.
With this patch, the lxc-ls is now reporting created and active
containers.
Signed-off-by: Michel Normand <michel.mno@free.fr> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Michael Tokarev [Tue, 24 Nov 2009 08:47:27 +0000 (09:47 +0100)]
fix fdleak and errors in lxc_create_tty()
if, for some reason, openpty() fails, lxc_create_tty() will
leak all previous ptys and leave the config structure in a
inconsistent state (wrt the number of ptys actually opened)
Fix that by explicitly closing all previously opened ptys
in case of failure and by setting number of actually opened
ttys after actual open
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Michael Tokarev [Fri, 20 Nov 2009 14:01:31 +0000 (15:01 +0100)]
allow link-less veth devices
Before, a veth device pair required a link which was treated as
a bridge device. Code crashed if there was no lxc.network.link
specified. Fix that by allowing lxc.network.link to be unset
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Daniel Lezcano [Fri, 20 Nov 2009 14:01:30 +0000 (15:01 +0100)]
Do not chdir when daemonize
With the previous modifications, a temporary directory is created
to mount the rootfs in order to have the system container to remount
itself the '/' directory.
But in case of daemonize, we change the directory, so when the rootfs
is specified with a relative path, we can not access it.
Don't chdir, as that will be done automatically later in the chroot
setup.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Michael Tokarev [Thu, 19 Nov 2009 14:06:02 +0000 (15:06 +0100)]
rename struct lxc_netdev fields to match reality
struct lxc_netdev is used to hold information from cnfig file
about a network device/configuration. Make the fields of this
structure to be named similarily with the config file keywords,
namely:
s/ifname/link/ - host-side link for the device (bridge or eth0)
s/newname/name/ - container-side ifname
It is insane to have completely different names in config file
and in structure/variable names :)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Daniel Lezcano [Tue, 17 Nov 2009 21:57:46 +0000 (22:57 +0100)]
fix container find the previously created configuration
The command specifies a configuration file => use it
The command does not specify a configuration but the container
was created before, use the configuration.
The command does not specify a configuration and the container
was not created before, use default.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Michael Tokarev [Tue, 17 Nov 2009 09:56:24 +0000 (10:56 +0100)]
batched reads for lxc_console
Instead of doing I/O one-byte-at-a-time in lxc_console,
which is slow, let's do it in batches. Only for output
(from container to the host system), since input is most
likely one-byte-at-a-time anyway (from a keyboard).
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Michael Tokarev [Tue, 17 Nov 2009 09:56:24 +0000 (10:56 +0100)]
host consoles/ttys in containers
I noticed that container's consoles aren't quite useable
(be it lxc-console or lxc-start with getty bound to /dev/console).
The main problem is a complete lack of window resizing support:
when I resize an xterm window with lxc-start or lxc-console, the
"guest" does not know about that and continues to think that the
terminal is 80x25 still.
Is it just a lack of functionality (missing implementation) or
something problematic?
Ok, the attached patch fixes this.
It moves the 'master' variable out of main function so it's
accessible from the signal handler, sets up SIGWINCH handler
to call a (newly created) winsz() function that gets the
current tty size using TIOCGWINSZ ioctl and if that works,
sets up the pty size using TIOCSWINSZ. That same function
is called at the start as well, when setting up the signal
handler.
Signed-off-By: Michael Tokarev <mjt@tls.msk.ru> Signed-off-By: Daniel Lezcano <dlezcano@fr.ibm.com>
Andrian Nord [Tue, 17 Nov 2009 09:56:23 +0000 (10:56 +0100)]
Choose configuration directory
Maybe it will be more logical to keep configs into /etc/lxc/?
Or, maybe, just use --with-config-path=/some/path switch into configure,
which could be overridden as user wants to? Something like this one (in
assumption, that this is up to user to create corresponding directory):
Signed-off-by: Andrian Nord <NightNord@gmail.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Andrian Nord [Fri, 13 Nov 2009 10:48:29 +0000 (11:48 +0100)]
Q: general lxc architecture
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@gmail.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Michel Normand [Fri, 13 Nov 2009 10:48:29 +0000 (11:48 +0100)]
lxc: add a new lxc.mount.entry keyword
The purpose of this new keyword is to save in main config file
all the lines of a provided fstab file.
This will ultimately replace the the lxc.mount keyword
when lxc scripts will use the new keyword.
Warning: I did not validated this patch
in all conditions of provided malformed input string.
Signed-off-by: Michel Normand <michel_mno@laposte.net> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Daniel Lezcano [Fri, 13 Nov 2009 10:48:29 +0000 (11:48 +0100)]
Replace create/destroy by a script
The simplification of the container configuration makes
pointless to have so much complexity in the container creation.
Let's remove that and replace by some scripts.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Daniel Lezcaon [Fri, 13 Nov 2009 10:48:29 +0000 (11:48 +0100)]
Allows a container to run without previous creation
When a container was created, its configuration is used.
When a container was not created, the configuration specified in
the command line is used, if not configuration file is used,
default values are used.
That allows to create 'volatile' container, like tmp files.
It is useful for example to spawn different container with the
same generic configuration file. That let the user to have its own
repository of configuration files.
And, more important, that fix temporary created container with
lxc-execute to be not deleted when the host crash or the command
is killed.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>