]> git.proxmox.com Git - mirror_lxc.git/log
mirror_lxc.git
11 years agoRename utmp.c/utmp.h to lxcutmp.c/lxcutmp.h
Stéphane Graber [Fri, 11 Jan 2013 17:29:54 +0000 (12:29 -0500)]
Rename utmp.c/utmp.h to lxcutmp.c/lxcutmp.h

This avoids conflict with the system header utmp.h.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoAdd check for sys/timerfd.h
Stéphane Graber [Fri, 11 Jan 2013 17:29:53 +0000 (12:29 -0500)]
Add check for sys/timerfd.h

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoFix header name in lxcmntent.h
Stéphane Graber [Fri, 11 Jan 2013 17:29:52 +0000 (12:29 -0500)]
Fix header name in lxcmntent.h

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agouse pkg-config to ensure python3-devel is installed
Dwight Engen [Thu, 10 Jan 2013 20:45:22 +0000 (15:45 -0500)]
use pkg-config to ensure python3-devel is installed

The Python.h header varies in location by distribution, so instead use
pkg-config to ensure the python3 devel package is installed. Tested with
Ubuntu 12.04 and Fedora 17. Fixes --enable-python on Fedora 17.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAdd 'config' option to lxc-archlinux template and fix getopt string
Alexander Vladimirov [Fri, 11 Jan 2013 10:36:23 +0000 (18:36 +0800)]
Add 'config' option to lxc-archlinux template and fix getopt string

This option allows user to control installation repository and options
using alternative pacman configuration file.
Also remove unnecessary sed invocation during container configuration.

Signed-off-by: Alexander Vladimirov <alexander.idkfa.vladimirov@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoutmp.h: Don't fail when utmpx.h isn't present
Stéphane Graber [Thu, 10 Jan 2013 22:10:51 +0000 (17:10 -0500)]
utmp.h: Don't fail when utmpx.h isn't present

Following a comment on the mailing-list, I made utmp.h return -1
when it's disabled, the problem with that is that it prevents the
container from starting completely, which isn't quite what I wanted.

This change makes the function succeed, the container will therefore
start but without utmp handler.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoDefine PR_CAPBSET_READ when missing
Stéphane Graber [Thu, 10 Jan 2013 20:22:30 +0000 (15:22 -0500)]
Define PR_CAPBSET_READ when missing

PR_CAPBSET_READ isn't defined in bionic, so define it if it's not.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agooracle template: fix lxc-shutdown with upstart SIGPWR handler
Dwight Engen [Wed, 9 Jan 2013 19:09:55 +0000 (14:09 -0500)]
oracle template: fix lxc-shutdown with upstart SIGPWR handler

OL6 uses upstart init and needs a handler for the SIGPWR that
lxc-shutdown sends it so that a container can shut down cleanly.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofix lxc-shutdown argument parsing
Dwight Engen [Wed, 9 Jan 2013 19:09:33 +0000 (14:09 -0500)]
fix lxc-shutdown argument parsing

processing of -w or -r shifts an argument that isn't there, messing up
other argument processing

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoMakefile.am: Add missing liblxc symlink
Stéphane Graber [Mon, 7 Jan 2013 22:46:16 +0000 (17:46 -0500)]
Makefile.am: Add missing liblxc symlink

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoDon't call setup_mount_entries if the list is empty
Stéphane Graber [Fri, 4 Jan 2013 18:56:13 +0000 (13:56 -0500)]
Don't call setup_mount_entries if the list is empty

There's no good reason to call setup_mount_entries if we don't have any
lxc.mount.entry. This also avoids an issue on bionic where the tmpfile()
call in setup_mount_entries requires the presence of /tmp which isn't the
case by default.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agotests/Makefile.am: Update for bionic
Stéphane Graber [Thu, 3 Jan 2013 19:04:48 +0000 (14:04 -0500)]
tests/Makefile.am: Update for bionic

-lpthread doesn't exist and isn't necessary on bionic.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc_unshare: Replace getpw*_r by getpw*
Stéphane Graber [Thu, 3 Jan 2013 16:51:52 +0000 (11:51 -0500)]
lxc_unshare: Replace getpw*_r by getpw*

