]> git.proxmox.com Git - mirror_lxc.git/log
mirror_lxc.git
14 years agoadd a configure option to set a rootfs mount point
Daniel Lezcano [Wed, 12 May 2010 21:44:28 +0000 (23:44 +0200)]
add a configure option to set a rootfs mount point

Add a configure option to set a mount point path when using a rootfs,
that will replace the actual behavior which creates uneeded /tmp/lxc**
directories.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agowhitespace cleanup in configure.ac
Daniel Lezcano [Wed, 12 May 2010 21:44:28 +0000 (23:44 +0200)]
whitespace cleanup in configure.ac

Mindless changes by removing whitespace.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agono need to use a temporary directory for pivoting
Ferenc Wagner [Mon, 10 May 2010 09:50:10 +0000 (11:50 +0200)]
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>
14 years agoMake dynamic busybox supported
Daniel Lezcano [Mon, 10 May 2010 09:50:10 +0000 (11:50 +0200)]
Make dynamic busybox supported

Bind mount host library path.
Weird but some distro provide busybox as a dynamically linked binary.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agomake lxc-checkconfig more explicit
Guillaume Zitta [Mon, 10 May 2010 09:50:10 +0000 (11:50 +0200)]
make lxc-checkconfig more explicit

With a friend, we installed lxc on his server.
We spend 1 hour on the kernel config because we didn't knew :
- that lxc-checkconfig is a bash script and it can check a config before
running it
- which kernel config item whas not good
- that CONFIG_SECURITY_FILE_CAPABILITIES is obsolete since 2.6.33

So, here is a patch for lxc-checkconfig that could save time for lxc newbies

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Modified-by: Daniel Lezcano <daniel.lezcano@free.fr>
Signed-off-by: Guillaume Zitta <lxc@zitta.fr>
14 years agoadd missing /dev/pts directory
Daniel Lezcano [Mon, 10 May 2010 09:50:10 +0000 (11:50 +0200)]
add missing /dev/pts directory

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoupdate INSTALL file
Daniel Lezcano [Mon, 10 May 2010 09:50:09 +0000 (11:50 +0200)]
update INSTALL file

"lxc configure does not exist. You need to run ./autogen.sh to create it.
I think it needs to either be documented in INSTALL or you provide ./configure"

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Reported-by: Jamal Hadi Salim <hadi@cyberus.ca>
14 years agofactor out pivot_root code
Daniel LEzcano [Mon, 10 May 2010 09:50:09 +0000 (11:50 +0200)]
factor out pivot_root code

Clean up and factor a bit the pivot_root code.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agofix pivot_root temporary directory
Daniel Lezcano [Mon, 10 May 2010 09:50:09 +0000 (11:50 +0200)]
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>
14 years agoFix console infinite loop
Daniel Lezcano [Mon, 10 May 2010 09:50:09 +0000 (11:50 +0200)]
Fix console infinite loop

When the client console exits, the mainloop goes in an infinite loop
as the handler is not removed and we are notified from the disconnection
indefinitely.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agomore robustness against SIGCHLD
Daniel Lezcano [Fri, 7 May 2010 12:37:05 +0000 (14:37 +0200)]
more robustness against SIGCHLD

If the SIGCHLD is sent from a process different from the container's init
process we ignore it, otherwise we finish to wait it.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agodo not exit mainloop when child is stopped
Daniel Lezcano [Fri, 7 May 2010 12:37:05 +0000 (14:37 +0200)]
do not exit mainloop when child is stopped

When the init container is stopped, we don't check this condition
and we assume the child exited and we wait indefinitely for the child
to exit while this one is stopped.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoadd fd to ignore to lxc_check_inherited function
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
add fd to ignore to lxc_check_inherited function

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agolxc: move lxc_unlink_nsgroup out of lxc_fini
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
lxc: move lxc_unlink_nsgroup out of lxc_fini

to be able to have lxc_fini symetric with lxc_init

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agolxc: child failing before container rename
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
lxc: child failing before container rename

