]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
12 years agopython: PEP8 compatibility
Stéphane Graber [Thu, 22 Nov 2012 20:25:45 +0000 (15:25 -0500)] 
python: PEP8 compatibility

The new version of the pep8 command is detecting more indentation
mistakes than it used to, this fixes them.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
12 years agoRemove all trailing whitespaces.
Stéphane Graber [Mon, 26 Nov 2012 17:08:13 +0000 (12:08 -0500)] 
Remove all trailing whitespaces.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoFix checkconfig to handle kernel memory cgroup name change
Dwight Engen [Wed, 14 Nov 2012 17:03:56 +0000 (12:03 -0500)] 
Fix checkconfig to handle kernel memory cgroup name change

The kernel config option for the memory cgroup was changed in 3.6
from CONFIG_CGROUP_MEM_RES_CTLR to CONFIG_MEMCG with commit c255a458.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agolxc.conf.sgml.in: Fix typo
Stéphane Graber [Mon, 26 Nov 2012 16:45:28 +0000 (11:45 -0500)] 
lxc.conf.sgml.in: Fix typo

Fix a typo in the previous lxc.conf.sgml.in change.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoAdd lxc.autodev
Serge Hallyn [Thu, 1 Nov 2012 21:27:03 +0000 (22:27 +0100)] 
Add lxc.autodev

Add a container config option to mount and populate /dev in a container.

We might want to add options to specify a max size for /dev other than
the default 100k, and to specify other devices to create.  And maybe
someone can think of a better name than autodev.

Changelog: Don't error out if we couldn't mknod a /dev/ttyN.
Changelog: Describe the option in lxc.conf manpage.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agopython: Add new lxc-device tool
Stéphane Graber [Thu, 22 Nov 2012 23:01:08 +0000 (18:01 -0500)] 
python: Add new lxc-device tool

Add a new lxc-device tool which uses the new add_device() function of
the python API and lets you add a new device node to a running container.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
12 years agopython: Add add_device() function
Stéphane Graber [Thu, 22 Nov 2012 22:35:44 +0000 (17:35 -0500)] 
python: Add add_device() function

This introduces a new add_devices() call to the python API.

Parameters:
 - path => Mandatory, path to a character or block device on the host
 - destpath => Optional, alternative path inside the container

The function will allow the node in the container's devices cgroup and
then create the entry in the container.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
12 years agolxc-create: do not use 'local'
Natanael Copa [Mon, 26 Nov 2012 11:00:44 +0000 (12:00 +0100)] 
lxc-create: do not use 'local'

Apparently 'local' is not POSIX. Don't use it.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agolxc-create: fix passing over first argument to template script
Natanael Copa [Thu, 22 Nov 2012 13:16:23 +0000 (14:16 +0100)] 
lxc-create: fix passing over first argument to template script

The e60a8164c12d565f70071ff6b32b823dd495df9e introduced a bug that caused
first argument passed over to the template script get lost.

This patch fixes it.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agolxc-create: use posix shell instead of bash
Natanael Copa [Fri, 16 Nov 2012 16:01:55 +0000 (17:01 +0100)] 
lxc-create: use posix shell instead of bash

- use '[ -x /path/prog ]' instead of 'type /path/prog'
- avoid getopt --longoptions
- add \ at after && and || when those are at end of line
- make sure condition expands to empty string if variable is empty

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoUse clearer error message on failure to create pidfile
Stéphane Graber [Thu, 15 Nov 2012 15:51:09 +0000 (10:51 -0500)] 
Use clearer error message on failure to create pidfile

As suggested by Serge Hallyn on lxc-devel.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agolxc-start: add option -p, --pidfile=FILE
Natanael Copa [Thu, 15 Nov 2012 13:52:16 +0000 (14:52 +0100)] 
lxc-start: add option -p, --pidfile=FILE

Add option to create a pidfile for lxc-start. This is helpful for
init scripts and process monitors when running as daemon.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoFix package name needed for building docs with RPM
Dwight Engen [Wed, 14 Nov 2012 15:44:35 +0000 (10:44 -0500)] 
Fix package name needed for building docs with RPM

Tested on Oracle Linux 6 and Fedora 17

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoensure btrfs subvolume is removed when container creating fails
Frederic Crozat [Wed, 14 Nov 2012 15:11:08 +0000 (16:11 +0100)] 
ensure btrfs subvolume is removed when container creating fails