Bionic and maybe some other libc implementations lack the _r nss functions.
This replaces our current getpwnam_r and getpwuid_r calls by getpwnam and
getpwuid.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoconf.c: Cleanup __S_ISTYPE
Stéphane Graber [Thu, 3 Jan 2013 17:24:20 +0000 (12:24 -0500)]
conf.c: Cleanup __S_ISTYPE

__S_ISTYPE doesn't exist in all C libraries, so define it if it's missing.
Additionaly, replace one occurence where it wasn't actually needed.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoAdd local implementation of mntent.h
Stéphane Graber [Thu, 3 Jan 2013 17:24:19 +0000 (12:24 -0500)]
Add local implementation of mntent.h

Bionic (at least) is missing some of the usual mntent functions.
This adds code defining those that we need when they're missing from the C
library.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agocaps.h: Rename __errno to ___errno
Stéphane Graber [Thu, 3 Jan 2013 17:24:18 +0000 (12:24 -0500)]
caps.h: Rename __errno to ___errno

At least bionic defines __errno, so this was causing a conflict in caps.h
leading to build failure. Renaming to ___errno avoids that conflicting
definition.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoReplace strdupa call by standard strdup
Stéphane Graber [Wed, 26 Dec 2012 14:47:37 +0000 (15:47 +0100)]
Replace strdupa call by standard strdup

strdupa appears to only exist in the standard glibc but at least not in bionic.
Replace the two strdupa calls we have by a standard strdup.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoAdd a bionic_alphasort function on bionic
Stéphane Graber [Thu, 3 Jan 2013 17:24:16 +0000 (12:24 -0500)]
Add a bionic_alphasort function on bionic

alphasort doesn't have the right signature on bionic which causes the build to
fail. This implements a new bionic_alphasort function when building on bionic
providing the right signature and a functional equivalent of glibc's alphasort.

This signature problem with alphasort was fixed in upstream bionic but hasn't
been released yet. This commit can therefore be reverted as soon as the
following commit hits the Android NDK: 40e467ec668b59be25491bd44bf348a884d6a68d

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoMake utmpx.h optional
Stéphane Graber [Thu, 3 Jan 2013 17:24:15 +0000 (12:24 -0500)]
Make utmpx.h optional

This adds code detecting the presence of utmpx.h and in its absence, turns the
utmp related functions into no-ops.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoWorkaround missing functions in other libc
Stéphane Graber [Thu, 3 Jan 2013 17:24:14 +0000 (12:24 -0500)]
Workaround missing functions in other libc

Some libc implementation (bionic) is lacking some of the syscall functions
that are present in the glibc.

For those, detect at build time the they are missing and implement a minimal
syscall() wrapper that will essentially give the same result as the glibc
function.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agopersonality.h: Make the personality code optional
Stéphane Graber [Thu, 3 Jan 2013 17:24:13 +0000 (12:24 -0500)]
personality.h: Make the personality code optional

Some platforms don't have personality.h in their C library, this change
adds buildtime detection for the header and turns off the personality setting
code in those cases.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoDon't hard depend on capability.h and libcap
Stéphane Graber [Thu, 20 Dec 2012 15:11:03 +0000 (16:11 +0100)]
Don't hard depend on capability.h and libcap

In the effort to make LXC work with non-standard Linux distros, this change
allows for the user to build LXC without capability support through a new
--disable-capabilities option to configure.

This effectively will cause LXC not to link against libcap and will turn all
the _cap_ functions into no-ops.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agotty.h: Ship our own minimal openpty.h
Stéphane Graber [Thu, 3 Jan 2013 17:24:11 +0000 (12:24 -0500)]
tty.h: Ship our own minimal openpty.h