do the same checking as already done in lxc/restart.c

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agolxc: remove unused lxc_bridge_detach
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
lxc: remove unused lxc_bridge_detach

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agolxc: remove perror call in nl.c (V2)
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
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>
14 years agolxc: introduce lxc-kill command (v4)
gkurz@linux.vnet.ibm.com [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
lxc: introduce lxc-kill command (v4)

lxc-kill send a signal to the process 1 of the container.

If this command is used on an application container ran by
lxc-execute, the lxc-init will receive the signal and will forward it to
the process 2 which is the command specified in the command line.

Signed-off-by: Greg Kurz <gkurz@fr.ibm.com>
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoman update lxc.conf
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
man update lxc.conf

reformating given examples
and add reference to examples directory.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoman update lxc-create lxc-destroy
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
man update lxc-create lxc-destroy

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoman update lxc-execute and lxc-start (V2)
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
man update lxc-execute and lxc-start (V2)

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoman update lxc
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
man update lxc

update lxc man page to better explain:
* the notions of persistent and volatil container.
* the difference between lxc-execute and lxc-start commands

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agolxc: add usage and help to lxc-netstat (V2)
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
lxc: add usage and help to lxc-netstat (V2)

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agolxc: lxc-unshare to remove its /cgroup/<pid> (V3)
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
lxc: lxc-unshare to remove its /cgroup/<pid> (V3)

this is required to avoid to fill /cgroup
with pid number each time lxc-unshare is called.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoremove unused _config_console function
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
remove unused _config_console function

it's usage was removed by patch
28a4b0e55c659428bc8f495fde2e774fbd0fb03c
"open the console later"

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoget_init_pid moved to lxc/commands.c
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
get_init_pid moved to lxc/commands.c

as will be used later on in other patches.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoreport error if statefd parm is not a digit
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
report error if statefd parm is not a digit

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoadd --statefd option to lxc-checkpoint/restart
Michel Normand [Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)]
add --statefd option to lxc-checkpoint/restart

This new option is to have user to pass a fd
in place of statefile name.

Simple usage with file open in bash:
===
$rm -f *.log; lxc-execute -n foo -- pi1  44444
$rm -rf /tmp/sf; lxc-checkpoint -n foo -k --statefd 3 3>/tmp/sf && lxc-restart -n bar --statefd 4 4</tmp/sf
===

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoclose fd 0 and 1 where not required
Michel Normand [Thu, 29 Apr 2010 08:03:58 +0000 (10:03 +0200)]
close fd 0 and 1 where not required

the fd 0,1 and 2 are still inherited
and we only need the fd 2 (stderr) after
the start/restart of the application.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoavoid compile warning lxc_init.c
Michel Normand [Thu, 29 Apr 2010 08:03:58 +0000 (10:03 +0200)]
avoid compile warning lxc_init.c

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoFail gracefully with attach
Daniel Lezcano [Thu, 8 Apr 2010 07:44:23 +0000 (09:44 +0200)]
Fail gracefully with attach

Fail when we try to attach to an non existing container

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agochange to the same directory when attaching
Daniel Lezcano [Thu, 8 Apr 2010 07:44:23 +0000 (09:44 +0200)]
change to the same directory when attaching

This patch will try to change the default "/" directory to the
directory we were before attaching. In order to work correctly,
the path has to exist in the container, that makes sense with a
shared file system without rootfs.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agofork/exec after attach
Daniel Lezcano [Thu, 8 Apr 2010 07:44:23 +0000 (09:44 +0200)]
fork/exec after attach

The command to attach has to be fork/exec.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agorestart the container at reboot
Daniel Lezcano [Thu, 8 Apr 2010 07:44:23 +0000 (09:44 +0200)]
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>
14 years agoshutdown the container when powering off the container
Daniel Lezcano [Thu, 8 Apr 2010 07:44:23 +0000 (09:44 +0200)]
shutdown the container when powering off the container

This patch allows to shutdown the container when the system
is powered off in the container.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoStore the container name in the handler
Daniel Lezcano [Thu, 8 Apr 2010 07:44:23 +0000 (09:44 +0200)]
Store the container name in the handler

Store the container in the handler, so it is accessible
everywhere.

Signed-off-by: Daniel Lezcano <dlezcan@fr.ibm.com>
14 years agocount the number of tasks in the container
Daniel Lezcano [Thu, 8 Apr 2010 07:44:23 +0000 (09:44 +0200)]
count the number of tasks in the container

