Commit Graph

726 Commits

Author SHA1 Message Date
Michel Normand
b8da590f0e lxc-kill man update about SIGSTOP and SIGKILL
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-27 14:26:09 +02:00
Michel Normand
d0817ec91a remove obsolete lxc_utils.h
This file is a duplicate of utils.h

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-27 12:17:40 +02:00
clg@linux.vnet.ibm.com
0af683cf29 drop capabilities in lxc-init (V2)
capabilities are reseted just after the filesystem is mounted.
lxc_setup_fs() is moved up, before the process is forked.

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-27 12:17:40 +02:00
Cedric Le Goater
3c22086fe2 introduce a sync API
The following patch wrap the calls on the synchronisation
socketpair in a lxc_sync_ API. It hopefully clarifies what
is done in the start sequence to the expense of more lines
of code ...

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-26 21:43:53 +02:00
Cedric Le Goater
ee70bf78e3 merge lxc_restart() and lxc_start()
now that we have specific operations and specific arguments for each
sequence, lxc_restart() and lxc_start() can easily be merged under
a common subroutine.

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-26 16:54:48 +02:00
Cedric Le Goater
23c53af96d replace common start_arg by private start_arg
the following patch moves the start argument in private
structs which are opaque to lxc_spawn(). To achieve this goal,
we need to move the sv[2] socketpair and lxc_handler

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-26 16:54:48 +02:00
Cedric Le Goater
ffe1e01a50 start sequence cleanups
These are trivial changes:
	start_arg->name is redundant with lxc_handler->name
	sv[2] can be stored directly under start_arg

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-26 16:54:48 +02:00
Cedric Le Goater
32e1c76058 simplify lxc_spawn() gotos
label 'out_close' is used only once.

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-26 16:54:48 +02:00
Cedric Le Goater
79fd982e91 introduce struct lxc_operations
struct lxc_operations offers 2 operations : start and post_start
which are used by the lxc-start and lxc-restart sequences to
define specific actions.

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
2010-05-26 16:54:48 +02:00
Michel Normand
e6126dbe9f Add ops for start
In order to define a specific function for restart, let's create
an ops where we will be able to specify a function for restart too.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-26 16:54:48 +02:00
Michel Normand
fc25b815fd prepare do_start for restart code
In order to be able to use a single 'start' function for start
and restart, let's prepare do_start to get an extra statefile parameter.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-26 16:54:48 +02:00
Michel Normand
69ffa31110 move LXC_TTY_HANDLER_ADD/DEL out of init/fini in start.c
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-26 16:54:48 +02:00
Michel Normand
8f64a3f64f sigprocmask moved in fini of start.c
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-26 16:54:48 +02:00
Denis Rizaev
8ff3518040 fix initial run level
I did a little investigation about runlevels and i think we can assume
runlevels 2-5 as normal. So, we can check if system was in runlevel 2-5
and proc count is 1 and now we are in 0/6.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Denis Rizaev <Denis.Rizaev@trueoffice.ru>
2010-05-24 15:06:36 +02:00
Nathan Lynch
fa9ab20562 correct asprintf error checking
asprintf(3) returns -1 (not 0) on error.

Signed-off-by: Nathan Lynch <ntl@pobox.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-19 22:15:28 +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
1362f2eba1 close socket command
We don't close the command socket after the transaction, that leads
to a fd leak.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-19 22:15:28 +02:00
Daniel Lezcano
da2aef7f9a fix indentation
Indent the signalfd structure definition correctly.

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
Daniel Lezcano
1f1b18e754 support ipv4 broadcast specification
Add the broadcast specification, if none is specified, it is automatically
computed from the addr & mask.

syntax:
	lxc.network.ipv4 = 172.20.0.2/24 172.20.255.255

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-18 17:40:04 +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
23b7ea696b add lxc.rootfs.mount config option
Define lxc.rootfs.mount option in order to override the default
mount point for rootfs.

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
Daniel Lezcano
196db713a9 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>
2010-05-12 23:44:28 +02:00
Daniel Lezcano
288063bd07 whitespace cleanup in configure.ac
Mindless changes by removing whitespace.

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
bf6cc73696 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>
2010-05-10 11:50:10 +02:00
Guillaume Zitta
8208b295ab 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>
2010-05-10 11:50:10 +02:00
Daniel Lezcano
10e657e5e8 add missing /dev/pts directory
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-05-10 11:50:10 +02:00
Daniel Lezcano
2f462f4b9b 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>
2010-05-10 11:50:09 +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
Daniel Lezcano
5c2940600e 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>
2010-05-10 11:50:09 +02:00
Daniel Lezcano
82d89dce37 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>
2010-05-07 14:37:05 +02:00
Daniel Lezcano
15cd25fdcd 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>
2010-05-07 14:37:05 +02:00
Michel Normand
f2faa8fab9 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>
2010-04-29 10:03:59 +02:00
Michel Normand
4d2e2ec66c 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>
2010-04-29 10:03:59 +02:00
Michel Normand
99a6af5202 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>
2010-04-29 10:03:59 +02:00
Michel Normand
7d1635085f lxc: remove unused lxc_bridge_detach
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
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
gkurz@linux.vnet.ibm.com
e4b3fe5833 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>
2010-04-29 10:03:59 +02:00
Michel Normand
b78b21258c 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>
2010-04-29 10:03:59 +02:00
Michel Normand
becc0400fc man update lxc-create lxc-destroy
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
Michel Normand
94b81f611f 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>
2010-04-29 10:03:59 +02:00
Michel Normand
a941cc0bf6 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>
2010-04-29 10:03:59 +02:00
Michel Normand
d72d3d7b16 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>
2010-04-29 10:03:59 +02:00
Michel Normand
b89885d896 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>
2010-04-29 10:03:59 +02:00
Michel Normand
dcb7e5d5d2 remove unused _config_console function
it's usage was removed by patch
28a4b0e55c
"open the console later"

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