bionic is missing an openpty() function, so ship our own and only
build it and use it on bionic.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoclone: Support bionic's clone() defintion
Stéphane Graber [Thu, 3 Jan 2013 17:24:10 +0000 (12:24 -0500)]
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>
11 years agoconf.c: Define LO_FLAGS_AUTOCLEAR if it's not
Stéphane Graber [Thu, 3 Jan 2013 17:24:09 +0000 (12:24 -0500)]
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>
11 years agoAdd/remove extra includes
Stéphane Graber [Thu, 20 Dec 2012 13:17:09 +0000 (14:17 +0100)]
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>
11 years agoReplace get_current_dir_name by getcwd
Stéphane Graber [Thu, 3 Jan 2013 17:24:07 +0000 (12:24 -0500)]
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>
11 years agoNo need to link against rt and util on bionic
Stéphane Graber [Thu, 3 Jan 2013 17:24:06 +0000 (12:24 -0500)]
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>
11 years agoSupport both getline and fgetln
Stéphane Graber [Thu, 20 Dec 2012 12:46:57 +0000 (13:46 +0100)]
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>
11 years agoReplace all reference to ushort by unsigned short
Stéphane Graber [Tue, 8 Jan 2013 17:02:53 +0000 (12:02 -0500)]
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>
11 years agoconfigure.ac: Cleanup, comments, indent, ...
Stéphane Graber [Tue, 8 Jan 2013 17:02:52 +0000 (12:02 -0500)]
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>
11 years agoconfigure.ac: Add code to detect bionic C library
Stéphane Graber [Tue, 8 Jan 2013 17:02:51 +0000 (12:02 -0500)]
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>
11 years agoSet umask before populating /dev and restore it after.
Alexander Vladimirov [Tue, 8 Jan 2013 01:08:54 +0000 (09:08 +0800)]
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>
11 years agooracle template: use url arg to wget repo file
Dwight Engen [Mon, 7 Jan 2013 19:02:39 +0000 (14:02 -0500)]
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>
11 years agooracle template: drop additional capabilities
Dwight Engen [Mon, 7 Jan 2013 19:02:31 +0000 (14:02 -0500)]
oracle template: drop additional capabilities

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agodocument lxc-console escape sequence and argument
Dwight Engen [Fri, 4 Jan 2013 20:23:23 +0000 (15:23 -0500)]
document lxc-console escape sequence and argument

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofixed RELEASE_URL for fedora releases higher than 16
Maximilian Seesslen [Fri, 4 Jan 2013 15:36:07 +0000 (16:36 +0100)]
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>
11 years agolxc-ps: fix order of output and fix --lxc opt
Natanael Copa [Fri, 4 Jan 2013 08:39:04 +0000 (09:39 +0100)]
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>
11 years agolxc-checkconfig: fix colors when using dash
Natanael Copa [Tue, 25 Dec 2012 15:50:54 +0000 (16:50 +0100)]
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>
11 years agofix lxc-wait waiting forever for FREEZING, FROZEN, THAWED states
Dwight Engen [Wed, 19 Dec 2012 00:15:33 +0000 (19:15 -0500)]
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>
11 years agooracle template: add support for creating ol4 container from ovm template
Dwight Engen [Fri, 14 Dec 2012 20:38:35 +0000 (15:38 -0500)]
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>
11 years agoseparate console device from console log
Dwight Engen [Thu, 27 Dec 2012 22:01:26 +0000 (17:01 -0500)]
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>
11 years agokill -s expects the signal name without SIG
Stéphane Graber [Wed, 2 Jan 2013 18:47:18 +0000 (13:47 -0500)]
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>
11 years agolxc-alpine: add support for installing optional packages
Natanael Copa [Mon, 31 Dec 2012 19:49:19 +0000 (20:49 +0100)]
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>
11 years agolxc-alpine: add support for setting arch from command line
Natanael Copa [Mon, 31 Dec 2012 19:49:18 +0000 (20:49 +0100)]
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>
11 years agolxc-alpine: add --repository option
Natanael Copa [Mon, 31 Dec 2012 19:49:17 +0000 (20:49 +0100)]
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>
11 years agolxc-alpine: indent fixes
Natanael Copa [Mon, 31 Dec 2012 19:49:16 +0000 (20:49 +0100)]
lxc-alpine: indent fixes

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agotemplates: install lxc-alpine
Natanael Copa [Mon, 31 Dec 2012 19:49:15 +0000 (20:49 +0100)]
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>
11 years agolxc-ps: use posix shell and awk instead of bash
Natanael Copa [Wed, 26 Dec 2012 21:31:56 +0000 (22:31 +0100)]
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>
11 years agolxc-shutdown: use posix shell instead of bash
Natanael Copa [Thu, 27 Dec 2012 08:52:30 +0000 (09:52 +0100)]
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>
11 years agofix open check (0 is a valid fd)
Dwight Engen [Mon, 31 Dec 2012 19:02:49 +0000 (14:02 -0500)]
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>
11 years agocleanup: use lxc-info --state-is
Natanael Copa [Fri, 28 Dec 2012 08:24:55 +0000 (09:24 +0100)]
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>
11 years agolegacy/lxc-ls: improve finding fs mountpoint of hierarchy
Natanael Copa [Wed, 26 Dec 2012 09:07:04 +0000 (10:07 +0100)]
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>
11 years agolxc-netstat: improve finding fs mountpoint of hierarchy
Natanael Copa [Wed, 26 Dec 2012 09:07:03 +0000 (10:07 +0100)]
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>
11 years agoUpdate lxc-archlinux template to work with systemd
Alexander Vladimirov [Thu, 13 Dec 2012 08:00:55 +0000 (16:00 +0800)]
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>
11 years agolxc-netstat: use posix shell instead of bash
Natanael Copa [Tue, 25 Dec 2012 16:08:56 +0000 (17:08 +0100)]
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>
11 years agolxc-clone: use posix shell instead of bash
Natanael Copa [Tue, 25 Dec 2012 16:08:55 +0000 (17:08 +0100)]
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>
11 years agolegacy/lxc-ls: use posix shell instead of bash
Natanael Copa [Tue, 25 Dec 2012 16:08:54 +0000 (17:08 +0100)]
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>
11 years agolxc-destroy: use posix shell instead of bash
Natanael Copa [Tue, 25 Dec 2012 16:08:53 +0000 (17:08 +0100)]
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>
11 years agotemplates: initial support for Alpine Linux
Natanael Copa [Mon, 24 Dec 2012 16:18:21 +0000 (17:18 +0100)]
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>
11 years agoFix compile warning on uninitialized return value
Kyle Russell [Fri, 21 Dec 2012 15:34:34 +0000 (10:34 -0500)]
Fix compile warning on uninitialized return value