This patch adds a function to count the number of tasks in the
container. The result is not reliable as it may change with a fork
or an exit, but in some cases, for example, there is only one task, or
the container is frozen, the result is accurate.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agofix when console is not specified
Daniel Lezcano [Fri, 2 Apr 2010 21:37:42 +0000 (23:37 +0200)]
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>
14 years agolxc: add --statefile opt to lxc-checkpoint/restart
Michel Normand [Fri, 2 Apr 2010 16:45:47 +0000 (18:45 +0200)]
lxc: add --statefile opt to lxc-checkpoint/restart

based on patch from: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>

but also:
* remove the deprecated --directory one.
* change liblxc api of checkpoint/restart to use fd and not string.
* explicitely report error messages for the checkpoint/restart stub functions.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agofix lxc-setcap script for lxc-attach
Daniel Lezcano [Mon, 22 Mar 2010 10:08:34 +0000 (11:08 +0100)]
fix lxc-setcap script for lxc-attach

Fix type and missing capability.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agodo not use logfile in lxc_init (V2)
Michel Normand [Mon, 22 Mar 2010 10:08:34 +0000 (11:08 +0100)]
do not use logfile in lxc_init (V2)

The log file in lxc-init is quite useless as the code is trivial.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agotypo in error message
Michel Normand [Mon, 22 Mar 2010 10:08:34 +0000 (11:08 +0100)]
typo in error message

Wrong variable.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agofix lxc-attach returned error
Daniel Lezcano [Mon, 22 Mar 2010 10:08:34 +0000 (11:08 +0100)]
fix lxc-attach returned error

When we try to attach to a container belonging to another user than us,
the command fails as expected but the return code is wrong, so we have
an "unknown error" instead of "permission denied".

The culprit is:

-                     strerror(command.answer.ret));
+                     strerror(-command.answer.ret));

The rest of the code is indentation without code impact.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Michel Normand <normand@fr.ibm.com>
14 years agolxc: enter / exec a command inside a container V2
Daniel Lezcano [Mon, 22 Mar 2010 10:08:34 +0000 (11:08 +0100)]
lxc: enter / exec a command inside a container V2

This patch allows to execute a command or enter inside the container:
  * lxc-attach -n <name> [command]

If the <command is not specified>, the lxc-attach will retrieve your uid
and get your shell name and exec it in the container.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoopen the console later
Daniel Lezcano [Mon, 22 Mar 2010 10:08:34 +0000 (11:08 +0100)]
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>
14 years agolxc: forbid open fds upon startup
Cedric Le Goater [Mon, 22 Mar 2010 10:08:34 +0000 (11:08 +0100)]
lxc: forbid open fds upon startup

This patch modifies the startup of a container to forbid opened
fds, unless these are stdios.

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
14 years agofix kill -1 process
Daniel Lezcano [Fri, 26 Feb 2010 20:12:31 +0000 (21:12 +0100)]
fix kill -1 process

In the process of rollbacking, the handler->pid is not set
we must not kill it. Otherwsise, kill(-1, SIGKILL), ouch ! ...

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoadd console.h to dist file
Daniel Lezcano [Fri, 26 Feb 2010 20:12:31 +0000 (21:12 +0100)]
add console.h to dist file

Add the console.h file in order to compile the dist file.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agofix network devices cleanup on error
Daniel Lezcano [Thu, 25 Feb 2010 09:24:13 +0000 (10:24 +0100)]
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>
14 years agofix function prototype implementation
Daniel Lezcano [Thu, 25 Feb 2010 09:24:13 +0000 (10:24 +0100)]
fix function prototype implementation

Fix inconsistent function definition regarding the headers.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agodelete network devices by index
Daniel Lezcano [Thu, 25 Feb 2010 09:24:12 +0000 (10:24 +0100)]
delete network devices by index

Add a function to delete the network device by its index.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoadd missing cgroup include
Daniel Lezcano [Wed, 24 Feb 2010 15:24:55 +0000 (16:24 +0100)]
add missing cgroup include

Fix the warning:

