]> git.proxmox.com Git - mirror_lxc.git/log
mirror_lxc.git
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>
11 years agolxc-ls: Show a simple error message when non-root
Stéphane Graber [Tue, 4 Dec 2012 21:17:08 +0000 (16:17 -0500)]
lxc-ls: Show a simple 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>
11 years agolxc-start-ephemeral: Use argparse errors
Stéphane Graber [Tue, 4 Dec 2012 21:17:07 +0000 (16:17 -0500)]
lxc-start-ephemeral: Use argparse errors

Use argparse's error function instead of our own print + exit.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agorename physical nics at shutdown
Serge Hallyn [Tue, 4 Dec 2012 18:00:26 +0000 (12:00 -0600)]
rename physical nics at shutdown

When a physical nic is being set up, store its ifindex and original name
in struct lxc_conf.  At reboot, reset the original name.
We can't just go over the original network list in lxc_conf at shutdown
because that may be tweaked in the meantime through the C api.  The
saved_nics list is only setup during lxc_spawn(), and restored and
freed after lxc_start.

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

Changelog: remove non-effect change in execute.c

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agomake install should create $LXCPATH directory
Dwight Engen [Thu, 29 Nov 2012 21:24:47 +0000 (16:24 -0500)]
make install should create $LXCPATH directory

The $LXCPATH (default /var/lib/lxc) directory was not being created by
make install, so unless it gets created by some other means
(packaging tools), commands such as lxc-create will fail.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoInstall legacy scripts when built without python.
Stéphane Graber [Tue, 4 Dec 2012 17:12:36 +0000 (12:12 -0500)]
Install legacy scripts when built without python.

Re-introduce the old lxc-ls script and manpage under a new legacy
sub-directory.

Those will be installed in place of their python equivalent when LXC
is built without --enable-python.

Any other script ported to python should be added to those lists.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoRewrite lxc-ls in python
Stéphane Graber [Wed, 21 Nov 2012 22:38:27 +0000 (17:38 -0500)]
Rewrite lxc-ls in python

This rewrite is mostly compatible with the shell version.
--active and -1 still work and behave as they used to.

This adds --running, --stopped and --frozen as state filters.

A new "fancy" view is also implemented (can be used with --fancy) and
will show containers in a column-based interface with the following fields:
 - name
 - state
 - ipv4
 - ipv6
 - pid of init

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc_conf logfile and loglevel support
Serge Hallyn [Mon, 3 Dec 2012 18:53:46 +0000 (12:53 -0600)]
lxc_conf logfile and loglevel support

Add 'lxc.logfile' and 'lxc.loglevel' config items.  Values provided on
the command line override the config items.

Have lxccontainer not set a default loglevel and logfile.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agotemplates: use hardlink detection in rsync
Serge Hallyn [Mon, 3 Dec 2012 15:53:10 +0000 (09:53 -0600)]
templates: use hardlink detection in rsync

I'm not sure whether we want this:  is -H ubiquitous?

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
11 years agolxc-clone: use hardlink detection in rsync
Serge Hallyn [Mon, 3 Dec 2012 15:47:37 +0000 (09:47 -0600)]
lxc-clone: use hardlink detection in rsync

Otherwise busybox clones have been reported to explode from
2M to 440M.

Reported-by: Rene K. Mueller <spiritdude@gmail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
11 years agoCreate busybox commands as symlinks instead of hardlinks
Dwight Engen [Fri, 30 Nov 2012 16:49:25 +0000 (11:49 -0500)]
Create busybox commands as symlinks instead of hardlinks

I was getting a "Too many links" error when creating a busybox container on
a btrfs file system. This change has the template create the links as
symlinks instead. It also generates the list of commands to be symlinked from
busybox itself instead of a hardcoded list in the template.

Also set the root password to root, to match what other templates do.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-create: Script cleanup
Stéphane Graber [Mon, 3 Dec 2012 14:29:27 +0000 (09:29 -0500)]
lxc-create: Script cleanup

 - Removes the mixed tabs/spaces, replacing by standard 4 spaces indent.
 - Fix a bunch of bashisms.
 - Use shell syntax for and/or in if statements instead of the "test" syntax.
 - Improve block spacing a bit.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-create: Store template information in config
Stéphane Graber [Fri, 30 Nov 2012 21:55:54 +0000 (16:55 -0500)]
lxc-create: Store template information in config

