Commit Graph

284 Commits

Author SHA1 Message Date
Serge Hallyn
1bd051a6b0 link /dev/kmsg to /dev/console in the container
This way init log messages can be seen on the console.  If containerized
syslog ever comes around, we can get rid of this.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:35:08 +02:00
Serge Hallyn
87af3ecd48 log errno when pclose fails
When lxc is executing a script and pclose fails, log the
errno to help debug what happened.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:29:53 +02:00
Stéphane Graber
d0a36f2c8b Add missing include for apparmor.h in conf.c
This include is conditional on apparmor being selected.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:22:50 +02:00
Stéphane Graber
9ac3ffb517 Make lxc-execute without rootfs work.
That means, don't try to pin a null rootfs, and don't try to mount /proc
since /var/lib/lxc/root/proc doesn't exist to be mounted onto.
The apparmor patches are not yet upstream, so this patch will not go
upstream by itself.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:19:37 +02:00
Serge Hallyn
30c5d29201 use lxc_putold as pivot_dir put dir, not mnt
Using mnt means that lxc fstab entries do not work when placed under
the container's /mnt/ (i.e. /mnt/etc).

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:07:18 +02:00
Serge Hallyn
e99ee0decc don't try to pin a null rootfs.
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:04:33 +02:00
Serge Hallyn
9ba8130c96 switch all sprintfs which can overrun to snprintfs
and check return values

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:04:33 +02:00
Serge Hallyn
80a881b232 templates: use relative paths when creating containers
At the same time, allow lxc.mount.entry to specify an absolute target
path relative to /var/lib/lxc/CN/rootfs, even if rootfs is a blockdev.
Otherwise all such entries are ignored for blockdev-backed containers.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:04:33 +02:00
Serge Hallyn
26ddeedd83 Introduce a first set of container hooks
This patch introduces support for 4 hooks.  We'd like to have 6 in
all to mirror the openvz ones (thanks to Stéphane for this info):

pre-start: in the host namespace before container mounting happens
mount: after container mounting (as per config and /var/lib/lxc/container/fstab)
       but before pivot_root
start: immediately before exec'ing init
stop: in container namespace and in chroot before shutdown
umount: after other unmounting has happened
post-stop: outside of the container

stop and umount are not implemented here because when the kernel kills
the container init, it kills the namespace.  We can probably work around
this, i.e. by keeping the /proc/pid/ns/mnt open, and using that, though
all container tasks including init would still be dead.  Is that worth
pursuing?