Signed-off-by: Frederic Crozat <fcrozat@suse.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agodont fail on failure to link kmsg
Serge Hallyn [Wed, 14 Nov 2012 03:35:51 +0000 (21:35 -0600)] 
dont fail on failure to link kmsg

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoAdd the test binaries to .gitignore
Stéphane Graber [Wed, 14 Nov 2012 00:36:05 +0000 (19:36 -0500)] 
Add the test binaries to .gitignore

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoCheck return value of all system calls in startone
Stéphane Graber [Wed, 14 Nov 2012 00:35:17 +0000 (19:35 -0500)] 
Check return value of all system calls in startone

One of the system() calls in src/tests/startone.c wasn't checked.
This was causing a build failure now that -Wall -Werror are set by default.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoswitch use of #define with static char*
Serge Hallyn [Tue, 13 Nov 2012 23:54:01 +0000 (17:54 -0600)] 
switch use of #define with static char*

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoRevert "Fix check against LXCROOTFSMOUNT to use strcmp"
Serge Hallyn [Tue, 13 Nov 2012 23:50:35 +0000 (17:50 -0600)] 
Revert "Fix check against LXCROOTFSMOUNT to use strcmp"

This reverts commit 5bf2c5ce9ba2539efbf81928ef6ccb96d959bcf8.

12 years agoInitialize curtime to silence spurious compiler warning
Serge Hallyn [Tue, 13 Nov 2012 23:49:13 +0000 (17:49 -0600)] 
Initialize curtime to silence spurious compiler warning

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agolxc-ssh: fix message about ssh key insertion
Serge Hallyn [Tue, 13 Nov 2012 23:19:13 +0000 (17:19 -0600)] 
lxc-ssh: fix message about ssh key insertion

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoFix reverse check: error out only if mkdir(cgroup/lxc) fails NOT due to -EEXIST
Serge Hallyn [Tue, 13 Nov 2012 23:17:25 +0000 (17:17 -0600)] 
Fix reverse check: error out only if mkdir(cgroup/lxc) fails NOT due to -EEXIST

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agolxc-create: Support passing a full path to -t
Stéphane Graber [Mon, 12 Nov 2012 21:41:14 +0000 (16:41 -0500)] 
lxc-create: Support passing a full path to -t

In some cases it may be useful to pass a full path to an executable
template script directly to lxc-create.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agolxc-ls: Don't exit 1 when no container or help
Stéphane Graber [Mon, 12 Nov 2012 21:20:53 +0000 (16:20 -0500)] 
lxc-ls: Don't exit 1 when no container or help

lxc-ls is currently exiting with return code 1 when called with --help
or when called on a system without containers.

This behaviour isn't documented in the manpage and isn't terribly intuitive.
It's been the source of quite a few weird failures in scripts running with
set -e.

As a user calling --help is a voluntary action, lxc-ls should exit 0.

Also, as lxc-ls's goal is solely to list containers, showing an error and
exiting with return code 1 when there's no container seems counter-intuitive
and error-prone.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoUpdate .gitignore for current list of binaries and templates
Stéphane Graber [Mon, 12 Nov 2012 20:56:41 +0000 (15:56 -0500)] 
Update .gitignore for current list of binaries and templates

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoDetect which name to use for docbook2x-man
Stéphane Graber [Mon, 12 Nov 2012 20:38:50 +0000 (15:38 -0500)] 
Detect which name to use for docbook2x-man

docbook2x-man doesn't have the same name on Debian based systems as
on RedHat based systems, add some magic to configure.ac to detect and
substitute the proper name in Makefile.am

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoUpdate documentation to Docbook 4.5
Peter Simons [Sat, 20 Oct 2012 09:47:22 +0000 (11:47 +0200)] 
Update documentation to Docbook 4.5

The package 'docbook-tools' [1] required to format Docbook 3.0 into man pages
has been obsoleted a long time ago and can no longer be downloaded from its
former homepage. Recent versions of that package -- now called 'docbook2X' --,
cannot deal with that old markup format anymore (and don't support the '-w all'
command line switch either). To remedy these issues, all SGML files have been
updated to Docbook 4.5 so that recent versions of docbook2man can process them.

[1] http://sources.redhat.com/docbook-tools/
[2] http://docbook2x.sourceforge.net/

Signed-off-by: Peter Simons <simons@cryp.to>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoUpdated README and INSTALL. autogen.sh command should be run before configure.
Frank Scholten [Fri, 26 Oct 2012 17:22:26 +0000 (19:22 +0200)] 
Updated README and INSTALL. autogen.sh command should be run before configure.