Signed-off-by: Kyle Russell <bkylerussell@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agodefine MS_SHARED if needed
Natanael Copa [Tue, 25 Dec 2012 09:53:50 +0000 (10:53 +0100)]
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>
11 years agoClear environment for container
Serge Hallyn [Thu, 20 Dec 2012 22:14:49 +0000 (16:14 -0600)]
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>
11 years agoSupport MS_SHARED /
Serge Hallyn [Thu, 20 Dec 2012 05:58:44 +0000 (23:58 -0600)]
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>
11 years agolxc-destroy container only if it is in the STOPPED state
Dwight Engen [Tue, 18 Dec 2012 21:12:34 +0000 (16:12 -0500)]
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>
11 years agoVersion 0.9.0.alpha2
Daniel Lezcano [Fri, 14 Dec 2012 08:42:55 +0000 (09:42 +0100)]
Version 0.9.0.alpha2

11 years agoMerge git://github.com/lxc/lxc
Daniel Lezcano [Fri, 14 Dec 2012 08:42:21 +0000 (09:42 +0100)]
Merge git://github.com/lxc/lxc

11 years agoFix race/corruption with multiple lxc-start, lxc-execute
Dwight Engen [Tue, 11 Dec 2012 22:05:11 +0000 (17:05 -0500)]
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>
11 years agoVersion 0.9.0.alpha1
Daniel Lezcano [Thu, 13 Dec 2012 20:51:03 +0000 (21:51 +0100)]
Version 0.9.0.alpha1

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
11 years agoMerge git://github.com/lxc/lxc
Daniel Lezcano [Thu, 13 Dec 2012 20:47:55 +0000 (21:47 +0100)]
Merge git://github.com/lxc/lxc

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
11 years agoDon't attempt to symlink kmsg without rootfs->path
Dwight Engen [Tue, 11 Dec 2012 17:39:16 +0000 (12:39 -0500)]
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>
11 years agosupport new libseccomp api
Serge Hallyn [Tue, 11 Dec 2012 17:40:02 +0000 (11:40 -0600)]
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>
11 years agoREADME: fix typo in example script
Serge Hallyn [Tue, 11 Dec 2012 17:39:26 +0000 (11:39 -0600)]
README: fix typo in example script

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoseccomp: free conf->seccomp (filename char *)
Serge Hallyn [Tue, 11 Dec 2012 17:08:09 +0000 (11:08 -0600)]
seccomp: free conf->seccomp (filename char *)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoassume LXCPATH took on default localstatedir based value in configure
Dwight Engen [Thu, 6 Dec 2012 18:29:51 +0000 (13:29 -0500)]
assume LXCPATH took on default localstatedir based value in configure

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Michael H. Warfield <mhw@WittsEnd.com>
11 years agopython: Update add_device_node to use the new API
Stéphane Graber [Mon, 10 Dec 2012 04:36:10 +0000 (23:36 -0500)]
python: Update add_device_node to use the new API