start.c: In function â€˜lxc_fini’:
start.c:250: warning: implicit declaration of function â€˜lxc_unlink_nsgroup’
start.c: In function â€˜lxc_spawn’:
start.c:380: warning: implicit declaration of function â€˜lxc_rename_nsgroup’

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoAdd missing stat.h include to start.c
Silas Sewell [Wed, 24 Feb 2010 15:24:55 +0000 (16:24 +0100)]
Add missing stat.h include to start.c

The patch fixes a build error on the devel version of Fedora.

Signed-off-by: Silas Sewell <silas@sewell.ch>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agouse lazy umount when umount returns EBUSY
Daniel Lezcano [Wed, 24 Feb 2010 09:57:43 +0000 (10:57 +0100)]
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>
14 years agofix no rootfs no console
Daniel Lezcano [Wed, 24 Feb 2010 09:57:43 +0000 (10:57 +0100)]
fix no rootfs no console

When there is no rootfs, don't create a console.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoset terminal settings when console is a tty
Daniel Lezcano [Wed, 24 Feb 2010 09:57:43 +0000 (10:57 +0100)]
set terminal settings when console is a tty

As the console output can be a tty, we want to have the terminal to
be set as a specific manner to not echo and receive signals from the
keyboard.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoallocate a console to be proxied
Daniel Lezcano [Wed, 24 Feb 2010 09:57:43 +0000 (10:57 +0100)]
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>
14 years agorename network type enum
Daniel Lezcano [Wed, 24 Feb 2010 09:57:43 +0000 (10:57 +0100)]
rename network type enum

Use a prefixed enum to avoid conflict later.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoFix header inclusion
Daniel Lezcano [Wed, 24 Feb 2010 09:57:43 +0000 (10:57 +0100)]
Fix header inclusion

No need to include the lxc_conf structure definition, a forward
declaration is enough.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agouse a mainloop for the console
Daniel Lezcano [Wed, 24 Feb 2010 09:57:42 +0000 (10:57 +0100)]
use a mainloop for the console

Use the mainloop to manage io of the console.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agofactor-out-console code
Daniel Lezcano [Wed, 24 Feb 2010 09:57:42 +0000 (10:57 +0100)]
factor-out-console code

Factor out the console code and encapsulate the code in
functions.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agofix empty network namespace
Daniel Lezcano [Wed, 24 Feb 2010 09:57:42 +0000 (10:57 +0100)]
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>
14 years agofix compilation warning
Daniel Lezcano [Wed, 24 Feb 2010 09:57:42 +0000 (10:57 +0100)]
fix compilation warning

Add missing include

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agofix cpuset configuration with smp only
Daniel Lezcano [Wed, 24 Feb 2010 09:57:42 +0000 (10:57 +0100)]
fix cpuset configuration with smp only

Do not check CPUSET configuration when SMP is not enabled.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoversion 0.6.5
Daniel Lezcano [Fri, 22 Jan 2010 10:45:11 +0000 (11:45 +0100)]
version 0.6.5

Increment to 0.6.5 version.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agounmount failure is not fatal
Daniel Lezcano [Fri, 22 Jan 2010 10:29:10 +0000 (11:29 +0100)]
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>
14 years agocompilation warning in confile.c
Michel Normand [Thu, 21 Jan 2010 16:21:34 +0000 (17:21 +0100)]
compilation warning in confile.c

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoAdd some define to compile on rhel5u1
Michel Normand [Thu, 21 Jan 2010 16:21:33 +0000 (17:21 +0100)]
Add some define to compile on rhel5u1

the last patch commit 81810dd120291b78daf7c6833e6fcbca0289aad5
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>
14 years agofix tab vs space indentation
Daniel Lezcano [Thu, 21 Jan 2010 14:15:26 +0000 (15:15 +0100)]
fix tab vs space indentation

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agodrop capabilities
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.

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>
14 years agoadd extra line in the busybox script
Daniel Lezcano [Thu, 21 Jan 2010 13:45:00 +0000 (14:45 +0100)]
add extra line in the busybox script