Signed-off-by: Frank Scholten <frank@frankscholten.nl>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoFix check against LXCROOTFSMOUNT to use strcmp
Stéphane Graber [Mon, 12 Nov 2012 19:39:43 +0000 (14:39 -0500)] 
Fix check against LXCROOTFSMOUNT to use strcmp

The check for conf->rootfs.mount not being equal to LXCROOTFSMOUNT
wasn't done with strcmp which was leading to undefined behaviour
and triggered gcc warnings.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoFix autogen failing because of clean/distclean overrides
Stéphane Graber [Mon, 12 Nov 2012 19:33:55 +0000 (14:33 -0500)] 
Fix autogen failing because of clean/distclean overrides

A previous patch added a clean/distclean target to config/Makefile.am.
This conflicts with automake's own target.

This change replaces those by a clean-local and distclean-local target.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoSet automake flags and CFLAGS
Stéphane Graber [Mon, 12 Nov 2012 19:32:39 +0000 (14:32 -0500)] 
Set automake flags and CFLAGS

Set automake's flags to -Wall -Werror as well as the general
CFLAGS to -Wall and -Werror when building using gcc.

This should catch any regression on build warnings now that we are in
a pretty clean state.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoReinstate README file in rootfs directory
Dwight Engen [Thu, 25 Oct 2012 17:46:34 +0000 (13:46 -0400)] 
Reinstate README file in rootfs directory

Change 5fd8314f removed the README file explaining why the
rootfs directory has to exist. Doing so broke the build on
Fedora 17 since this directory will not be created by make
install and thus the spec file cannot find it.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agobuild: make sure to expand all variables that are substituted.
Diego Elio Pettenò [Sun, 11 Nov 2012 04:55:10 +0000 (20:55 -0800)] 
build: make sure to expand all variables that are substituted.

This fixes lxc-sshd still referring to '${libdir}'.

Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agolxc-start-ephemeral: Wipe the whole container on exit, not just the rootfs
Stéphane Graber [Wed, 31 Oct 2012 07:20:52 +0000 (08:20 +0100)] 
lxc-start-ephemeral: Wipe the whole container on exit, not just the rootfs

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoRevert "Update documentation to Docbook 4.5"
Stéphane Graber [Wed, 24 Oct 2012 18:41:07 +0000 (20:41 +0200)] 
Revert "Update documentation to Docbook 4.5"

This reverts commit 9a84044bc97098821cce2721ea40a1368f17a091.

The changes made the branch to fail to build on Ubuntu/Debian, so
reverting the commits and re-opening the pull request.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoRevert "Convert remaining file to new docbook format"
Stéphane Graber [Wed, 24 Oct 2012 18:41:01 +0000 (20:41 +0200)] 
Revert "Convert remaining file to new docbook format"

This reverts commit 8587ac4b855b7b66931a37742c45cd2c8c624658.

The changes made the branch to fail to build on Ubuntu/Debian, so
reverting the commits and re-opening the pull request.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoConvert remaining file to new docbook format
Stéphane Graber [Wed, 24 Oct 2012 13:32:52 +0000 (15:32 +0200)] 
Convert remaining file to new docbook format

12 years agoUpdate documentation to Docbook 4.5
Peter Simons [Sat, 20 Oct 2012 09:47:22 +0000 (11:47 +0200)] 
Update documentation to Docbook 4.5

The package 'docbook-tools' [1] required to format Docbook 3.0 into man pages
has been obsoleted a long time ago and can no longer be downloaded from its
former homepage. Recent versions of that package -- now called 'docbook2X' --,
cannot deal with that old markup format anymore (and don't support the '-w all'
command line switch either). To remedy these issues, all SGML files have been
updated to Docbook 4.5 so that recent versions of docbook2man can process them.

[1] http://sources.redhat.com/docbook-tools/
[2] http://docbook2x.sourceforge.net/

Signed-off-by: Peter Simons <simons@cryp.to>
12 years agopython-lxc: Add missing space between two help lines
Stéphane Graber [Fri, 19 Oct 2012 21:06:12 +0000 (23:06 +0200)] 
python-lxc: Add missing space between two help lines

One character fix making the documentation readable in help()

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoAdd distro config file /etc/lxc/lxc.conf
Dwight Engen [Thu, 18 Oct 2012 16:50:02 +0000 (12:50 -0400)] 
Add distro config file /etc/lxc/lxc.conf