Change lxc-create to add the name of the template, checksum and any parameters
to the container's configuration.
This makes it easier to debug and figure out exactly how a container was built.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agocheck and warn of return value from fchdir
Serge Hallyn [Fri, 30 Nov 2012 02:05:37 +0000 (20:05 -0600)]
check and warn of return value from fchdir

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoInclude lxc-ubuntu when doing make dist
Dwight Engen [Thu, 29 Nov 2012 18:27:37 +0000 (13:27 -0500)]
Include lxc-ubuntu when doing make dist

Removing templates/lxc-ubuntu from configure.ac makes it so that it is
not included in the tarball that make dist builds (and therefore also
breaks the rpm build).

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoDescription: run MAKEDEV console when doing lxc.autodev
Serge Hallyn [Thu, 29 Nov 2012 16:46:46 +0000 (10:46 -0600)]
Description: run MAKEDEV console when doing lxc.autodev

mounted-dev.conf won't be running that in container's userspace as it
previously would have, so make sure that all the devices it would have
created (other than ones which lxc later finagles) get created.
To achieve this, we have to first mount /dev, then run MAKEDEV, then
run setup_autodev to populate the rest of /dev.

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

Changelog:
  v2: Use INFO rather than ERROR when makedev fails, since we won't stop the container boot.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoFix build with --enable-tests on Fedora
Dwight Engen [Wed, 28 Nov 2012 21:51:37 +0000 (16:51 -0500)]
Fix build with --enable-tests on Fedora

When using --enable-tests on Fedora, the linker complains with:
"undefined reference to symbol sem_getvalue", which nm shows to be in
libpthread not librt. Build tested on Fedora, Oracle Linux, and Ubuntu.

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 agolxc-ubuntu: Fix wrong variable name
Stéphane Graber [Thu, 29 Nov 2012 15:08:22 +0000 (10:08 -0500)]
lxc-ubuntu: Fix wrong variable name

$LANGPACK_LIST was renamed to $langpacks but not all the code was updated.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-ubuntu: Fix mixed indent
Stéphane Graber [Wed, 28 Nov 2012 23:29:58 +0000 (18:29 -0500)]
lxc-ubuntu: Fix mixed indent

Replace all remaining tabs by 8 spaces, to properly indent by 4 spaces.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-ubuntu: Rename from lxc-ubuntu.in
Stéphane Graber [Wed, 28 Nov 2012 23:29:57 +0000 (18:29 -0500)]
lxc-ubuntu: Rename from lxc-ubuntu.in

lxc-ubuntu no longer uses any build time variables, therefore it can
now be simply copied to the target without any autoconf magic.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-ubuntu: Guess a list of langpacks to install
Stéphane Graber [Wed, 28 Nov 2012 23:29:56 +0000 (18:29 -0500)]
lxc-ubuntu: Guess a list of langpacks to install

In addition to creating the current locale in the container, also
try to scan the host and extra the list of langpacks installed there,
then pass that list to debootstrap as additional packages to install.

On distros that don't have dpkg, only language-pack-en will be installed.
The code will always ensure that language-pack-en is ALWAYS installed in the
target, similar to what Ubuntu does with its various media.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-ubuntu: Always create the needed locales
Stéphane Graber [Wed, 28 Nov 2012 23:29:55 +0000 (18:29 -0500)]
lxc-ubuntu: Always create the needed locales

Move some old code from the trim() function into the main configure_ubuntu
function so that we always create a locale in the container.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoFix busybox template to not have extra aa_profile hunk
Dwight Engen [Thu, 29 Nov 2012 15:13:10 +0000 (10:13 -0500)]
Fix busybox template to not have extra aa_profile hunk

Both 69d66f1e and f02ce27d added the aa_profile = unconfined hunk, but only
the first was needed, maybe a merge error? The second one causes the
template to get an error on the EOF line. This essentially reverts
f02ce27d.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agorevert inadvertent un-doing of lxc-clone fix
Serge Hallyn [Wed, 28 Nov 2012 15:57:59 +0000 (09:57 -0600)]
revert inadvertent un-doing of lxc-clone fix

commit 8f2c3a702aae3545b631a2b4c6db99f87528553a reverted a fix
for bad handling by lxc-clone of 'lxc.mount[ \t]' lines.
Fix.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoOracle template: make container also boot under libvirt
Dwight Engen [Tue, 27 Nov 2012 16:07:12 +0000 (11:07 -0500)]
Oracle template: make container also boot under libvirt

