Commit Graph

1578 Commits

Author SHA1 Message Date
Stéphane Graber
1f1665e6ca clone: Support bionic's clone() defintion
The clone() call in bionic is very slightly different.
This updates namespace.h to support both glibc and bionic.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-09 10:10:26 -05:00
Stéphane Graber
9818cae412 conf.c: Define LO_FLAGS_AUTOCLEAR if it's not
LO_FLAGS_AUTOCLEAR isn't defined on bionic, so add an extra ifndef
and set it to its usual value if it's not.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-09 10:10:22 -05:00
Stéphane Graber
8173e600ef Add/remove extra includes
While cross-building with bionic, a number of failures were triggered by some
missing includes and in a few cases by extra unused includes.

This commit updates the various headers based on those observations.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-09 10:10:18 -05:00
Stéphane Graber
d2717c14d8 Replace get_current_dir_name by getcwd
get_current_dir_name appears to be specific to glibc. Replace that call
by an equivalent getcwd call.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-09 10:10:13 -05:00
Stéphane Graber
20d2e91bd3 No need to link against rt and util on bionic
When building on bionic, -lrt and -lutil only cause a build failure.
Dropping those fixes the build, so it appears that the symbols are defined
in the main library.

This commit moves -lrt and -lutil under a !IS_BIONIC check.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-09 10:10:02 -05:00
Stéphane Graber
1ba0013f21 Support both getline and fgetln
Some libc implementations don't have the getline function but instead
have an equivalent fgetln function.

Add code to detect both and use whatever is available.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-09 10:09:36 -05:00
Stéphane Graber
7c11d57a22 Replace all reference to ushort by unsigned short
ushort appears to be a glibc specific type which doesn't exist in
bionic, this commit simply replace all occurences by the equivalent
unsigned short type.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-09 09:36:46 -05:00
Stéphane Graber
8aa4885c22 configure.ac: Cleanup, comments, indent, ...
This commit doesn't do any functional change to configure.ac but does a fair
amount of cleaning up.

It re-orders the various blocks by type (options, checks, expands, ...).
It also consistently uses tabs for indents.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-09 09:36:25 -05:00
Stéphane Graber
a6168a17ee configure.ac: Add code to detect bionic C library
This adds a new IS_BIONIC define that can be used to detect whether we are
building with eglibc or with bionic.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-09 09:35:19 -05:00
Alexander Vladimirov
3a32201c5a Set umask before populating /dev and restore it after.
According to docs, mknod clears each permission bit whose
corresponding bit in the process umask is set, so we should fix it
before creating device nodes.

Signed-off-by: Alexander Vladimirov <alexander.idkfa.vladimirov@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-08 12:07:34 -05:00
Dwight Engen
c5b908a262 oracle template: use url arg to wget repo file
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-08 12:06:59 -05:00
Dwight Engen
d378aebe3d oracle template: drop additional capabilities
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-08 12:06:57 -05:00
Dwight Engen
768487891f document lxc-console escape sequence and argument
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-08 12:05:43 -05:00
Maximilian Seesslen
29e18143a0 fixed RELEASE_URL for fedora releases higher than 16
The Url for the fedora-release RPM changed in release 17.

Signed-off-by: Maximilian Seesslen <mes@seesslen.net>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-04 12:22:14 -05:00
Natanael Copa
bd9a66b20c lxc-ps: fix order of output and fix --lxc opt
We must output the lines from 'ps' in same order for tree views.

Fix also --lxc option to only show processes from containers.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-04 10:11:19 -05:00
Natanael Copa
bc2333ebec lxc-checkconfig: fix colors when using dash
The \e did not work as expected on dash. Replace with proper posix \033

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-04 09:57:22 -05:00
Dwight Engen
d27b0806cd fix lxc-wait waiting forever for FREEZING, FROZEN, THAWED states
These states are kept by the kernel in the freezer.state cgroup item, and
are never set in handler->state with lxc_set_state(). If lxc transitions
a container to/from the freezer after an lxc-wait for one of the above
states has already started, the lxc-wait will never see the new state. This
change has lxc send the new state to the lxc-monitor socket.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-03 18:14:07 -05:00
Dwight Engen
e35cb41b8c oracle template: add support for creating ol4 container from ovm template
Also: disable the interactive part of ovmd so ol5,6 containers won't
hang if started for the first time with -d. Don't let containers do rawio,
or have access to /dev/rtc0, they can mess up the hosts system clock among
other things.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-03 18:12:41 -05:00
Dwight Engen
596a818d4b separate console device from console log
lxc-start -c makes the named file/device the container's console, but using
this with a regular file in order to get a log of the console output does
not work very well if you also want to login on the console. This change
implements an additional option (-L) to simply log the console's output to
a file.