Update add_device_node to use the new set_cgroup_item call instead
of having to figure out the cgroup paths and update the entries manually.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agogitignore: Update for python files
Stéphane Graber [Fri, 7 Dec 2012 20:47:12 +0000 (15:47 -0500)]
gitignore: Update for python files

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agopython: Add binding for {get|set}_cgroup_item
Stéphane Graber [Fri, 7 Dec 2012 20:47:11 +0000 (15:47 -0500)]
python: Add binding for {get|set}_cgroup_item

Updates the binding for the two new functions.

This also fixes some problems with the argument checking of
get_config_item that'd otherwise lead to a segfault.

The python binding for set_cgroup_item and get_cgroup_item are pretty
raw as lxc has little control over the cgroup entries.
That means that we don't try to interpret lists as we do for the config
entries.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agopython: get_keys() doesn't require a path
Stéphane Graber [Fri, 7 Dec 2012 20:47:10 +0000 (15:47 -0500)]
python: get_keys() doesn't require a path

The python binding was forcing the user to pass a base path to
get_keys() even though the C binding doesn't require it.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agodont save loglevel if it is unset
Serge Hallyn [Fri, 7 Dec 2012 20:16:54 +0000 (14:16 -0600)]
dont save loglevel if it is unset

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agopython3-lxc: Fix build prefix/destdir
Stéphane Graber [Fri, 7 Dec 2012 17:24:23 +0000 (12:24 -0500)]
python3-lxc: Fix build prefix/destdir

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoapi: add set_cgroup_item and get_cgroup_item (to c api)
Serge Hallyn [Fri, 7 Dec 2012 00:41:15 +0000 (18:41 -0600)]
api: add set_cgroup_item and get_cgroup_item (to c api)

set_cgroup_item takes a pointer to a running container, a cgroup subsystem
name, and a char *value and it mimicks
'lxc-cgroup -n containername subsys value'
get_cgroup_item takes a pointer to a running container, a a cgroup
subsystem name, a destination value * and the length of the value being
sent in, and returns the length of what was read from the cgroup file.
If a 0 len is passed in, then the length of the file is returned.  So
you can do

len = c->get_cgroup_item(c, "devices.list", NULL, 0);
v = malloc(len+1);
ret = c->get_cgroup_item(c, "devices.list", v, len);

to read the whole file.

This patch also disables the lxc-init part of the startone test, which
was failing because lxc-init has been moved due to multiarch issues.
The test is salvagable, but saving it was beyond this effort.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-create: Allow for empty or unset template name
Stéphane Graber [Fri, 7 Dec 2012 15:41:10 +0000 (10:41 -0500)]
lxc-create: Allow for empty or unset template name

This restores an old behaviour where lxc-create can be called without
a template. In such case, only a minimal configuration is built and no
rootfs is created. However the various backingstore code is still used.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc.spec: add openssl and rsync as Required since both are used in lxc-clone
Dwight Engen [Thu, 6 Dec 2012 14:58:21 +0000 (09:58 -0500)]
lxc.spec: add openssl and rsync as Required since both are used in lxc-clone

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agopython: Remove hardcoded LXCPATH
Stéphane Graber [Wed, 5 Dec 2012 23:51:10 +0000 (18:51 -0500)]
python: Remove hardcoded LXCPATH

Switch the python scripts to using @LXCPATH@.