[PATCH] Clean the lxc.conf file

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoAdd distro config file /etc/lxc/lxc.conf
Dwight Engen [Wed, 17 Oct 2012 17:28:27 +0000 (13:28 -0400)] 
Add distro config file /etc/lxc/lxc.conf

This allows a distro to put the distro specific default network
configuration (for example bridge device, link type), or other lxc
configuration in the case that -f is not passed by the user to
lxc-create, in which case lxc-create will use the distro conf file as
the basis for the containers config.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoHonor network type and link from lxc-create -f
Dwight Engen [Mon, 15 Oct 2012 13:42:26 +0000 (09:42 -0400)] 
Honor network type and link from lxc-create -f

Make the oracle template honor the lxc.network.type and
lxc.network.link configuration items if a "base" configuration file is
passed to lxc-create. If no configuration file is passed and the host
system is Oracle or Fedora, the template assumes a type of veth and
the default name created by libvirt.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
12 years agoFix removal of unneeded startup/shutdown scripts
Dwight Engen [Mon, 15 Oct 2012 13:42:18 +0000 (09:42 -0400)] 
Fix removal of unneeded startup/shutdown scripts

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
12 years agoAlways rebuild rpm database
Dwight Engen [Mon, 15 Oct 2012 13:42:10 +0000 (09:42 -0400)] 
Always rebuild rpm database

Always rebuild the rpm database with the guest's rpm so there are no
db version mismatches when you boot the guest and run rpm or yum.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
12 years agoBetter rpm database downgrade logic
Dwight Engen [Mon, 15 Oct 2012 13:42:02 +0000 (09:42 -0400)] 
Better rpm database downgrade logic

Use the file command to see if the rpm database version needs to
be downgraded. Use the lsb_release command to determine the host
system, which is then used to set the commands needed to do the
conversion, and lets us move the rpm database to the correct location
if the host rpm doesn't put it where the guest expects it to be.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
12 years agoadd oracle template (From: Dwight Engen)
Serge Hallyn [Fri, 5 Oct 2012 21:40:21 +0000 (16:40 -0500)] 
add oracle template  (From: Dwight Engen)

This is a new template to create containers based on Oracle Linux. A version
such as 5.8, 6.3, or 6.latest can be specified with -R in which case a rootfs
will be created from rpms downloaded from the Oracle public-yum repo.
Alternatively the path to an existing rootfs of Oracle 5 or 6 may be given to
the template with the -t option.

The architecture of the downloaded rpms installed in the container can be
specified with the -a template option.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agofix minor spelling error
Dwight Engen [Wed, 26 Sep 2012 16:59:24 +0000 (12:59 -0400)] 
fix minor spelling error

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
12 years agoSupport individual hook types in clear_config_item
Serge Hallyn [Fri, 14 Sep 2012 19:42:24 +0000 (14:42 -0500)] 
Support individual hook types in clear_config_item

Without this patch, only clear_config_item("lxc.hook") works.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoapi shutdown: don't c->stop() if already stopped.
Serge Hallyn [Thu, 13 Sep 2012 14:41:01 +0000 (09:41 -0500)] 
api shutdown: don't c->stop() if already stopped.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoapi_test.py: Remove workarounds for API bugs
Stéphane Graber [Thu, 13 Sep 2012 14:31:24 +0000 (10:31 -0400)] 
api_test.py: Remove workarounds for API bugs

The script used to contain a workaround for back when create()
wouldn't properly flush the config and reload it.
As these issues have now been fixed, these workarounds can be removed.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agolxc-start-ephemeral: startup time improvement
Stéphane Graber [Thu, 13 Sep 2012 14:08:39 +0000 (10:08 -0400)] 
lxc-start-ephemeral: startup time improvement

Re-organize the code to only call get_ips() when we actually need
the IP address of the container.

Also bump the timeout for get_ips() from 5s to 10s to accomodate
slower machines.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agolxc-start-ephemeral: Exit with command return code
Stéphane Graber [Thu, 13 Sep 2012 14:04:57 +0000 (10:04 -0400)] 
lxc-start-ephemeral: Exit with command return code

When using lxc-start-ephemeral to directly call a command, return
ssh's return code (the command's return code) when exiting.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agolxc-start-ephemeral: Drop stop() calls when shutdown() returns non-True
Stéphane Graber [Thu, 13 Sep 2012 14:03:21 +0000 (10:03 -0400)] 
lxc-start-ephemeral: Drop stop() calls when shutdown() returns non-True

