Commit Graph

1756 Commits

Author SHA1 Message Date
Serge Hallyn
f5dd1d532a API support for container snapshots (v2)
The api allows for creating, listing, and restoring of container
snapshots.  Snapshots are created as snapshot clones of the
original container - i.e. btrfs and lvm will be done as snapshot,
a directory-backed container will have overlayfs snapshots.  A
restore is a copy-clone, using the same backing store as the
original container had.

Changelog:

 . remove lxcapi_snap_open, which wasn't defined anyway.
 . rename get_comment to get_commentpath
 . if no newname is specified at restore, use c->name (as we meant to)
   rather than segving.
 . when choosing a snapshot index, use the correct path to check for.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-10 18:19:20 -04:00
Cedric Bosdonnat
98f5f7e2c5 Fixed opensuse template to make lxc-shutdown work.
The fix is described by:
https://wiki.archlinux.org/index.php/Linux_Containers#Container_cannot_be_shutdown_if_using_systemd

Signed-off-by: Cedric Bosdonnat <cbosdonnat@suse.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-10 18:19:20 -04:00
KATOH Yasufumi
57da8c32f8 Add Japanese man pages.
Japanese man pages is installed under $mandir/ja.
At this time, it is based on version 0.9.0.
2013-09-10 18:19:20 -04:00
Daniel Lezcano
4213373fe5 change version to 1.0.0.alpha1 in configure.ac
Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
2013-09-10 23:55:26 +02:00
Daniel Lezcano
be9f766c1e Merge git://github.com/lxc/lxc
Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
2013-09-09 21:08:49 +02:00
Natanael Copa
f756cda05c configure: enable Lua if found and continue without if not
Search for Lua if no --enable-lua/--disable-lua specified but continue
without if not found.

If --enable-lua is specified and Lua is not found then return error.

If --disable-lua is specified, then don't search for Lua.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-06 15:19:15 -04:00
Serge Hallyn
5c068da969 lxc_spawn: don't close pinfd until container is stopped
Otherwise containers may be able to remount -o ro their rootfs
at shutdown.

Reported-by: Harald Dunkel <harri@afaics.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-06 13:23:08 -05:00
Natanael Copa
69c757b343 lua: fix logic to enable lua support in configure
When there is no --enable-lua or --with-lua-pc, Lua should not be
enabled.

This fixes a bug introduced with 12e93188 (configure/makefile:
Allow specify Lua pkg-config file with --with-lua-pc) that caused
configure script to fail if lua headers was missing.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-06 09:14:28 -04:00
Serge Hallyn
2caf9a97d9 sanity-check number of detected capabilities
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-05 20:34:34 -05:00
Dwight Engen
3a1675bf08 add AS_VAR_COPY for older autoconf versions
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-05 19:59:05 -04:00
Dwight Engen
330da5fa32 lua: fix stats gathering
- remove lxc subdir in cgroup paths (done in commit b98f7d6e)
- remove extraneous debug printfs
- remove extra call to stats_clear

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-05 19:58:55 -04:00
Natanael Copa
c25c2970a6 lua: implement dirname in C rather than depend on external executable
Instead of popen and run external executable dirname we implement a
dirname in C in the core module.

We also remove the unused basename function.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-05 19:58:28 -04:00
Natanael Copa
ac8255280d lua: implement usleep in C module
So we avoid running os.execute

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-05 19:58:12 -04:00
Natanael Copa
12e93188de configure/makefile: Allow specify Lua pkg-config file with --with-lua-pc
Enable support for both Lua 5.1 and 5.2 by letting user specify the Lua
pkg-config package name. By default it will use 'lua' and try figure
out which version it is.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-05 19:57:52 -04:00
Natanael Copa
44a80d675f lua: prepare for Lua 5.2
Adjust code for Lua 5.2 and keep compatibility with Lua 5.1.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-05 19:57:34 -04:00
Natanael Copa
2698b46924 lua: fix a bug in the parsing of /proc/mounts
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-05 19:57:08 -04:00
Serge Hallyn
eee59f9408 clone: don't copy rdepends when not doing a snapshot clone
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-05 18:05:34 -05:00
Serge Hallyn
2a2d36a425 fix typo
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-05 17:59:28 -05:00
Serge Hallyn
1fb86a7cdc introduce lxc.cap.keep
The lxc configuration file currently supports 'lxc.cap.drop', a list of
capabilities to be dropped (using the bounding set) from the container.
The problem with this is that over time new capabilities are added.  So
an older container configuration file may, over time, become insecure.