A mindless change.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agotypo in restart and checkpoint
Michel Normand [Thu, 21 Jan 2010 13:34:08 +0000 (14:34 +0100)]
typo in restart and checkpoint

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agolxc-create to run even if not in PATH
Michel Normand [Thu, 21 Jan 2010 13:34:08 +0000 (14:34 +0100)]
lxc-create to run even if not in PATH

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoavoid too long line in lxc-busybox.in
Michel Normand [Thu, 21 Jan 2010 13:34:08 +0000 (14:34 +0100)]
avoid too long line in lxc-busybox.in

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoadd --define to restart V2
Michel Normand [Thu, 21 Jan 2010 13:34:08 +0000 (14:34 +0100)]
add --define to restart V2

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agolxc: typo in scripts/lxc-debian.in
Michel Normand [Tue, 19 Jan 2010 17:45:10 +0000 (18:45 +0100)]
lxc: typo in scripts/lxc-debian.in

warning with git am, white before tab correction

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agolxc: remove useless check
Greg Kurz [Tue, 19 Jan 2010 17:45:13 +0000 (18:45 +0100)]
lxc: remove useless check

The handler argument to lxc_fini() is never null.

Signed-off-by: Greg Kurz <gkurz@fr.ibm.com>
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agolxc: fix double-close in lxc_[re]spawn() abort path
Greg Kurz [Tue, 19 Jan 2010 17:45:15 +0000 (18:45 +0100)]
lxc: fix double-close in lxc_[re]spawn() abort path

sv[0] has already been closed when reaching out_abort label.

Signed-off-by: Greg Kurz <gkurz@fr.ibm.com>
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agolxc: add capabilities for C/R
Michel Normand [Tue, 19 Jan 2010 17:45:16 +0000 (18:45 +0100)]
lxc: add capabilities for C/R

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoRemove useless lines
Clement Calmels [Tue, 19 Jan 2010 17:45:12 +0000 (18:45 +0100)]
Remove useless lines

Signed-off-by: Clement Calmels <clement.calmels@fr.ibm.com>
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agolxc: some goto clarification
Greg Kurz [Tue, 19 Jan 2010 17:45:14 +0000 (18:45 +0100)]
lxc: some goto clarification

It makes sense to use goto when there's some rollback work to be done.
And it's nice for code clarity to add an explicit suffix to goto labels.

Signed-off-by: Greg Kurz <gkurz@fr.ibm.com>
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agolxc: typo white space src/lxc/network.c
Michel Normand [Tue, 19 Jan 2010 17:45:11 +0000 (18:45 +0100)]
lxc: typo white space src/lxc/network.c

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoAdded -e to lxc-console to change command character (defaults to '^a')
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>
14 years agoremove warning in parse.c:80
Clement Calmels [Mon, 18 Jan 2010 22:08:12 +0000 (23:08 +0100)]
remove warning in parse.c:80

Signed-off-by: Clement Calmels <clement.calmels@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agouse getline instead of fgets
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>
14 years agofree struct dirent **namelist
Clement Calmels [Mon, 18 Jan 2010 22:08:12 +0000 (23:08 +0100)]
free struct dirent **namelist

Correct the way the struct dirent **namelist structure is freed.

Signed-off-by: Clement Calmels <clement.calmels@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agofix compilation warning
Daniel Lezcano [Thu, 14 Jan 2010 06:43:18 +0000 (07:43 +0100)]
fix compilation warning

lxc_config_define_load should an int

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agolxc: add --define to start
Cedric Le Goater [Thu, 14 Jan 2010 06:43:18 +0000 (07:43 +0100)]
lxc: add --define to start

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoadd --define to restart
Cedric Le Goater [Thu, 14 Jan 2010 06:43:18 +0000 (07:43 +0100)]
add --define to restart

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoadd --define to execute
Cedric Le Goater [Thu, 14 Jan 2010 06:43:18 +0000 (07:43 +0100)]
add --define to execute

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoadd interface to assign configuration variable from the command line
Cedric Le Goater [Thu, 14 Jan 2010 06:43:17 +0000 (07:43 +0100)]
add interface to assign configuration variable from the command line