start also presents a bit of an issue.  openvz allows a script on the
host to be specified, apparently.  My patch requires the script or
program to exist in the container.  I'm fine with trying to do it the
openvz way, but I wasn't sure what the best way to do that was.  Openvz
(I'm told) opens the script and passes its contents to a bash in the
container.  But that limits the hooks to being only scripts.  By
requiring the hook to be in the container, we can allow any sort of
hook, and assume that any required libraries/dependencies exist
there.

Other than that with this patchset I can add

lxc.hook.pre-start = /var/lib/lxc/p1/pre-start
lxc.hook.mount = /var/lib/lxc/p1/mount
lxc.hook.start = /start
lxc.hook.post-stop = /var/lib/lxc/p1/post-stop

to my /var/lib/lxc/p1/config, and the hooks get executed as expected.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:04:33 +02:00
Serge Hallyn
e075f5d9b6 Introduce apparmor support
This could be done as generic 'lsm_init()' and 'lsm_load()' functions,
however that would make it impossible to compile one package supporting
more than one lsm.  If we explicitly add the selinux, smack, and aa
hooks in the source, then one package can be built to support multiple
kernels.

The smack support should be pretty trivial, and probably very close
to the apparmor support.

The selinux support may require more, including labeling the passed-in
fds (consoles etc) and filesystems.

If someone on the list has the inclination and experience to add selinux
support, please let me know.  Otherwise, I'll do Smack and SELinux.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:04:33 +02:00
Serge Hallyn
0c54752318 pin container's rootfs to prevent read-only remount
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:03:30 +02:00
Serge Hallyn
7c6ef2a2ee add lxc.devttydir config variable
If set, then the console and ttys will be bind-mounted not over /dev/console,
but /dev/<ttydir>/console and then symlinked from there to /dev/console.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-26 10:44:41 +01:00
Christian Seiler
d55bc1adad Accept numeric values for capabilities to drop
lxc.cap.drop now also accepts numeric values for capabilities. This allows
the user to specify capabilities LXC doesn't know about yet or capabilities
that were not part of the kernel headers LXC was compiled against.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:13 +01:00
Christian Seiler
5170c71633 Add CAP_SYSLOG and CAP_WAKE_ALARM to list of capabilities
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-02-23 09:57:13 +01:00
Daniel Lezcano
d8f8e35202 Fix network cleanup on error
Network cleanup does not cleanup correctly the virtual interfaces
in case of an error.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-01-05 22:45:32 +01:00
Daniel Lezcano
7ad84da79b fix indentation of the previous patch
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-01-05 22:45:31 +01:00
Christian Seiler
49684c0b43 Set high byte of mac addresses for host veth devices to 0xfe
When used in conjunction with a bridge, veth devices with random addresses
may change the mac address of the bridge itself if the mac address of the
interface newly added is numerically lower than the previous mac address
of the bridge. This is documented kernel behavior. To avoid changing the
host's mac address back and forth when starting and/or stopping containers,
this patch ensures that the high byte of the mac address of the veth
interface visible from the host side is set to 0xfe.

A similar logic is also implemented in libvirt.

Fixes SF bug #3411497
See also: <http://thread.gmane.org/gmane.linux.kernel.containers.lxc.general/2709>

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
2012-01-05 22:45:31 +01:00
Matthijs Kooijman
19a26f8214 add autodetection of the gateway address
For veth and macvlan networks, this can look up the host address on the
bridge (link) interface and add a default route on the guest to that
address. This facilitates a typical setup where guests are bridged
together.

syntax:
	lxc.ipv4.gateway = auto
	lxc.ipv6.gateway = auto

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-08-30 23:50:23 +02:00
Matthijs Kooijman
f8fee0e2c3 .gateway configuration
This directive adds a default route to the guest at startup.

syntax:
	lxc.network.ipv4.gateway = 10.0.0.1
	lxc.network.ipv6.gateway = 2001:db8:85a3::8a2e:370:7334

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-08-30 23:50:23 +02:00
Serge Hallyn
c1c75c04a6 print netdev name, not link, after moving dev into netns
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-06-25 15:17:47 +02:00
Sven Wegener
77890c6d6b Check for existing ptmx symlink
It's OK, if /dev/ptmx points to /dev/pts/ptmx via a symlink.

Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-05-23 23:12:24 +02:00
Sven Wegener
88d413d5b6 Add relatime and strictatime mount options
Also add #ifndef for compability with glibc before 2.12.

Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-05-23 23:12:24 +02:00
Michael Santos
95642a1068 conf: increase buffer size to include spaces
Signed-off-by: Michael Santos <michael.santos@gmail.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-03-22 15:04:52 +01:00
Daniel Lezcano
071a2b8cc9 fix mount path
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-03-14 21:47:15 +01:00
Daniel Lezcano
d472214b83 rename physical device to the original name
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-03-07 02:08:47 +01:00
Daniel Lezcano
b84f58b9fb factor out networking configuration code
Change the name of the functions and factor some of them.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-03-07 02:08:47 +01:00
Daniel Lezcano
7b57e8b681 fix empty network configuration
The return statement is at the wrong place.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-02-02 21:55:49 +01:00
David Ward
b0efbac48e Only bring up network interface if IFF_UP is set
Each network interface was brought up regardless of the configuration,
as the wrong boolean operator was being used to test the IFF_UP flag.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-01-17 10:18:50 +01:00
Daniel Lezcano
6e35af2e39 set veth host's side always up
We should always have the veth host's side up, otherwise if we omit
the up flag in the configurationn, letting the container to configure
its interface, the network will be never enabled as the host's side
is not up.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-01-17 10:18:50 +01:00
Joerg Gollnick
91656ce587 Fix mntflags initialization
Dear all,
while setting up a container on x86_64 (archlinux host/guest) I had trouble 
with mounting dev/pts and others from container.fstab and a ssh login does not 
work (only ssh container bash -i gives you a shell)
The cause is that conf.c does not initialize mntflags.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-01-16 19:40:46 +01:00
Daniel Lezcano
013bd42848 substitute the absolute rootfs mount path
Change the mount point in the rootfs because we mount the rootfs
in ROOTFSDIR for the pivot. We have to substitute the real mount
path to the new path located in ROOTFSDIR.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-01-13 16:25:14 +01:00
Daniel Lezcano
911324ef25 encapsulate mount point code
Change the code to encapsulate the different mounts point.

 * mount on the host fs
 * mount relatively to the rootfs
 * mount absolutely to the rootfs (broken)

That will make the code cleaner to fix the latter.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-01-13 16:25:14 +01:00
Daniel Lezcano
d330fe7b86 mindless changes to conform indentation
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2011-01-13 16:15:15 +01:00
Michael Tokarev
59760f5d0f Make mount paths relative to rootfs
Why not chdir into the root of container right when
the root filesystem is (bind-)mounted, and let all
mount entries to be relative to the container root?

Even more, to warn if lxc.mount[.entry] contains
absolute path for the destination directory (or a
variation of this, absolute and does not start with
container root mount point)?

This way, all mounts will look much more sane, and
it will be much easier to move/clone containers -
by changing only lxc.rootfs.

I do it this way locally since the beginning, by
chdir'ing to the proper directory (rootfs) before
running lxc-start (in a startup script), but this
is now broken in 0.7.3 which bind-mounts rootfs
somewhere in /usr/lib/lxc.

Signed-off-by: Michael Tokarev<mjt@tls.msk.ru>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-12-17 11:43:36 +01:00
Sergey S. Kostyliov
968fbd3605 add support for dirsync mount option
Add support for `dirsync' mount option. MS_DIRSYNC is on of the
mount(2) mountflags so don't send it as extra mount option to avoid:

 	lxc-start: Invalid argument - failed to mount ...

errors.

Signed-off-by: Sergey S. Kostyliov <rathamahata@gmail.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-30 21:41:19 +02:00
Daniel Lezcano
b3ecde1ec3 Fix compilation error on fc12
The capability header makes the inclusion of the loop header to 
fail. Moving the inclusion of loop.h before capability.h fixes the
problem.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-12 15:11:45 +02:00
Daniel Lezcano
2656d23127 reduce function name
Cosmetic change by reducing the function names.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-12 14:57:57 +02:00
Daniel Lezcano
abbfd20baa use popen and redirect script output
Change the run_script function to use popen and to redirect
the output of the script to the log file.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-12 10:52:47 +02:00
Daniel Lezcano
751d9dcd39 fix Coding Style
Fix the coding style, 80 chars lines, etc ...
Fix indentation blocks if ... then ... else ... fi

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-12 10:52:47 +02:00
Stefan Tomanek
e3b4c4c44a add lxc.network.script.up configuration hook
This commit adds an configuration option to specify a script to be
executed after creating and configuring the network used by the
container. The following arguments are passed to the script:

	* container name
	* config section name (net)

Additional arguments depend on the config section employing a
script hook; the following are used by the network system:

	* execution context (up)
	* network type (empty/veth/macvlan/phys)

Depending on the network type, other arguments may be passed:

veth/macvlan/phys:
	* (host-sided) device name

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-12 10:52:47 +02:00
Daniel Lezcano
a6afdde95c allow to specify a image or a device block as rootfs
This patch allows to specify an image or a block device.

The image or the block device is mounted on rootfs->mount.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-03 23:09:36 +02:00
Daniel Lezcano
12297168e9 Initialize default mount point
Let's initialize rootfs->mount to LXCROOTFSMOUNT. The value
will be overwritten by the configuration in case it is specified.

That will make the code nicer, instead of the ugly rootfs->mount checks.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-03 23:09:35 +02:00
Daniel Lezcano
bc9bd0e31e use the rootfs mount point for the tty's
The rootfs is always located in rootfs->mount, let's use it for
the tty.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-03 23:09:35 +02:00
Daniel Lezcano
466978b083 use the rootfs mount point for the console
The rootfs is always located in the mount point now, let's
use it.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-03 23:09:35 +02:00
Daniel Lezcano
ac7787080c mount the rootfs to the mount directory first
Split the rootfs setup by mounting the rootfs to the mount
point. This mount point will be used as the facto place where
the rootfs is placed.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-03 23:09:35 +02:00
Daniel Lezcano
cccc74b514 configure container architecture
When a container is installed with 32bits binaries while we are
running on a 64bits host, inside the container we are seen as
64bits arch. That leads to some problems for the package updates
because the scripts will download 64bits packages instead of 32bits.

This patch defines a configuration variable to set the architecture
of the container.

lxc.arch = i686 | x86 | x86_64 | amd64

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-09-13 15:36:20 +02:00
Daniel Lezcano
96bcd56ae2 Dont' try to remove a physical nic on error
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-23 15:10:38 +02:00
Daniel Lezcano
6168e99fff fix core dump when using physical interface
If the physical link is not specified in the configuration
the check in if_nametoindex(netdev->link) leads to a segfault.

Check the link is specified.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Reported-by: Ferenc Wagner <wferi@niif.hu>
2010-07-23 15:10:38 +02:00
Daniel Lezcano
fb6d9b2f40 keep the name of the physical interface
When the interface used in the container is a physical
interface from the host, we keep the initial name.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Reported-by: Sabdar <sabdar@wellspringsys.com>
2010-07-22 15:59:44 +02:00
Ciprian Dorin, Craciun
e76b8764fa lxc to apply mount options for bind mounts
Hello all!

    This bug stalked me for a while, but only now it bit me quite
badly... (Lost about an hour of work...)

    So the culprit: inside the fstab file for the `lxc.mount` option I
can use options like `ro` together with `bind`. Unfortunately the
kernel just laughs in my face and ignores any options I've put in
there... :) But not any more: I've updated `./src/lxc/conf.c`
(`mount_file_entries` function) so that when it encounters a `bind`
option it executes it twice (one without any extra options, and a
second time with the remount flag set.)

I've marginally (as in my particular case) tested it and it works.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-24 09:47:14 +02:00
Ferenc Wagner
4f9293b1f0 fix comment
Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-11 15:56:25 +02:00
Ferenc Wagner
3103609ddc change pivotdir default to mnt
The mnt directory has a good chance to already exist in the new root
filesystem, so creation and removal can be avoided.  This also eases
use of read only root filesystems (no configuration necessary).

Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-11 15:56:25 +02:00
Ferenc Wagner
9527e566fc conditional use of new capabilities
Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-07 11:33:56 +02:00
Daniel Lezcano
0e391e57b0 fix compilation warnings
Fix the following warnings:

console.c: In function ‘console_handler’:
console.c:252: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result
console.c:254: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result
conf.c: In function ‘instanciate_veth’:
conf.c:1130: warning: ignoring return value of ‘mktemp’, declared with attribute warn_unused_result
conf.c:1135: warning: ignoring return value of ‘mktemp’, declared with attribute warn_unused_result
conf.c: In function ‘instanciate_macvlan’:
conf.c:1206: warning: ignoring return value of ‘mktemp’, declared with attribute warn_unused_result
af_unix.c: In function ‘lxc_af_unix_send_fd’:
af_unix.c:124: warning: dereferencing type-punned pointer will break strict-aliasing rules
af_unix.c: In function ‘lxc_af_unix_recv_fd’:
af_unix.c:169: warning: dereferencing type-punned pointer will break strict-aliasing rules
af_unix.c: In function ‘lxc_af_unix_send_credential’:
af_unix.c:195: warning: dereferencing type-punned pointer will break strict-aliasing rules
af_unix.c: In function ‘lxc_af_unix_rcv_credential’:
af_unix.c:237: warning: dereferencing type-punned pointer will break strict-aliasing rules

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-01 12:13:32 +02:00
Daniel Lezcano
5045eedff0 disable rootfs automatic detection
Avoid a warning at compile time by disabling temporary the code.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-28 17:39:11 +02:00
Daniel Lezcano
cc6f6dd7d8 fix pivot umount algorithm
Make a function and fix bad parameter to umount.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-28 17:39:11 +02:00
Daniel Lezcano
b3df193c50 fix whitespace
Fix whitespace.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-28 11:49:25 +02:00
Cedric Le Goater
2ac29abe45 use ptmxmode mount option
Save one call by using the ptmxmode mount option.

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-27 16:16:30 +02:00
Daniel Lezcano
5332bb844a Don't close fd 0, fd 1
That breaks the reboot because when we reexec, fd 0 and fd 1 will be
closed and these one are created by lxc, not inherited. 

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-19 22:15:28 +02:00
Daniel Lezcano
0093bb8ced added locally modified files for broadcast support
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-18 19:13:26 +02:00
Ferenc Wagner
9232212afd fix typos in error messages
Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-12 23:47:55 +02:00
Ferenc Wagner
a91d897a7b remove pivotdir only if it was created by us
The removal does not account for possible leading path components that
were also created during creation of pivotdir.

Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-12 23:47:55 +02:00
Daniel Lezcano
b1789442d6 use defined rootfs mount point
As we defined a path where to mount the rootfs, we can use without
ambiguity because it is defined by default at compile time or by the
configuration.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-12 23:44:28 +02:00
Daniel Lezcano
33fcb7a047 encapsulate rootfs data in a structure
We have pivot_dir and rootfs defined in lxc_conf structure.
Let's encapsulate them in a rootfs structure.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-12 23:44:28 +02:00
Ferenc Wagner
25368b5249 no need to use a temporary directory for pivoting
Ferenc Wagner <wferi@niif.hu> writes:

> Daniel Lezcano <dlezcano@fr.ibm.com> writes:
>
>> Ferenc Wagner wrote:
>>
>>> Daniel Lezcano <daniel.lezcano@free.fr> writes:
>>>
>>>> Ferenc Wagner wrote:
>>>>
>>>>> While playing with lxc-start, I noticed that /tmp is infested by
>>>>> empty lxc-r* directories: [...] Ok, this name comes from lxc-rootfs
>>>>> in conf.c:setup_rootfs.  After setup_rootfs_pivot_root returns, the
>>>>> original /tmp is not available anymore, so rmdir(tmpname) at the
>>>>> bottom of setup_rootfs can't achieve much.  Why is this temporary
>>>>> name needed anyway?  Is pivoting impossible without it?
>>>>
>>>> That was put in place with chroot, before pivot_root, so the distro's
>>>> scripts can remount their '/' without failing.
>>>>
>>>> Now we have pivot_root, I suppose we can change that to something cleaner...
>>>
>>> Like simply nuking it?  Shall I send a patch?
>>
>> Sure, if we can kill it, I will be glad to take your patch :)
>
> I can't see any reason why lxc-start couldn't do without that temporary
> recursive bind mount of the original root.  If neither do you, I'll
> patch it out and see if it still flies.

For my purposes the patch below works fine.  I only run applications,
though, not full systems, so wider testing is definitely needed.

Thanks,
Feri.

>From 98b24c13f809f18ab8969fb4d84defe6f812b25c Mon Sep 17 00:00:00 2001
Date: Thu, 6 May 2010 14:47:39 +0200

That was put in place before lxc-start started using pivot_root, so
the distro scripts can remount / without problems.

Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-10 11:50:10 +02:00
Daniel LEzcano
0b7a835335 factor out pivot_root code
Clean up and factor a bit the pivot_root code.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-10 11:50:09 +02:00
Daniel Lezcano
1b09f2c057 fix pivot_root temporary directory
First of all, when trying to start a container in a read-only root
lxc-start complains:
  lxc-start: Read-only file system - can't make temporary mountpoint

This is in conf.c:setup_rootfs_pivot_root() function.  That function
uses optional parameter "lxc.pivotdir", or creates (and later removes)
a temporary directory for pivot_root.  Obviously there's no way to
create a directory in a read-only filesystem.

But lxc.pivotdir does not work either. In the function mentioned above
it is used with leading dot (eg. if I specify "lxc.pivotdir=pivot" in
the config file the pivot_root() syscall will be made to ".pivot" with
leading dot, not to "pivot"), but later on it is used without that dot,
and fails:

  lxc-start: No such file or directory - failed to open /pivot/proc/mounts
  lxc-start: No such file or directory - failed to read or parse mount list '/pivot/proc/mounts'
  lxc-start: failed to pivot_root to '/stage/t'

(that's with "lxc.pivotdir = pivot" in the config file).  After symlinking
pivot to .pivot it still fails:

  lxc-start: Device or resource busy - could not unmount old rootfs
  lxc-start: failed to pivot_root to '/stage/t'

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Reported-by: Michael Tokarev <mjt@tls.msk.ru>
2010-05-10 11:50:09 +02:00
Michel Normand
3cfc0f3a65 lxc: remove perror call in nl.c (V2)
There is only one such perror call, so remove it in nl.c

In this same patch, verify that all functions of nl.c and network.c
are reporting a -errno value in case of error;
value that is reported in lxc log by the callers in conf.c

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-29 10:03:59 +02:00
Daniel Lezcano
91480a0f0a restart the container at reboot
When the reboot is detected, reboot the container.
That needs to set all file descriptor opened by lxc-start
to be flagged with the close-on-exec flag, otherwise when
re-execing ourself, we inherit our own fd.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-08 09:44:23 +02:00
Daniel Lezcano
f78a1f32f4 fix when console is not specified
When no console is specified, do not try to setup the console.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-02 23:37:42 +02:00
Michel Normand
adc1e6c25d typo in error message
Wrong variable.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-03-22 11:08:34 +01:00
Daniel Lezcano
28a4b0e55c open the console later
Open the console at the setup time, otherwise the openeded
file descriptor will be considered as an inherited fd and the
startup will fail.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-03-22 11:08:34 +01:00
Daniel Lezcano
7fef7a06d8 fix network devices cleanup on error
Delete the network devices when an error occurs before they are moved
to the network namespace (network namespace destruction triggers the
network devices deletion). Otherwise they stay in the system.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-25 10:24:13 +01:00
Daniel Lezcano
c08556c6ec use lazy umount when umount returns EBUSY
When the umount fails, we force the umount and make the mount point
unaccessible by using a lazy umount.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:43 +01:00
Daniel Lezcano
63376d7db3 allocate a console to be proxied
The actual behaviour of the console is messy as:
 * it relies on a heuristic (tty or not, rootfs or not, etc ...)
 * the container init stole the tty and we lose the control

The following patch:
 * allocates a tty
 * maps this tty to the container console
 * proxy the io from the console to the file specified in the configuration
 lxc.console=<file>

That allows to specify a file, a fifo, a $(tty), and can be extended with an
uri like file://mypath, net://1.2.3.4:1234, etc ...
That solves the problem with the heuristic and the container does no longer stole
our current tty.

Note by default, the console output will go to a blackhole if no configuration is
specified making the container showing nothing.

In order to access the console from the tty, use

 lxc-start -n foo -s lxc.console=$(tty)

I propose the make the container to daemonize by default now.

I tried the following:

 in a shell:
  touch /var/lib/lxc/foo/console
  tail --retry -f /var/lib/lxc/foo/console
 in another shell:
  lxc-start -n foo -s lxc.console=/var/lib/lxc/foo/console

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:43 +01:00
Daniel Lezcano
246541036c rename network type enum
Use a prefixed enum to avoid conflict later.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:43 +01:00
Daniel Lezcano
236087a6c8 fix empty network namespace
When there is an empty network namespace, we must not move the
network device.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:42 +01:00
Daniel Lezcano
7df119eeae unmount failure is not fatal
There are several cases where the system can no longer access a mount
point or a mount point configuration makes the algorithm bogus.

For example, we mount something and then we chroot, the mount information
will give an unaccessible path and the container won't be able to start
because this mount point will be unaccessible. But if it's the case, then
we can just warn and continue running the container.

Another case is the path to a mount point is not accessible because there
is another mount point on top of it hiding the mount point. So the umount
will fail and the container won't start.

Easy to reproduce:

mkdir -p /tmp/dir1/dir2
mount -t tmpfs tmpfs /tmp/dir1/dir2
mount -t tmpfs tmpfs /tmp/dir1

So can we just ignore the error when unmounting and continue to the list again
and again until it shrinks.

At the end, we just display the list of the unmounted points.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-22 11:29:10 +01:00
Michel Normand
b09094da2d Add some define to compile on rhel5u1
the last patch commit 81810dd120
make lxc to not compile anymore on rhel5u1

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-22 11:21:46 +01:00
Daniel Lezcano
1e11be345d fix tab vs space indentation
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-21 15:15:26 +01:00
Daniel Lezcano
81810dd120 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.

Example:

lxc.cap.drop = sys_chroot
lxc.cap.drop = mknod
lxc.cap.drop = sys_module

or specify in a single line:

lxc.cap.drop = sys_chroot mknod sys_module

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>
2010-01-21 15:06:42 +01:00
Clement Calmels
2382ecffdb 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>
2010-01-18 23:08:12 +01:00
Cedric Le Goater
7a7ff0c6fb fix lxc_file_cb prototype
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-13 18:51:15 +01:00
Daniel Lezcano
932b94f5de Remove dead code
Remove dead code.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-08 15:19:19 +01:00
Michael Holtz
bf601689a9 use pivot_root instead of chroot
lxc currently does a chroot into the target rootfs. chroot is insecure and
can easily be broken, as demonstrated here:

| root@synergy:~# touch /this_is_the_realrootfs_ouch
| # touch /container/webhost/this_is_the_container
| # lxc-start -n webhost /bin/sh
| # ls this*
| this_is_the_container
| # ./breakchroot
| # ls this*
| this_is_the_realrootfs_ouch

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. 

Example:

| root@synergy:~# grep pivotdir /var/lib/lxc/webhost/config
| lxc.pivotdir = /oldrootfs
| root@synergy:~# ls -lad /container/webhost/oldrootfs
| drwxr-xr-x 2 root root 4096 2010-01-02 03:59 /container/webhost/oldrootfs
| root@synergy:~# lxc-start -n webhost /bin/sh
| # mount -t proc proc /proc
| # cat /proc/mounts
| rootfs / rootfs rw 0 0
| /dev/root / ext3 rw,relatime,errors=remount-ro,data=writeback 0 0
| devpts /dev/console devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
| proc /proc proc rw,relatime 0 0
| # ls this*   
| this_is_the_container
| # ./breakchroot
| # ls this*
| this_is_the_container

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Michael Holtz <lxc@my.fqdn.org>
2010-01-08 14:34:13 +01:00
Michel Normand
7b379ab3a5 lxc: avoid memory corruption on ppc and s390 V4
conf object is on stack and is used in forked process.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-08 14:34:13 +01:00
Daniel Lezcano
e892973e39 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>
2009-12-28 22:10:11 +01:00
Daniel Lezcano
1d6b1976a0 fix mount entry typo
Added missing carriage-return when adding a new entry.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-12-18 14:19:59 +01:00
Jamal Hadi Salim
f6cc1de1a9 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>
2009-12-15 10:14:27 +01:00
Jamal Hadi Salim
26c390288b 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>
2009-12-15 10:14:27 +01:00
Sven Wegener
e4e7d59db8 use correct number of ttys during setup
commit 985d15b106 "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>
2009-11-26 16:46:23 +01:00
Michael Tokarev
6ab9ab6d08 minor cleanups for instanciate_veth()
the same cleanup as in instanciate_macvlan(). Just makes code
shorter and less "jumpy" (as with goto back)

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-11-26 16:46:23 +01:00
Michael Tokarev
8634bc197f 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>
2009-11-26 16:46:23 +01:00
Michael Tokarev
985d15b106 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>
2009-11-24 09:47:27 +01:00
Michael Tokarev
d957ae2d51 check if lxc.netdev.link is set for macvlan
Ensure that lxc.netdev.link is specified for macvlan interfaces,
since it's required.

While at it, simplify logic in instanciate_macvlan():
remove unnecessary-complicating goto statements (we only
need to perform a cleanup in one place)

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-11-20 15:01:31 +01:00
Michael Tokarev
734915aca1 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>
2009-11-20 15:01:31 +01:00
Michael Tokarev
9d0834025e 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>
2009-11-19 15:06:02 +01:00
Cedric Le Goater
00b3c2e284 cleanup <lxc/lxc.h>
<lxc/lxc.h>  should only include what is needed. This patch removes
all useless headers from lxc.h and fixed other .c files.

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-11-17 10:56:23 +01:00
Michel Normand
e7938e9ee3 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>
2009-11-13 11:48:29 +01:00
Michel Normand
88329c69cd stop config reading if cgroup setting failed
in today's code lxc-start to not stop if setup_cgroup is detecting an error

Signed-off-by: Michel Normand <michel_mno@laposte.net>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-11-13 11:48:29 +01:00
Daniel Lezcano
ab2d32f88c 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>
2009-11-13 11:48:29 +01:00
Andrian Nord
7fa9074f13 ipv6 interfaces added with /0 prefix
Greetings, I've found a small typo into src/lxc/conf.c that leads to
nulled prefix for ipv6 addresses.

Signed-off-by: Andrian Nord <NightNord@gmail.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-11-09 10:43:03 +01:00
Daniel Lezcano
881450bbed use config.h to define the lxcpath and co
Instead of passing the LXCPATH definition in the compiler
command line, use configure.ac to define the value in the config.h
file and include this file where it is needed.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-22 15:33:40 +02:00
Daniel Lezcano
d685aa8049 clean up and factor out some code
Factor out some code and fix a memory corruption when
dupping the arguments.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-12 22:02:06 +02:00
Daniel Lezcano
a79cf70427 remove configure dead code
Remove the old configuration remaining code.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-12 22:02:06 +02:00
Daniel Lezcano
5e4a62bf32 fix tty creation using confdir
tty_create uses the old conf directory, fixing this.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-09 11:38:39 +02:00
Daniel Lezcano
5f4535a3d9 fix netdev structure vs network structure
The netdev vs network structure is not well defined. Fix that.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-09 11:38:39 +02:00
Daniel Lezcano
4bf1968d3c Factor out some network code
We can factor out the "ip addr add"

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-09 11:38:39 +02:00
Daniel Lezcano
82d5ae15e7 Use the configuration structure for the network
We don't want to use anymore the configuration directory,
let's use the configuration structure.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-09 11:38:39 +02:00
Daniel Lezcano
571e6ec89e Move configuration info to the structure
Move configuration informations from the handler structure to
the configuration structure.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-09 11:38:39 +02:00
Daniel Lezcano
88d5514d16 Move the configuration file to the start function
We want to store more information in the configuration structure,
especially the ttys.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-09 11:38:39 +02:00
Daniel Lezcano
102a53038a use the configuration structure for the cgroup
Do not use the directory configuration

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-09 11:38:39 +02:00
Daniel Lezcano
52e3595723 use the configuration structure for the tty
Do not use the directory configuration

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-09 11:38:39 +02:00
Daniel Lezcano
1bc60a65c9 use configuration structure for the mount points
Do not use the directory configuration for the mount points.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-09 11:38:39 +02:00
Daniel Lezcano
d852c78cf0 Use the configuration structure for pts
Avoid to use the directory structure.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-09 11:38:38 +02:00
Daniel Lezcano
4e5440c654 use the configuration structure to setup the utsname
Use the configuration structure, not the directory configuration

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-09 11:38:38 +02:00
Daniel Lezcano
c69bd12f88 use the configuration structure for setting up the rootfs
use the configuration structure for setting up the rootfs

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-09 11:38:38 +02:00
Daniel Lezcano
ecb0e51b0c use the configuration to check if a resource is enabled
Remove the usage of the directory config for the setup and use the
configuration structure instead.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-09 11:38:38 +02:00
Daniel Lezcano
df83bf6f97 Read the config file at restart
This patch makes the configuration to read the configuration
file in order to pass the configuration to the different functions.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-09 11:38:38 +02:00
Michel Normand
cfd1dc0932 keep rcfile for lxc-execute as already done for lxc-create
The code previously added in lxc-create with
commit d7efa8fcbf
is also required in lxc-execute.
So make this code common for the two callers.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-10-07 10:05:39 +02:00
Daniel Lezcano
1ac470c02a add some traces in the code for the logger
Add some traces in the code, so we are able to follow the execution
of the start command with the logger.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-07-24 15:25:45 +02:00
Daniel Lezcano
f5d186114c fix cgroup trace
The trace is displayed either if the setting fails, change that by
displaying the trace when the setting is successful.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-07-24 15:25:44 +02:00
Daniel Lezcano
cd54d859da make use of the logging facility and add some traces
Now we have a logging facility, let's use it and add some traces in
the code.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-07-22 19:39:17 +02:00
Daniel Lezcano
018ef5201b choose a default network interface name
When no name is specified in the configuration file for an interface,
let the system to choose one nice name like "eth".

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-05-28 12:10:51 +02:00
Daniel Lezcano
34c66a6980 Remove old code to destroy the network
Removed this unused code.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-05-28 12:10:50 +02:00
Daniel Lezcano
64e1ae63eb make use of the copy file function
Now we have specific function to copy the files, make use of it
and remove the old code.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-05-28 12:10:50 +02:00
Michel Normand
95b5ffafae remove LXC_ERROR_* usage in src/lxc/conf.c as not required
This is useless because error is already reported by the functions

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-05-18 22:30:39 +02:00
Michel Normand
8b92dc3ab6 change lxc_cgroup_set/get functions to return -1
and report error message as soon as detected error in these two functions

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Michel Normand <normand@fr.ibm.com>
2009-05-14 16:27:29 +02:00
Michel Normand
3ab87b66af remove fprintf to stderr and replace by ERROR call when needed
do it in all cli, except:
* the usage functions that will be removed by another patch
* the lxc_init that need more work
* the lxc_priority that is not used anymore

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-05-14 15:52:03 +02:00
Cedric Le Goater
36eb9bdef1 lxc: use new logging system
This patch defines a new log category in each file using logging and
replaced the former logging routines with the new ones.

Signed-off-by: Cedric Le Goater <legoater@free.fr>
Acked-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-04-21 21:51:13 +02:00
Ryousei Takano
998ac6763f Add support for various mount options
This patch adds support for various mount options.  It is also able to pass extra 
mount option data to mount(2).  For example, it allows users to mount aufs file 
system at lxc_start time.

See the thread
	http://sourceforge.net/mailarchive/forum.php?thread_name=E6D98D6C-F633-419A-9424-F24EBB3E11D9%40aist.go.jp&forum_name=lxc-devel
for details.

Signed-off-by: Ryousei Takano <takano-ryousei@aist.go.jp>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-04-20 22:10:59 +02:00
Môshe van der Sterre
b035ad62e6 prevent tty fd to be inherited in the container
Set the close on exec flag on the pty fd so they are automatically
closed when execing the container.

Signed-off-by: Môshe van der Sterre <me@moshe.nl>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2009-04-20 22:10:59 +02:00
Daniel Lezcano
089cd8b878 move lxc_conf_init to conf.c
Changed the struct lxc_conf initialization function to the
right place.

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
2009-03-30 14:02:19 +02:00
Daniel Lezcano
13954cce63 cleanup conf.h
Rename lxc_conf.h to conf.h

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
2009-03-30 14:02:19 +02:00