Walter has in the past suggested replacing lxc.cap.drop with
lxc.cap.preserve, which would have the inverse sense - any capabilities
in that set would be kept, any others would be dropped.

Realistically both have the same problem - the sendmail capabilities
bug proved that running code with unexpectedly dropped privilege can be
dangerous.  This patch gives the admin a choice:  You can use either
lxc.cap.keep or lxc.cap.drop, not both.

Both continue to be ignored if a user namespace is in use.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-05 17:20:59 -05:00
Serge Hallyn
59d66af29d bdev: free after bdev_init
(Except in cases where we will immediately exit)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-05 17:04:15 -05:00
Dwight Engen
41c3b7c7ac valgrind: fix memory leak on container new/put
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-05 10:39:10 -05:00
Natanael Copa
75b5535282 lxc-alpine: add hwaddr for a single macvlan interface
We already add harware address for a single veth interface. Do the same
with a single macvlan interface.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-04 14:15:09 -05:00
S.Çağlar Onur
e34b5d2ef2 bdev_copy segfaults if bdevtype is NULL
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-04 08:54:10 -05:00
Stéphane Graber
cd0bcc4958
tests: Add lxc-test-usernic to the dist tarball
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-03 15:11:07 -04:00
Stéphane Graber
250b1eec71
licensing: Add missing headers and FSF address
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-03 14:33:03 -04:00
Stéphane Graber
d08c3aaebc
ubuntu: iproute is now called iproute2
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-09-03 11:36:09 -04:00
Serge Hallyn
c66e9b01f0 lua: update license
As with other files, update to be LGPL since these are part
of the lxc library.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-03 09:07:56 -05:00
Stéphane Graber
ca9548ad02 python: Fix api_test to use the new attach() API
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-09-03 09:35:39 -04:00
Serge Hallyn
80bcb05357 lxc-commands: add a comment explaining CMD_* rules
We wish to ensure that, henceforth, newer lxc tools are always compatible
with older lxc monitors.  Add a comment to commands.c to explain the
rule we wish to enforce to this end.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-03 09:33:46 -04:00
Serge Hallyn
0f081315a9 remove old stale comments (lxc-clone is now implemented)
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-30 15:51:31 -05:00
Stéphane Graber
188e0ab60b Add a section about licensing to CONTRIBUTING
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-08-30 16:05:20 -04:00
Serge Hallyn
acbb59f50d fix license text in ubuntu and ubuntu-cloud templates
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-30 14:51:43 -05:00
Serge Hallyn
d75462e4d6 fix wrong license text for parts of liblxc library
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-30 14:43:25 -05:00
Stéphane Graber
0c69c79b4d
avoid zgrep -q as it's failing on some distros
Reported-by: Filirom1
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-08-30 12:08:26 -04:00
Stéphane Graber
dfa7aa3a83
fedora: Add missing double-quotes.
Reported-by: tlc
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-08-30 11:47:58 -04:00
Stéphane Graber
840295ff4c
Fix some typos
Signed-off-by: Dmitry Shachnev <mitya57@ubuntu.com>
Reported-by: Vincent Ladeuil
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-08-30 11:43:19 -04:00
Serge Hallyn
80507ee8eb start.c: handle potential signal flood
Signalfd does not guarantee that we'll get an event for every signal.
So if 3 tasks exit at the same time, we may get only one sigchld
event.  Therefore, in signal_handler(), always check whether init has
exited.  Do with with WNOWAIT so that we can still wait4 to cleanup
the init after lxc_poll() exists (rather than complicating the code).