shutdown() when given a timeout already does a stop call so there's no
need to check its return value and do another one.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agolxc-start-ephemeral: Add missing return call to wait override
Stéphane Graber [Wed, 12 Sep 2012 17:12:50 +0000 (13:12 -0400)] 
lxc-start-ephemeral: Add missing return call to wait override

When overriding wait(), I forgot to actually return the value coming
from the C binding...

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agolxc-start-ephemeral: Fix typo causing crash at startup
Stéphane Graber [Wed, 12 Sep 2012 16:48:34 +0000 (12:48 -0400)] 
lxc-start-ephemeral: Fix typo causing crash at startup

Apparently a ")" was dropped in a recent change, causing
lxc-start-ephemeral to fail to start completely (invalid syntax).

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agofix expansion of LXCPATH,LXCROOTFSMOUNT,LXCTEMPLATEDIR
Dwight Engen [Tue, 11 Sep 2012 21:06:05 +0000 (17:06 -0400)] 
fix expansion of LXCPATH,LXCROOTFSMOUNT,LXCTEMPLATEDIR

These variables are not expanded correctly in doc/lxc-create.sgml.in
and a workaround is in place to ensure ${localstatedir}, and ${datadir}
are set in the various shell scripts that use it. There is no workaround
to ensure ${datadir} is set in src/lxc/lxc-create.in, nor is
${localstatedir} set in templates/lxc-altlinux.in so I think that these
are currently broken.

Using AS_AC_EXPAND instead of AC_SUBST fixes these problems and removes
the need for the workarounds. In addition the lxc-start-ephemeral.in
script can be autoconf'ed instead of sed'ed by the makefile.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
12 years agofix gcc error: typedef redefinition (against git staging)
Dwight Engen [Mon, 10 Sep 2012 18:26:36 +0000 (14:26 -0400)] 
fix gcc error: typedef redefinition (against git staging)

Fix gcc error confile.c:83: error: redefinition of typedef ‘config_cb’.
Its already defined the same way in confile.h.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@canonical.com>
12 years agofix compile without apparmor (against git staging)
Dwight Engen [Mon, 10 Sep 2012 18:26:43 +0000 (14:26 -0400)] 
fix compile without apparmor (against git staging)

Add a few missing #if's to fix compilation when configured without
AppArmor.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@canonical.com>
12 years agopython-lxc: Always convert state passed to wait() to uppercase
Stéphane Graber [Mon, 10 Sep 2012 18:06:06 +0000 (14:06 -0400)] 
python-lxc: Always convert state passed to wait() to uppercase

At Serge's suggestion, always convert the state passed to the wait()
function in the python API to its uppercase equivalent.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoPrefix the test binaries by lxc-test-
Stéphane Graber [Sun, 9 Sep 2012 17:14:38 +0000 (13:14 -0400)] 
Prefix the test binaries by lxc-test-

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agocheck return values of scanf and system
Serge Hallyn [Fri, 7 Sep 2012 22:52:06 +0000 (17:52 -0500)] 
check return values of scanf and system

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agocheck sscanf return value
Serge Hallyn [Fri, 7 Sep 2012 22:48:29 +0000 (17:48 -0500)] 
check sscanf return value

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoFix previous commit, removing hardcoded /var/lib/lxc from lxc-start-ephemeral
Stéphane Graber [Fri, 7 Sep 2012 18:53:19 +0000 (14:53 -0400)] 
Fix previous commit, removing hardcoded /var/lib/lxc from lxc-start-ephemeral

The previous commit was missing part of the changes, leading to a non-working
version of lxc-start-ephemeral.

This commit adds the missing parts.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoRemove hardcoded /var/lib/lxc from lxc-start-ephemeral
Stéphane Graber [Fri, 7 Sep 2012 18:37:58 +0000 (14:37 -0400)] 
Remove hardcoded /var/lib/lxc from lxc-start-ephemeral

Add dependency on sed and add a Makefile.am section for lxc-start-ephemeral
so that it gets updated at build time for the right container path.

12 years agoAdd lxc-start-ephemeral
Stéphane Graber [Fri, 7 Sep 2012 17:11:05 +0000 (13:11 -0400)] 
Add lxc-start-ephemeral

This commit adds lxc-start-ephemeral as a python script using the
new python-lxc API.

This script is somewhat similar to lxc-clone except that it uses
overlayfs or aufs to provide an overlay on top of the source container.

It also allows the user to directly run a command in the container using
SSH and can fetch the IP address from the container when starting the
container in the background.