Both options can be used separately or together. For example to get a usable
console and log: lxc-start -n name -c /dev/tty8 -L console.log

The console state is cleaned up more when lxc_delete_console is called, and
some of the clean up paths in lxc_create_console were fixed.

The lxc_priv and lxc_unpriv macros were modified to make use of gcc's local
label feature so they can be expanded more than once in the same function.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-02 18:08:12 -05:00
Stéphane Graber
4199da3061 kill -s expects the signal name without SIG
The previous lxc-shutdown change replaced 'kill SIG<name>' by
'kill -s SIG<name>'. Although this works with busybox where it was tested,
this doesn't actually work with all kill implementations. Some requiring just
the signal name without the prefix.

This changes "-s SIG<name>" by just "-s <name>". Tested with busybox and
standard kill.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 13:47:18 -05:00
Natanael Copa
670c6ab8ca lxc-alpine: add support for installing optional packages
Let users append a list of packages they want install in the container

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 13:13:15 -05:00
Natanael Copa
2b49de9a3f lxc-alpine: add support for setting arch from command line
This allows us to lxc-create 32 bit guests on x86_64 hosts.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 13:11:31 -05:00
Natanael Copa
e5846a6f89 lxc-alpine: add --repository option
This allows specifying what repository to use for the container.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 13:06:43 -05:00
Natanael Copa
b1aa0624ba lxc-alpine: indent fixes
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 13:05:23 -05:00
Natanael Copa
8410c48507 templates: install lxc-alpine
Make sure we actually install lxc-alpine

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 13:04:48 -05:00
Natanael Copa
b5dec5f30b lxc-ps: use posix shell and awk instead of bash
Use awk to parse the output pf 'ps' and the tasks files for the
containers.

Use awk fields to find PID column rather than assume that the PID field
is exactly 5 chars wide and has a leading space ' PID'. This works as
long as the PID field is before the command or other field that include
spaces. This also makes it work with busybox 'ps'.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 13:00:32 -05:00
Natanael Copa
600faead38 lxc-shutdown: use posix shell instead of bash
- avoid getopt --longoptions
- use 'which' instead of 'type' to detect existance of tools
- specify -s SIG<signame> with kill

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 12:57:27 -05:00
Dwight Engen
4415d5163c fix open check (0 is a valid fd)
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 12:53:56 -05:00
Natanael Copa
7265dc4344 cleanup: use lxc-info --state-is
We now have the possibility to test for a given state. Use this feature
instead of parsing output with grep or awk

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 12:52:37 -05:00
Natanael Copa
32e8690186 legacy/lxc-ls: improve finding fs mountpoint of hierarchy
We cannot assume that the mount source name always starts with 'cgroup'
so we check the filesystem type instead.

Use 'awk' instead of 'grep -E' and  as it is a better tool for this job.

This fixes the tool on systems using openrc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 12:48:13 -05:00
Natanael Copa
f358385a7c lxc-netstat: improve finding fs mountpoint of hierarchy
We cannot assume that the mount source name always starts with 'cgroup'
so we check the filesystem type instead.

Use 'awk' instead of 'grep -E' and  as it is a better tool for this job.

This fixes the tool on systems using openrc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 12:47:31 -05:00
Alexander Vladimirov
f3849d01d8 Update lxc-archlinux template to work with systemd
Use arch-install-scripts for installation.

Signed-off-by: Alexander Vladimirov <alexander.idkfa.vladimirov@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 12:42:26 -05:00
Natanael Copa
c44fc03789 lxc-netstat: use posix shell instead of bash
- use case .. in instead of comparison with globs
- avoid 'local'

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-25 17:34:38 +01:00
Natanael Copa
4785915a51 lxc-clone: use posix shell instead of bash
- avoid getopt --longoptions
- use 'which' instead of 'type' to detect existance of tools
- use 'grep -q -w' instead of bash substring variable expansion
  ${line:0:18}

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-25 17:34:26 +01:00
Natanael Copa
2f0e69084e legacy/lxc-ls: use posix shell instead of bash
- use case .. in instead of comparison with globs
- avoid 'local'

