Commit Graph

284 Commits

Author SHA1 Message Date
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