The initial work on lxc-start-ephemeral was done by Serge Hallyn in Ubuntu,
this is a re-implementation of it using python and the new LXC hooks.

Compared to the shell implementation, there are three notable differences:
 - When starting without a command, lxc-start-ephemeral now attaches to tty1
 - When starting in the background (-d), the name and IP of the container is
   shown on screen.
 - A new "-k" option is added, allowing the user to keep the ephemeral
   container after shutdown. This turns off the tmpfs backend and sets up the
   hooks so that the container can be started/stopped multiple times.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agodual-fork for daemonized fork in lxcapi-start
Serge Hallyn [Fri, 7 Sep 2012 16:14:04 +0000 (11:14 -0500)] 
dual-fork for daemonized fork in lxcapi-start

So the container will be reparented by init.  Otherwise children of the
lxc-start might be reaped by python3 rather than lxc-start.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoRemove zombie_handler from python-lxc code
Stéphane Graber [Fri, 7 Sep 2012 14:50:36 +0000 (10:50 -0400)] 
Remove zombie_handler from python-lxc code

This code was addeed to deal with stopped/dead containers but
really shouldn't be implemented there. Instead the setsid() call in
start() should be enough to prevent python from getting the SIGCHLD and
having to deal with it.

12 years agoRaise exception when getting Container instance as non-root in python3-lxc
Stéphane Graber [Thu, 6 Sep 2012 20:06:27 +0000 (16:06 -0400)] 
Raise exception when getting Container instance as non-root in python3-lxc

The liblxc API currently doesn't work as non-root, so check that the euid
is 0 when getting a Container instance in the python API.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agopremount hook is implemented in git
Serge Hallyn [Thu, 6 Sep 2012 17:45:16 +0000 (12:45 -0500)] 
premount hook is implemented in git

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agodocument lxc.hooks in lxc.conf manpage
Serge Hallyn [Thu, 6 Sep 2012 17:26:29 +0000 (12:26 -0500)] 
document lxc.hooks in lxc.conf manpage

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoAdd lxc_conf_free()
Serge Hallyn [Thu, 6 Sep 2012 02:55:38 +0000 (21:55 -0500)] 
Add lxc_conf_free()

Then after lxcapi container->create(), free whatever lxc_conf may be
loaded and reload from the newly created configuration file.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoget_item(utsname): don't dereference utsname if it is NULL
Serge Hallyn [Tue, 4 Sep 2012 23:06:44 +0000 (18:06 -0500)] 
get_item(utsname): don't dereference utsname if it is NULL

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoFix passing non-const char* in for const char*
Serge Hallyn [Tue, 4 Sep 2012 19:18:03 +0000 (14:18 -0500)] 
Fix passing non-const char* in for const char*

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agocheck chdir(/) return value
Serge Hallyn [Tue, 4 Sep 2012 19:10:40 +0000 (14:10 -0500)] 
check chdir(/) return value

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoreplace HOOK define with proper code.
Serge Hallyn [Tue, 4 Sep 2012 18:57:39 +0000 (13:57 -0500)] 
replace HOOK define with proper code.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoAdd better example/test of the python3-lxc API
Stéphane Graber [Sun, 2 Sep 2012 02:55:03 +0000 (22:55 -0400)] 
Add better example/test of the python3-lxc API

Replaced python-lxc/test.py by a new api_test.py script that
uses all the available function of the API to run a batch of
basic tests.

This example is useful both as a test of the API and as a guide on
how to use the python API to manage containers.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoRemove unused v1 and v2 variables in main()
Stéphane Graber [Sun, 2 Sep 2012 00:25:28 +0000 (20:25 -0400)] 
Remove unused v1 and v2 variables in main()

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoCleanup lxc_wait
Stéphane Graber [Sun, 2 Sep 2012 00:22:39 +0000 (20:22 -0400)] 
Cleanup lxc_wait

 - Remove unused timeout_handler function.
 - Remove unsused variables from main()

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoRemove unused "i" variable in lxc_get_item_nic
Stéphane Graber [Sun, 2 Sep 2012 00:19:53 +0000 (20:19 -0400)] 
Remove unused "i" variable in lxc_get_item_nic

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoChange lxc_remove_nic from returning int to void
Stéphane Graber [Sun, 2 Sep 2012 00:17:32 +0000 (20:17 -0400)] 
Change lxc_remove_nic from returning int to void

The function wasn't returning anything and none of the callers
were checking for a return code.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoMake building the API tests/examples optional
Stéphane Graber [Sat, 1 Sep 2012 23:57:11 +0000 (19:57 -0400)] 
Make building the API tests/examples optional