While here, also avoid 'find ... -printf' which is not supported on busybox

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-25 17:34:03 +01:00
Natanael Copa
11bdaa7475 lxc-destroy: use posix shell instead of bash
- avoid use getopt --longoptions

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-25 17:30:19 +01:00
Natanael Copa
2a9a0a0807 templates: initial support for Alpine Linux
Requires apk-tools (http://git.alpinelinux.org/cgit/apk-tools)

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-25 12:59:36 +01:00
Kyle Russell
5270bf4b08 Fix compile warning on uninitialized return value
Signed-off-by: Kyle Russell <bkylerussell@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-25 12:59:24 +01:00
Natanael Copa
859a6da0fa define MS_SHARED if needed
Fixes build on uClibc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-25 12:58:50 +01:00
Serge Hallyn
964fe051e9 Clear environment for container
Clear env before starting a container.  Do it right before setting
the container=lxc variable.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-22 11:34:28 +01:00
Serge Hallyn
cc28d0b0a6 Support MS_SHARED /
(I'll be out until Jan 2, but in the meantime, here is hopefully a
little newyears gift - this seems to allow lxc-start with / being
MS_SHARED on the host)

When / is MS_SHARED (for instance with f18 and modern arch), lxc-start
fails on pivot_root.  The kernel enforces that, when doing pivot_root,
the parent of current->fs->root (as well as the new root and the putold
location) not be MS_SHARED.

To work around this, check /proc/self/mountinfo for a 'shared:' in
the '/' line.  If it is there, then create a tiny MS_SLAVE tmpfs dir to
serve as parent of /, recursively bind mount / into /root under that dir,
make it rslave, and chroot into it.

Tested with ubuntu raring image after doing 'mount --make-rshared /'.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-20 10:51:01 +01:00
Dwight Engen
963aef6f7f lxc-destroy container only if it is in the STOPPED state
Currently, lxc-destory will attempt to destroy a container if it is not in
the RUNNING state, but doing so is not good when the container is FROZEN, or
in other transitional states.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-19 17:07:50 +01:00
Daniel Lezcano
56655134e4 Version 0.9.0.alpha2 2012-12-14 09:42:55 +01:00
Daniel Lezcano
2a061f55f9 Merge git://github.com/lxc/lxc 2012-12-14 09:42:21 +01:00
Dwight Engen
d2e30e99b4 Fix race/corruption with multiple lxc-start, lxc-execute
If you start more than one lxc-start/lxc-execute with the same name at the
same time, or just do an lxc-start/lxc-execute with the name of a container
that is already running, lxc doesn't figure out that the container with this
name is already running until fairly late in the initialization process: ie
when __lxc_start() -> lxc_poll() -> lxc_command_mainloop_add() attempts to
create the same abstract socket name.

By this point a fair amount of initialization has been done that actually
messes up the running container. For example __lxc_start() -> lxc_spawn() ->
lxc_cgroup_create() -> lxc_one_cgroup_create() -> try_to_move_cgname() moves
the running container's cgroup to a name of deadXXXXXX.

The solution in this patch is to use the atomic existence of the abstract
socket name as the indicator that the container is already running.  To do
so, I just refactored lxc_command_mainloop_add() into an lxc_command_init()
routine that attempts to bind the socket, and ensure this is called earlier
before much initialization has been done.

In testing, I verified that maincmd_fd was still open at the time of lxc_fini,
so the entire lifetime of the container's run should be covered. The only
explicit close of this fd was in the reboot case of lxcapi_start(), which is
now moved to lxc_fini(), which I think is more appropriate.

Even though it is not checked any more, set maincmd_fd to -1 instead of 0 to
indicate its not open since 0 could be a valid fd.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-13 23:26:39 -05:00
Daniel Lezcano
d984bb4e75 Version 0.9.0.alpha1
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-12-13 21:51:03 +01:00
Daniel Lezcano
2e3ae157d5 Merge git://github.com/lxc/lxc
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-12-13 21:48:22 +01:00
Dwight Engen
222fea5a10 Don't attempt to symlink kmsg without rootfs->path
For example doing "lxc-execute -n tmpct /bin/bash" will call setup_kmsg(), but
in this case rootfs->mount/dev directory doesn't even exist so the call to
symlink fails with ENOENT. Commit f62b3449 made this failure not fatal, but
we should not even try it when we know it will fail. See similar code in
setup_tty(), setup_console(), etc.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-11 15:29:39 -05:00
Serge Hallyn
769872f9f2 support new libseccomp api
Detect the new api by existence in seccomp.h of the scmp_filter_ctx
type in configure.ac.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-12-11 12:33:40 -06:00
Serge Hallyn
a02264fb1e README: fix typo in example script
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-12-11 11:39:26 -06:00