lxc_config_define_add() and lxc_config_define_load() define
the interface to load a list of KEY=VAL buffers in the configuration

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoremove unused variable
Daniel Lezcano [Wed, 13 Jan 2010 17:51:16 +0000 (18:51 +0100)]
remove unused variable

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoexport lxc_config_readline()
Cedric Le Goater [Wed, 13 Jan 2010 17:51:16 +0000 (18:51 +0100)]
export lxc_config_readline()

lxc_config_readline() will be used to parse configuration variable
assigned from the command line with --define

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoSimplify mainloop
Clement Calmels [Wed, 13 Jan 2010 17:51:16 +0000 (18:51 +0100)]
Simplify mainloop

Just use a list instead of array for dynamically allocated stuff. It's
more appropriated.

Signed-off-by: Clement Calmels <clement.calmels@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agoDon't mess descr->ev
Clement Calmels [Wed, 13 Jan 2010 17:51:16 +0000 (18:51 +0100)]
Don't mess descr->ev

A simple test program to show up the issue:

-8<---
#include <stdio.h>
#include <unistd.h>

#include "mainloop.h"

struct lxc_epoll_descr loop;

int cb1(int fd, void *data, struct lxc_epoll_descr *descr)
{
fprintf(stderr, "cb1\n");
        return 1;
}

int cb2(int fd, void *data, struct lxc_epoll_descr *descr)
{
fprintf(stderr, "cb2\n");
        return 1;
}

int main(int argc, char *argv[])
{
        int ret;
        int fds[2];

        ret = pipe(fds);
        if (ret) {
                perror("pipe:");
                return -1;
        }

        ret = lxc_mainloop_open(&loop);
        if (ret) {
                fprintf(stderr, "lxc_mainloop_open: %d\n", ret);
                return -1;
        }

        ret = lxc_mainloop_add_handler(&loop, fds[1], cb1, NULL);
        if (ret) {
                fprintf(stderr, "lxc_mainloop_add_handler(fds[1]): %d\n", ret);
                return -1;
        }

        ret = lxc_mainloop_add_handler(&loop, fds[0], cb2, NULL);
        if (ret) {
                fprintf(stderr, "lxc_mainloop_add_handler(fds[0]): %d\n", ret);
                return -1;
        }

        write(fds[1], &ret, sizeof(ret));

        ret = lxc_mainloop(&loop);
        if (ret) {
        fprintf(stderr, "lxc_mainloop: %d\n", ret);
return -1;
        }

        ret = lxc_mainloop_close(&loop);
        if (ret) {
                fprintf(stderr, "lxc_mainloop_close: %d\n", ret);
                return -1;
        }

        return 0;
}

Compile and run:
$ gcc test.c -o test -I ./src/lxc/ ./src/lxc/liblxc_so-mainloop.o && ./test
cb2

14 years agoIf epoll_ctl fails, the descr->ev array isinconsistent
Clement Calmels [Wed, 13 Jan 2010 17:51:16 +0000 (18:51 +0100)]
If epoll_ctl fails, the descr->ev array isinconsistent

Let's take an example:

fd = open(..) /* fd = 3 for example */

lxc_mainloop_add_handler(descr, fd, cb1, data1) fails.

the program take care of the error, it closes the fd

Later, reopen a fd (get 3 for again)

lxc_mainloop_add_handler(desc, fd, cb2, data2) is ok.

When something happen on fd, cb1 with data1 will be called instead of
cb2 with data2, because descr->ev contains 2 entries for fd == 3.

Signed-off-by: Clement Calmels <clement.calmels@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agofix lxc_mainloop_del_handler
Clement Calmels [Wed, 13 Jan 2010 17:51:16 +0000 (18:51 +0100)]
fix lxc_mainloop_del_handler

Fix bad index.

Signed-off-by: Clement Calmels <clement.calmels@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agouse different log categories in commands
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>
14 years agofix lxc_file_cb prototype
Cedric Le Goater [Wed, 13 Jan 2010 17:51:15 +0000 (18:51 +0100)]
fix lxc_file_cb prototype

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
14 years agofix bad docbook syntax in lxc-create.sgml.in
Daniel Lezcano [Fri, 8 Jan 2010 14:19:20 +0000 (15:19 +0100)]
fix bad docbook syntax in lxc-create.sgml.in

Removed extra </command>.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>