Add a new --enable-tests option to configure which is used to
optionally build the tests/examples. Default is off.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoAdd lxc.hook.pre-mount
Serge Hallyn [Fri, 31 Aug 2012 17:25:38 +0000 (12:25 -0500)] 
Add lxc.hook.pre-mount

This happens in the container's namespace, but before the rootfs is
setup and mounted.  This gives us a chance to mangle the rootfs - i.e.
ecryptfs-mount it.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agolxc-wait: initialize timeout to -1
Serge Hallyn [Fri, 31 Aug 2012 16:28:42 +0000 (11:28 -0500)] 
lxc-wait: initialize timeout to -1

Otherwise it defaults to 0, meaning don't wait.  -1 means wait forever,
which is what we want as the default behavior.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoAdd lxc.aa_profile example to all templates
Stéphane Graber [Wed, 29 Aug 2012 16:27:53 +0000 (09:27 -0700)] 
Add lxc.aa_profile example to all templates

LXC has optional apparmor support, default profile is lxc-container-default.
This change adds a commented "lxc.aa_profile = default" line to all templates,
uncommenting this will bypass apparmor for the container.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoRename runapitests.bash to runapitests.sh and make it use /bin/sh
Stéphane Graber [Tue, 28 Aug 2012 17:53:30 +0000 (13:53 -0400)] 
Rename runapitests.bash to runapitests.sh and make it use /bin/sh

This is a simple POSIX shell script, so no need for the weird extension
or for the explicit use of /bin/bash

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoRemove duplicate copy of runapitests.bash
Stéphane Graber [Tue, 28 Aug 2012 17:51:02 +0000 (13:51 -0400)] 
Remove duplicate copy of runapitests.bash

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoAdd python-lxc based on the new liblxc API.
Stéphane Graber [Mon, 27 Aug 2012 23:04:43 +0000 (19:04 -0400)] 
Add python-lxc based on the new liblxc API.

This adds a basic python binding done in C and a python overlay to
extend some features and provide a user-friendlier API.

This python API only supports python 3.x and was tested with >= 3.2.

It's disabled by default in configure and can be turned on by using
--enable-python.

A basic example of the API can be found in src/python-lxc/test.py.
More documentation and examples will be added soon.

12 years agoWhen starting a container daemonized, wait for it to reach RUNNING state before retur...
Stéphane Graber [Mon, 27 Aug 2012 23:01:36 +0000 (19:01 -0400)] 
When starting a container daemonized, wait for it to reach RUNNING state before returning the result of start().

If the container doesn't reach RUNNING state in 5 seconds, a failure will be
returned to the user.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agoMerge the liblxc API work by Serge Hallyn.
Stéphane Graber [Mon, 27 Aug 2012 22:53:00 +0000 (18:53 -0400)] 
Merge the liblxc API work by Serge Hallyn.

This turns liblxc into a public library implementing a container structure.
The container structure is meant to cover most LXC commands and can easily be
used to write bindings in other programming languages.

More information on the new functions can be found in src/lxc/lxccontainer.h
Test programs using the API can also be found in src/tests/

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
12 years agolxc-attach: Add -R option to remount /sys and /proc when only partially attaching
Christian Seiler [Tue, 21 Aug 2012 22:03:16 +0000 (00:03 +0200)] 
lxc-attach: Add -R option to remount /sys and /proc when only partially attaching

When attaching to only some namespaces of the container but not the mount
namespace, the contents of /sys and /proc of the host system do not properly
reflect the context of the container's pid and/or network namespaces, and
possibly others.

The introduced -R option adds the possibility to additionally unshare the
mount namespace (when it is not being attached) and remount /sys and /proc
in order for those filesystems to properly reflect the container's context
even when only attaching to some of the namespaces.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Cc: Daniel Lezcano <daniel.lezcano@free.fr>
12 years agolxc-attach: Add -s option to select namespaces to attach to
Christian Seiler [Tue, 21 Aug 2012 22:03:15 +0000 (00:03 +0200)] 
lxc-attach: Add -s option to select namespaces to attach to

This patch allows the user to select any list of namespaces (network, pid,
mount, uts, ipc, user) that lxc-attach should use when attaching to the
container; all other namespaces will not be attached to.

