]> git.proxmox.com Git - mirror_lxc.git/log
mirror_lxc.git
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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.

11 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>
11 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>
11 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.

11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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.

11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 years agoconfile: support 'lxc.include' option to include other config files
Serge Hallyn [Thu, 9 Aug 2012 23:00:58 +0000 (18:00 -0500)]
confile: support 'lxc.include' option to include other config files

For instance

lxc.include = /var/lib/lxc/commonopts

in /var/lib/lxc/q1/config would cause the configuration in
/var/lib/lxc/commonopts to be loaded when container q1 starts.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoIntroduce support for seccomp.
Serge Hallyn [Sat, 28 Jul 2012 02:13:53 +0000 (21:13 -0500)]
Introduce support for seccomp.

Hi,

This patch is so far just a proof of concept.  The libseccomp api will be
changing soon so it probably wouldn't be worth pulling this until it is
updated for the new API.

This patch introduces support for seccomp to lxc.  Seccomp lets a program
restrict its own (and its children's) future access to system calls.  It
uses a simple whitelist system call policy file.  It would probably be
better to switch to something more symbolic (i.e specifying 'open' rather
than the syscall #, especially given container arch flexibility).

I just wanted to get this out there as a first step.  You can also get
source for an ubuntu package based on this patch at
https://code.launchpad.net/~serge-hallyn/ubuntu/quantal/lxc/lxc-seccomp

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
11 years agolxc-wait: Add timeout option
Jan Kiszka [Thu, 9 Aug 2012 22:54:48 +0000 (17:54 -0500)]
lxc-wait: Add timeout option

Allow to specify a timeout for waiting on state changes via lxc-wait.
Helpful for scripts that need to handle errors or excessive delays in
state changing procedures.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoVersion 0.8.0
Daniel Lezcano [Sun, 11 Nov 2012 02:34:22 +0000 (03:34 +0100)]
Version 0.8.0

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
11 years agofix git location
Daniel Lezcano [Sun, 11 Nov 2012 02:32:43 +0000 (03:32 +0100)]
fix git location

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
11 years agoclearer error message when interface name to long
Daniel Lezcano [Wed, 31 Oct 2012 16:15:25 +0000 (17:15 +0100)]
clearer error message when interface name to long

Signed-off-by: Tomas Pospisek <tpo_deb@sourcepole.ch>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
11 years agoFix lxc-netstat -- argument processing
Dwight Engen [Wed, 31 Oct 2012 16:08:13 +0000 (17:08 +0100)]
Fix lxc-netstat -- argument processing

Commit 21e487f2 introduced the use of getopt, but getopt will fail when
it sees arguments meant for netstat that are not in [short|long]options.
There should not be any ambiguity about arguments with the same letter:
those to the left of the -- are destined for lxc-netstat and those to
the right for the real netstat, which the original code handles by
shifting out all arguments it recognizes before the -- is hit.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
11 years agoFix lxc-ps -- argument processing
Dwight Engen [Thu, 25 Oct 2012 20:21:53 +0000 (16:21 -0400)]
Fix lxc-ps -- argument processing

lxc-ps is supposed to pass arguments after the -- on to ps. The problem is
that i is expanded once from $@ and the loop will iterate over all the
arguments that were in $@ at the time of expansion. Inside the loop, there
are shifts (in the name case for example) that are trying to remove more
than a single argument. This changes fixes that and makes lxc-ps work as
documented.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
11 years agoRemove unneeded ksrc spec file macro
Dwight Engen [Wed, 31 Oct 2012 16:08:13 +0000 (17:08 +0100)]
Remove unneeded ksrc spec file macro

Change 910bb4fa obviated the need for the --with-linuxdir configure
option which means that the ksrc rpm macro no longer makes sense either.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
11 years agoAdd %{dist} tag to differentiate RPM distributions and releases
Dwight Engen [Wed, 31 Oct 2012 16:08:13 +0000 (17:08 +0100)]
Add %{dist} tag to differentiate RPM distributions and releases

Note that an additional Release field is not necessary for the devel package
as it will follow the primary Release field. For more information on the dist
tag, see http://fedoraproject.org/wiki/Packaging:DistTag

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
11 years agoMerge branch 'upstream-bugfix' of https://github.com/lxc/lxc
Daniel Lezcano [Wed, 31 Oct 2012 15:39:50 +0000 (16:39 +0100)]
Merge branch 'upstream-bugfix' of https://github.com/lxc/lxc

* 'upstream-bugfix' of https://github.com/lxc/lxc: (47 commits)
  replace HOOK define with proper code.
  Remove lxc-start-ephemeral from configure.ac
  revert devtmpfs in ubuntu templates
  lxc-ubuntu{-cloud}: Fix missing "fi" in new devtmpfs code
  fix "make rpm"
  display warning when yum missing in fedora template
  templates: mount devtmpfs in ubuntu containers
  handle clone of btrfs snapshots
  if the rootfs is a btrfs subvolume, delete it instead of rm -rf
  lxc-debian: replace isc-dhcp-server by isc-dhcp-client
  lxc-ls: Scan cgroup mount points from fstype and not device
  Allow short -h and -n options to lxc-ps
  lxc-ubuntu: fix printing of default user
  lxc-debian: specify isc-dhcp-server in package list
  try to better handle out of date container caches.
  link /dev/kmsg to /dev/console in the container
  lxc-clone: fix the '--name' parameter
  lxc-ls: Use readlink on $directory
  lxc-busybox: Use relative mounts in lxc.mount.entry
  busybox: for all lib dirs create mounts only if directories exist
  ...

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
11 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>
11 years agoRemove lxc-start-ephemeral from configure.ac
Stéphane Graber [Thu, 25 Oct 2012 08:43:59 +0000 (10:43 +0200)]
Remove lxc-start-ephemeral from configure.ac

lxc-start-ephemeral.in ended up in configure.ac as a result of the
cherry-pick. This new tool hasn't been pulled in yet.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agorevert devtmpfs in ubuntu templates
Serge Hallyn [Wed, 24 Oct 2012 16:05:38 +0000 (11:05 -0500)]
revert devtmpfs in ubuntu templates

devtmpfs is shared between host and containers, and it messes up
lucid containers too.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-ubuntu{-cloud}: Fix missing "fi" in new devtmpfs code
Stéphane Graber [Wed, 24 Oct 2012 11:05:03 +0000 (13:05 +0200)]
lxc-ubuntu{-cloud}: Fix missing "fi" in new devtmpfs code

The "if" statement to add devtmpfs was missing a matching "fi" causing parsing
error when using the template.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofix "make rpm"
Dwight Engen [Thu, 4 Oct 2012 16:28:38 +0000 (12:28 -0400)]
fix "make rpm"

RPM doesn't like "-" in the version number and gives:
"error: line 24: Illegal char '-' in: Version: 0.8.0-rc2"
Other packages (bind-utils for example) have used . instead
of - as a seperator.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agodisplay warning when yum missing in fedora template
Dwight Engen [Thu, 4 Oct 2012 17:12:41 +0000 (13:12 -0400)]
display warning when yum missing in fedora template

This early exit is preventing the warning message that follows it from
being shown.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
11 years agotemplates: mount devtmpfs in ubuntu containers
Serge Hallyn [Thu, 4 Oct 2012 18:54:00 +0000 (13:54 -0500)]
templates: mount devtmpfs in ubuntu containers

That way /dev/disk/ exists, and update-grub can succeed.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1060404

11 years agohandle clone of btrfs snapshots
Dwight Engen [Wed, 26 Sep 2012 17:20:30 +0000 (13:20 -0400)]
handle clone of btrfs snapshots

Fix determination of $oldroot from the config file. The old code had the '
in the wrong place and didn't account for whitespace between the = and
the rootfs.

Set $rootfs based on $oldroot instead of forcing it to be in
$lxc_path/$lxc_new/rootfs. This allows for btrfs snapshot to be made even if
$lxc_path isn't on the same filesystem. If $oldroot isn't a subvolume,
fall back to making a copy.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
11 years agoif the rootfs is a btrfs subvolume, delete it instead of rm -rf
Dwight Engen [Wed, 26 Sep 2012 16:59:28 +0000 (12:59 -0400)]
if the rootfs is a btrfs subvolume, delete it instead of rm -rf

Check if the rootfs is btrfs subvolume, and if so delete it. Otherwise
fall back to the rm -rf.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
11 years agolxc-debian: replace isc-dhcp-server by isc-dhcp-client
Stéphane Graber [Mon, 24 Sep 2012 19:16:25 +0000 (15:16 -0400)]
lxc-debian: replace isc-dhcp-server by isc-dhcp-client

The DHCP client should be isc-dhcp-client, not isc-dhcp-server.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-ls: Scan cgroup mount points from fstype and not device
Christian Seiler [Mon, 24 Sep 2012 09:21:48 +0000 (11:21 +0200)]
lxc-ls: Scan cgroup mount points from fstype and not device

lxc-ls --active now scans mount points that have the 'cgroup' filesystem
type and not the 'cgroup' device name (which is ignored anyway and may be
anything).

Signed-off-by: Christian Seiler <christian@iwakd.de>
Cc: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoAllow short -h and -n options to lxc-ps
Dwight Engen [Tue, 18 Sep 2012 19:58:17 +0000 (15:58 -0400)]
Allow short -h and -n options to lxc-ps

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
11 years agolxc-ubuntu: fix printing of default user
Serge Hallyn [Wed, 19 Sep 2012 17:15:51 +0000 (12:15 -0500)]
lxc-ubuntu: fix printing of default user

If a user is bound into the container, don't claim the default user is
ubuntu.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1052315

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-debian: specify isc-dhcp-server in package list
Serge Hallyn [Wed, 19 Sep 2012 17:14:58 +0000 (12:14 -0500)]
lxc-debian: specify isc-dhcp-server in package list

dhcp3-client does not exist in testing.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1052972

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agotry to better handle out of date container caches.
Serge Hallyn [Fri, 14 Sep 2012 19:43:45 +0000 (14:43 -0500)]
try to better handle out of date container caches.

For a lucid container, apt-get update before installing the source package for
add-apt-repository, so that apt-get does not fail.

If apt-get dist-upgrade fails, suggest running lxc-create with -F.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolink /dev/kmsg to /dev/console in the container
Serge Hallyn [Thu, 13 Sep 2012 14:39:07 +0000 (09:39 -0500)]
link /dev/kmsg to /dev/console in the container

This way init log messages can be seen on the console.  If containerized
syslog ever comes around, we can get rid of this.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-clone: fix the '--name' parameter
Serge Hallyn [Thu, 13 Sep 2012 14:38:11 +0000 (09:38 -0500)]
lxc-clone: fix the '--name' parameter

The long opt for --name was being incorrectly compared to --new.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-ls: Use readlink on $directory
Stéphane Graber [Wed, 12 Sep 2012 22:21:00 +0000 (18:21 -0400)]
lxc-ls: Use readlink on $directory

lxc-ls was failing in cases where $directory is a symlink to another
directory. Instead have $directory be generated from the output of
readlink -f "$lxc_path".

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-busybox: Use relative mounts in lxc.mount.entry
Stéphane Graber [Wed, 12 Sep 2012 19:22:15 +0000 (15:22 -0400)]
lxc-busybox: Use relative mounts in lxc.mount.entry

To make it easier to clone/rename the container, replace hardcoded
entries (with rootfs in the destination path) by rootfs-relative entries.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agobusybox: for all lib dirs create mounts only if directories exist
Stuart Yoder [Wed, 12 Sep 2012 18:15:12 +0000 (13:15 -0500)]
busybox: for all lib dirs create mounts only if directories exist

Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
11 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>
11 years agolxc-rpm-build
Dwight Engen [Tue, 11 Sep 2012 18:30:22 +0000 (14:30 -0400)]
lxc-rpm-build

Fix building of rpm by non-root user. Include templates in rpm, fix rpm path of
lxc-init.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
11 years agolxc-doc-synopsis-args
Dwight Engen [Mon, 10 Sep 2012 20:49:31 +0000 (16:49 -0400)]
lxc-doc-synopsis-args

I was getting raw nroff ".SH DESCRIPTION" in my man pages. This fixes
the synopsis cmd args so that doesn't happen. Added replaceable to a few
arguments.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
11 years agolxc-pkgconfig-dir
Dwight Engen [Mon, 10 Sep 2012 14:28:37 +0000 (10:28 -0400)]
lxc-pkgconfig-dir

Put pkg-config .pc file in libdir.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
11 years agolog errno when pclose fails
Serge Hallyn [Fri, 7 Sep 2012 03:16:55 +0000 (22:16 -0500)]
log errno when pclose fails

When lxc is executing a script and pclose fails, log the
errno to help debug what happened.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoPass the container name to copy_configuration in lxc-lenny
Stéphane Graber [Thu, 6 Sep 2012 14:59:57 +0000 (10:59 -0400)]
Pass the container name to copy_configuration in lxc-lenny

This fixes a case where lxc.utsname would be set empty as copy_configuration
wasn't getting the container name.

Signed-off-by: Rex Tsai (蔡志展) <rex.tsai@canonical.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAdd SIGINT and SIGPWR handler in lxc-debian
Stéphane Graber [Thu, 6 Sep 2012 14:57:20 +0000 (10:57 -0400)]
Add SIGINT and SIGPWR handler in lxc-debian

This adds a SIGINIT and SIGPWR handler in the default inittab for
the Debian template. This allows lxc-shutdown/lxc-restart and their API calls
to properly shutdown or reboot the container.

Signed-off-by: Rex Tsai (蔡志展) <rex.tsai@canonical.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoDon't hardcode path to templates
Stéphane Graber [Thu, 6 Sep 2012 03:54:51 +0000 (23:54 -0400)]
Don't hardcode path to templates

configure.ac used to set the template path to /usr/share/lxc/templates.
Instead use ${datadir} to make it follow ${prefix}.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-destroy: Separately rm rootfs if it is a symlink
Serge Hallyn [Thu, 6 Sep 2012 02:59:13 +0000 (21:59 -0500)]
lxc-destroy: Separately rm rootfs if it is a symlink

If rootfs is a symbolic link but not to a block device, then do a separate
rm of its contents.  We have to do this because, out of cowardice, we call
rm with --one-filesystem.

Removing the '-o -h $rootdev' is ok, because if $rootdev is a symbolic
link to a block device (including lvm blockdev) then -b will still return
true.

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