Note - there is still a race in the kernel which can cause the
container init to become a defunct child of the host init (!).  This
doesn't solve that, but is a potential (if very unlikely) race which
apw pointed out while we were trying to create a reproducer for the
kernel bug.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-08-29 14:53:18 -05:00
Natanael Copa
48c63f8d03 lxc-alpine: create /dev/zero
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-26 07:22:25 -05:00
Serge Hallyn
5acccf95b2 config_ipv6: run inet_pton on the addr value without mask
otherwise a "$addr/$mask" results in failure.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-26 06:26:33 -05:00
Serge Hallyn
79622932f2 api: convert lxc_start
Normal lxc-start usage tends to be "lxc-start -n name [-P lxcpath]".
This causes $lxcpath/$name/config to be the configuration for the
container.  However, lxc-start is more flexible than that.  You can
specify a custom configuration file, in which case $lxcpath/$name/config
is not used.  You can also (in addition or in place of either of these)
specify configuration entries one-by-one using "-s lxc.utsname=xxx".

To support this using the API, if we are not using
$lxcpath/$name/config then we put ourselves into a custom lxcpath
called (configurable using LXCPATH) /var/lib/lxc_anon.  To stop a
container so created, then, you would use

	lxc-stop -P /var/lib/lxc_anon -n name

TODO: we should walk over the list of &defines by hand and set them
using c->set_config_item.  I haven't done that in this patch.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-26 06:23:27 -05:00
Scott Moser
cb0c6c0203 hooks/ubuntu-cloud-prep: add hostname to meta-data
prior to my enabling of the clone hook, the setting of the hostname
was being done by writing to /etc/hostname.  Instead of relying on that
we're now writing 'local-hostname' into the metadata for the instance.

cloud-init then reads this and sets the hostname properly.

We are also writing /etc/hostname with the new hostname explicitly.  This is
useful/necessary because on network bringup of eth0, dhclient will submit its
hosname.  The updating done by cloud-init occurs to late, and thus
the dhcp request goes out with the un-configured hostname and dns doens't
work correctly.

Signed-off-by: Scott Moser <smoser@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-22 15:29:06 -05:00
Serge Hallyn
92b0b5bac5 api: convert lxc_wait, lxc_freeze, and lxc_unfreeze
These are the last of the simpler conversions.  Start, execute,
kill, info and attach remain to be done.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
2013-08-21 19:21:56 -05:00
Serge Hallyn
9069513c69 lxc_cgroup: convert to using API
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-21 16:38:53 -05:00
Serge Hallyn
dfb31b25e2 Track snapshot dependencies (v2)
(Will push in a bit barring any objections)

lvm, btrfs, and zfs snapshots each do an ok job of handling deletions
for us - a btrfs snapshot does fine after the original is removed,
while zfs and lvm will both refuse to allow the original to be deleted
while the snapshot exists.

Overlayfs doesn't do this for us.  So, for overlayfs snapshots, track
the dependencies.

When c2 is created as an overlayfs snapshot of dir-backed c1, then

1. c2's lxc_rdepends file will contain

	c1_lxcpath
	c1_lxcname

2. c1's lxc_snapshots will contain "1"

c1 cannot be deleted so long as lxc_snapshots exists and contains
a non-zero number.

The contents of lxc_snapshots and lxc_rdepends are protected by
container_disk_lock() and at lxc_clone by the new container not yet
being accessible.

(Originally I was going to keep them in the container config, but the
problem with using $lxcpath/$name/config is that api users could end up
calling c->save_config() with a cached old value of snapshots/rdepends.)

Changelog:
	aug 21: check for fprintf and fclose failures

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
2013-08-21 16:38:51 -05:00
Serge Hallyn
84bdfb2b4c avoid very unlikely race due to EEXIST
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-20 18:15:06 -05:00
Serge Hallyn
659aa0618c coverity: make indent match nest level
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-20 18:01:07 -05:00
Serge Hallyn
5d9598d7d3 coverity: dont dereference before null check
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-20 17:59:19 -05:00
Serge Hallyn
a09295f841 coverity: don't leak partial_fd
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-20 17:54:19 -05:00
Serge Hallyn
ca6973422d coverity: don't leak open DIR
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-20 17:48:54 -05:00
Serge Hallyn
01efd4d3d9 coverity: correctly handle tpath error case.
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-20 16:58:24 -05:00