This allows the user to for example attach to just the network namespace and
use the host's (and not the container's) network tools to reconfigure the
network of the container.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Cc: Daniel Lezcano <daniel.lezcano@free.fr>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
12 years agolxc-unshare: Move functions to determine clone flags from command line options to...
Christian Seiler [Tue, 21 Aug 2012 22:03:14 +0000 (00:03 +0200)] 
lxc-unshare: Move functions to determine clone flags from command line options to namespace.c

In order to be able to reuse code in lxc-attach, the functions
lxc_namespace_2_cloneflag and lxc_fill_namespace_flags are moved from
lxc_unshare.c to namespace.c.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Cc: Daniel Lezcano <daniel.lezcano@free.fr>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
12 years agolxc-attach: Detect which namespaces to attach to dynamically
Christian Seiler [Tue, 21 Aug 2012 22:03:13 +0000 (00:03 +0200)] 
lxc-attach: Detect which namespaces to attach to dynamically

Use the command interface to contact lxc-start to receive the set of
flags passed to clone() when starting the container. This allows lxc-attach
to determine which namespaces were used for the container and select only
those to attach to.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Cc: Daniel Lezcano <daniel.lezcano@free.fr>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
12 years agolxc-attach: Remodel cgroup attach logic and attach to namespaces again in parent...
Christian Seiler [Tue, 21 Aug 2012 22:03:12 +0000 (00:03 +0200)] 
lxc-attach: Remodel cgroup attach logic and attach to namespaces again in parent process

With the introduction of lxc-attach's functionality to attach to cgroups,
the setns() calls were put in the child process after the fork() and not the
parent process before the fork() so the parent process remained outside the
namespaces and could add the child to the correct cgroup.

Unfortunately, the pid namespace really affects only children of the current
process and not the process itself, which has several drawbacks: The
attached program does not have a pid inside the container and the context
that is used when remounting /proc from that process is wrong. Thus, the
previous logic of first setting the namespaces and then forking so the child
process (which then exec()s to the desired program) is a real member of the
container.

However, inside the container, there is no guarantee that the cgroup
filesystem is still be mounted and that we are allowed to write to it (which
is why the setns() was moved in the first place).

To work around both problems, we separate the cgroup attach functionality
into two parts: Preparing the attach process, which just opens the tasks
files of all cgroups and keeps the file descriptors open and the writing to
those fds part. This allows us to open all the tasks files in lxc_attach,
then call setns(), then fork, in the child process close them completely and
in the parent process just write the pid of the child process to all those
fds.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Cc: Daniel Lezcano <daniel.lezcano@free.fr>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
12 years agolxc-start: Add command to retrieve the clone flags used to start the container.
Christian Seiler [Tue, 21 Aug 2012 22:03:11 +0000 (00:03 +0200)] 
lxc-start: Add command to retrieve the clone flags used to start the container.

Add the LXC_COMMAND_CLONE_FLAGS that retrieves the flags passed to clone(2)
when the container was started. This allows external programs to determine
which namespaces the container was unshared from.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Cc: Daniel Lezcano <daniel.lezcano@free.fr>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
12 years agolxc-create: Make location of container rootfs configurable
Serge Hallyn [Tue, 21 Aug 2012 15:11:23 +0000 (10:11 -0500)] 
lxc-create: Make location of container rootfs configurable

Make 'dir' an explicit backing store type, which accepts '--dir rootfs'
as an option to specify a custom location for the container rootfs.  Also
update lxc-destroy to now remove the rootfs separately, as removing
@LXCPATH@/$name may not hit it.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoAdd network-down script
Jan Kiszka [Mon, 9 Jul 2012 17:15:48 +0000 (19:15 +0200)] 
Add network-down script

Analogously to lxc.network.script.up, add the ability to register a down
script. It is called before the guest network is finally destroyed,
allowing to clean up resources that are not reset/destroyed
automatically. Parameters of the down script are identical to the up
script except for the execution context "down".

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoMakefile.am: use right .h file name for seccomp
Serge Hallyn [Fri, 17 Aug 2012 19:06:34 +0000 (14:06 -0500)] 
Makefile.am: use right .h file name for seccomp

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agofix configure.ac for seccomp and apparmor
Serge Hallyn [Fri, 17 Aug 2012 18:04:34 +0000 (13:04 -0500)] 
fix configure.ac for seccomp and apparmor

Use --enable-XXX=check when not specified to get reasonable defaults.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
12 years agoseccomp: include lxcseccomp.h in start.c
Serge Hallyn [Thu, 16 Aug 2012 20:07:51 +0000 (15:07 -0500)] 
seccomp: include lxcseccomp.h in start.c

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>