Commit Graph

1197 Commits

Author SHA1 Message Date
Stéphane Graber
9935be1881 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>
2012-11-13 19:35:17 -05:00
Serge Hallyn
ae9242c86a switch use of #define with static char*
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-11-13 17:54:01 -06:00
Serge Hallyn
c95cf86f39 Revert "Fix check against LXCROOTFSMOUNT to use strcmp"
This reverts commit 5bf2c5ce9b.
2012-11-13 17:50:40 -06:00
Serge Hallyn
8dff643f44 Initialize curtime to silence spurious compiler warning
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-11-13 17:49:13 -06:00
Serge Hallyn
ca0a33644a lxc-ssh: fix message about ssh key insertion
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-11-13 17:19:13 -06:00
Serge Hallyn
d7436fc1df Fix reverse check: error out only if mkdir(cgroup/lxc) fails NOT due to -EEXIST
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-11-13 17:18:22 -06:00
Stéphane Graber
24b292c917 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>
2012-11-12 16:41:14 -05:00
Stéphane Graber
aeb958be83 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>
2012-11-12 16:20:53 -05:00
Stéphane Graber
9b106331e7 Update .gitignore for current list of binaries and templates
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2012-11-12 15:56:41 -05:00
Stéphane Graber
7822022c4c 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>
2012-11-12 15:38:50 -05:00
Peter Simons
aa8d013ec5 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>
2012-11-12 15:20:39 -05:00
Frank Scholten
e54d6cce17 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>
2012-11-12 14:56:02 -05:00
Stéphane Graber
5bf2c5ce9b 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>
2012-11-12 14:39:43 -05:00
Stéphane Graber
eeb6cb8305 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>
2012-11-12 14:33:55 -05:00
Stéphane Graber
ad563aea97 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>
2012-11-12 14:32:39 -05:00
Dwight Engen
434445ee1e 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>
2012-11-12 13:47:51 -05:00
Diego Elio Pettenò
64c3c9020b 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>
2012-11-12 13:47:44 -05:00
Stéphane Graber
d76db55b6c 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>
2012-11-12 13:18:32 -05:00
Stéphane Graber
f282a2f4b8 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>
2012-11-12 13:18:32 -05:00
Stéphane Graber
efa99b3226 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>
2012-11-12 13:18:32 -05:00
Stéphane Graber
e03243397d Convert remaining file to new docbook format 2012-11-12 13:18:32 -05:00
Peter Simons
75d0acd48f 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>
2012-11-12 13:18:32 -05:00
Stéphane Graber
e2611fd5e1 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>
2012-11-12 13:18:32 -05:00
Dwight Engen
f0e592fc66 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>
2012-11-12 13:18:32 -05:00
Dwight Engen
6f75ba0bda 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>
2012-11-12 13:18:32 -05:00
Dwight Engen
b1dc05fde9 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>
2012-11-12 13:18:32 -05:00
Dwight Engen
7060353a08 Fix removal of unneeded startup/shutdown scripts
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
2012-11-12 13:18:32 -05:00
Dwight Engen
b88d7bb629 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>
2012-11-12 13:18:32 -05:00
Dwight Engen
b90270a5a3 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>
2012-11-12 13:18:32 -05:00
Serge Hallyn
708f4a80ea 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>
2012-11-12 13:18:32 -05:00
Dwight Engen
037ba55cbe fix minor spelling error
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
2012-11-12 13:18:32 -05:00
Serge Hallyn
17ed13a3bc 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>
2012-11-12 13:18:32 -05:00
Serge Hallyn
f6144ed443 api shutdown: don't c->stop() if already stopped.
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-11-12 13:18:32 -05:00
Stéphane Graber
5a339bbb87 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>
2012-11-12 13:18:32 -05:00
Stéphane Graber
abbe2ead95 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>
2012-11-12 13:18:32 -05:00
Stéphane Graber
6506255cfd 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>
2012-11-12 13:18:32 -05:00
Stéphane Graber
9737a2060c 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>
2012-11-12 13:18:32 -05:00
Stéphane Graber
225b52ef15 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>
2012-11-12 13:18:31 -05:00
Stéphane Graber
921ceb26bd 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>
2012-11-12 13:18:31 -05:00
Dwight Engen
5b12984bf9 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>
2012-11-12 13:18:31 -05:00
Dwight Engen
0d2787be93 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>
2012-11-12 13:17:54 -05:00
Dwight Engen
1f530df632 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>
2012-11-12 13:17:54 -05:00
Stéphane Graber
87540ad7d8 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>
2012-11-12 13:17:54 -05:00
Stéphane Graber
16216c8329 Prefix the test binaries by lxc-test-
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2012-11-12 13:17:54 -05:00
Serge Hallyn
9c9b984556 check return values of scanf and system
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-11-12 13:17:54 -05:00
Serge Hallyn
733a0e89ac check sscanf return value
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-11-12 13:17:54 -05:00
Stéphane Graber
95a717e9b9 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>
2012-11-12 13:17:54 -05:00
Stéphane Graber
caf32f58cd 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.
2012-11-12 13:17:54 -05:00
Stéphane Graber
d7415aea48 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>
2012-11-12 13:17:54 -05:00
Serge Hallyn
697fa6390c 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>
2012-11-12 13:17:54 -05:00