This allows containers created with lxc-create to also boot under
libvirt/Virtual Machine Monitor

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoMake config api items const
Dwight Engen [Mon, 26 Nov 2012 20:28:14 +0000 (15:28 -0500)]
Make config api items const

This makes it easier to write a binding, and presents a cleaner API. Use
strdupa in a few places to get mutable strings for tokenizing / parsing.
Also change the argv type in lxcapi_start and lxcapi_create to match
that of execv(3).

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-setuid: use POSIX shell instead of bash
Natanael Copa [Mon, 26 Nov 2012 21:39:05 +0000 (22:39 +0100)]
lxc-setuid: use POSIX shell instead of bash

Avoid getop --longoptions.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-setcap: use POSIX shell instead of bash
Natanael Copa [Mon, 26 Nov 2012 21:37:33 +0000 (22:37 +0100)]
lxc-setcap: use POSIX shell instead of bash

Avoid getopt --longoptions

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoUse autoconf LXCPATH instead of hardcoded LXCDIR
Dwight Engen [Mon, 26 Nov 2012 20:57:53 +0000 (15:57 -0500)]
Use autoconf LXCPATH instead of hardcoded LXCDIR

LXCDIR is only used in lxc_container_new, whereas LXCPATH is used throughout
the rest of lxc, and even in the same file as lxc_container_new (for example
create_container_dir()).

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-checkconfig: use POSIX shell instead of bash
Natanael Copa [Tue, 27 Nov 2012 07:27:17 +0000 (08:27 +0100)]
lxc-checkconfig: use POSIX shell instead of bash

- replace 'echo -e' with printf
- replace 'if [[ ... ]]' with 'if [ ... ]'
- add \ at after && and || when those are at end of line

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-version: use POSIX shell instead of bash
Natanael Copa [Tue, 27 Nov 2012 07:13:31 +0000 (08:13 +0100)]
lxc-version: use POSIX shell instead of bash

There is no reason to depend on bash for a single echo.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofix lxc-ubuntu-cloud option parsing bugs
Serge Hallyn [Mon, 26 Nov 2012 20:08:36 +0000 (14:08 -0600)]
fix lxc-ubuntu-cloud option parsing bugs

The -u shortopt matching --userdata was not specified, and when -L
is found shift should have been by 1 not 2 since there is no optarg.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-info: add option -t, --state-is=STATE to test for a given test
Natanael Copa [Mon, 26 Nov 2012 19:04:32 +0000 (20:04 +0100)]
lxc-info: add option -t, --state-is=STATE to test for a given test

Add an option to test for a give state. This is useful for scripts.
It lets us you do thing like:

 if lxc-info --name myname --state-is RUNNING; then
   ...

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoEnsure argv passed by createl to create is NULL terminated
Dwight Engen [Mon, 26 Nov 2012 17:18:13 +0000 (12:18 -0500)]
Ensure argv passed by createl to create is NULL terminated

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoFree allocated configuration memory
Dwight Engen [Mon, 26 Nov 2012 17:18:06 +0000 (12:18 -0500)]
Free allocated configuration memory

Most of these were found with valgrind by repeatedly doing lxc_container_new
followed by lxc_container_put. Also free memory when config items are
re-parsed, as happens when lxcapi_set_config_item() is called. Refactored
path type config items to use a common underlying routine.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoFix use of list item memory after free
Dwight Engen [Mon, 26 Nov 2012 17:17:58 +0000 (12:17 -0500)]
Fix use of list item memory after free

Valgrind showed use of ->next field after item has been free()ed.
Introduce a lxc_list_for_each_safe() which allows traversal of a list
when the body of the loop may remove the currently iterated item.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoFix fd leak in lxc log
Dwight Engen [Mon, 26 Nov 2012 17:17:51 +0000 (12:17 -0500)]
Fix fd leak in lxc log

lxc_log_init will leak an fd when it is called by a long running
program that may call lxc_container_new multiple times. Fix by
only opening the log if it is not already open.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agogitignore: Ignore python cache
Stéphane Graber [Thu, 22 Nov 2012 23:02:13 +0000 (18:02 -0500)]
gitignore: Ignore python cache

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agopython: Use builtin len() function for network interfaces
Stéphane Graber [Thu, 22 Nov 2012 23:01:40 +0000 (18:01 -0500)]
python: Use builtin len() function for network interfaces

Use our own len() function for network interfaces as doing
len(container.get_config_item("lxc.network")) will fail when the
list is empty.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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.

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