According to grep, this was the last occurence of a /var/*/lxc
path in the code.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agotemplates: Consistent use of locking
Stéphane Graber [Wed, 5 Dec 2012 23:51:09 +0000 (18:51 -0500)]
templates: Consistent use of locking

Move to per-template lock (except for oracle that's per-container).
Also ensure that the path used for the lock is relative to LOCALSTATEDIR.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-archlinux: Don't hardcode /var/lib/lxc in help
Stéphane Graber [Wed, 5 Dec 2012 23:51:08 +0000 (18:51 -0500)]
lxc-archlinux: Don't hardcode /var/lib/lxc in help

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-ubuntu: Don't hardcode path to cache
Stéphane Graber [Wed, 5 Dec 2012 23:51:07 +0000 (18:51 -0500)]
lxc-ubuntu: Don't hardcode path to cache

Use LOCALSTATEDIR to generate the path to the cache.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoUpdate for consistent indent
Stéphane Graber [Wed, 5 Dec 2012 21:47:19 +0000 (16:47 -0500)]
Update for consistent indent

This commit updates all scripts using mixed indent to a consistent
4 spaces indent.

In the past quite a few of those scripts used tabs to instead of 8 spaces or
instead of 4 spaces, sometimes mixing those in the same line and sometimes
changing the tab width within the same file.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agotemplates: Make generated config consistent
Stéphane Graber [Wed, 5 Dec 2012 21:47:18 +0000 (16:47 -0500)]
templates: Make generated config consistent

This updates all the templates and the configuration files to consistently
use "key = value" everywhere.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoMinor documentation updates
Stéphane Graber [Wed, 5 Dec 2012 21:47:17 +0000 (16:47 -0500)]
Minor documentation updates

 - Update COPYING to the current copy of the LPGL-2.1 license from
   common-licences (only difference is some indentation).
 - Remove mixed tabs/spaces in CONTRIBUTING
 - Make INSTALL fit on 79 cols.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoUpdate README
Stéphane Graber [Wed, 5 Dec 2012 21:47:16 +0000 (16:47 -0500)]
Update README

This adds a section about the staging branch to the README and updates
the list of supported architectures.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agooracle template: fixes when using fedora host
Stéphane Graber [Wed, 5 Dec 2012 22:07:01 +0000 (17:07 -0500)]
oracle template: fixes when using fedora host

Let oracle template work when host is fedora or oracle and the lsb_release
command is not present. Verify the arch given is valid. Don't add lxc.network
section again if already present.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agomake install should create /var/cache/lxc directory
Dwight Engen [Wed, 5 Dec 2012 20:05:02 +0000 (15:05 -0500)]
make install should create /var/cache/lxc directory

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-archlinux.in: Apply same LXCPATH/LOCALSTATEDIR
Stéphane Graber [Wed, 5 Dec 2012 18:33:03 +0000 (13:33 -0500)]
lxc-archlinux.in: Apply same LXCPATH/LOCALSTATEDIR

lxc-archlinux was apparently left out of the last change, apply
the same modification as the other templates.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoUse LXCPATH and LOCALSTATEDIR instead of hardcoded /var
Dwight Engen [Wed, 5 Dec 2012 17:33:16 +0000 (12:33 -0500)]
Use LXCPATH and LOCALSTATEDIR instead of hardcoded /var

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-create: refuse to use a custom rootfs (--dir) which already exists.
Serge Hallyn [Wed, 5 Dec 2012 16:38:07 +0000 (10:38 -0600)]
lxc-create: refuse to use a custom rootfs (--dir) which already exists.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-ls: Update code to allow non-root listing
Stéphane Graber [Tue, 4 Dec 2012 22:42:46 +0000 (17:42 -0500)]
lxc-ls: Update code to allow non-root listing

Re-arrange the code so that we only grab the container object when doing
something more than building a simple list of existing containers.

This means that now the following calls can run unprivileged:
 - lxc-ls
 - lxc-ls -1

Everything else will still require root privileges.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agopython: Update to the device related functions
Stéphane Graber [Tue, 4 Dec 2012 22:30:13 +0000 (17:30 -0500)]
python: Update to the device related functions

This commit does the following changes to the python API:
 - Rename the add_device API call to add_device_node
 - Adds an extra check that the container is running to add_device_node
 - Introduces a new add_device_net function

And the following changes to the lxc-device tool:
 - Change parser setup to better cope with variable number of arguments
 - Add support for network devices (currently auto-detected)
 - Support for different names on the host and in the container

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-device: Show an error message when non-root
Stéphane Graber [Tue, 4 Dec 2012 21:17:09 +0000 (16:17 -0500)]
lxc-device: Show an error message when non-root

Instead of returning a python stacktrace, check what the current euid is
and show an argparse error message similar to that used in lxc-start-ephemeral.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>