Commit Graph

3574 Commits

Author SHA1 Message Date
Serge Hallyn
270261b90e ovl_rsync: make sure to umount
Otherwise the kernel will umount when it gets around to it, but
that on lxc_destroy we may race with it and fail the rmdir of
the overmounted (BUSY) rootfs.

This makes lxc-test-snapshot pass for me again.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 15:43:38 -04:00
Serge Hallyn
a93488dfcb overlayfs_mount: create delta dir if it doesn't exist
(This *should* fix the lxc-test-snapshot testcase, but doesn't seem
to by itself.)

If it doesn't exist, we may as well start with an empty one.  This
is needed when creating an overlayfs snapshot.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 13:25:28 -04:00
Serge Hallyn
067650d0b6 lxc_rmdir_onedev: don't fail if path doesn't exist
We're asked to delete it, don't fail if it doesn't exist.

This stops lxc-destroy from failing when the container isn't fully
built.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 13:25:25 -04:00
Christian Brauner
776d170c5e Make ephemeral containers survive reboots
Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 13:25:23 -04:00
Christian Brauner
f01f7975c1 Remove ephemeral containers from lxc_snapshots
On shutdown ephemeral containers will be destroyed. We use mod_all_rdeps() from
lxccontainer.c to update the lxc_snapshots file of the original container. We
also include lxclock.h to lock the container when mod_all_rdeps() is called to
avoid races.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-09-21 11:47:41 -04:00
Christian Brauner
d825fff3ca Make mod_all_rdeps() public It will now also be called from start.c
Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-09-21 11:47:37 -04:00
Tycho Andersen
aee755ee52 lxc-checkconfig: add some more config options
Here's some more config options that we do actually require to be able to
boot containers.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-09-21 11:45:01 -04:00
Tycho Andersen
80a706b361 gitignore: add Korean man page output
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-09-21 11:43:16 -04:00
Tycho Andersen
3b63f6e487 gitignore: add strange lxc@.service file
I have no idea what this file is, but the build system seems to be
generating it, so let's ignore it.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-09-21 11:43:09 -04:00
Christian Brauner
42342bed25 Ensure that mmap()ed memory is \0-terminated (v3)
Use pwrite() to write terminating \0-byte

This allows us to use standard string handling functions and we can avoid using
the GNU-extension memmem(). This simplifies removing the container from the
lxc_snapshots file. Wrap strstr() in a while loop to remove duplicate entries.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-09-21 11:41:43 -04:00
Stephane Nguyen
af651aa9e1 Fixing MTU calculation in instantiate_veth()]
Signed-off-by: Stephane Nguyen <stephminh@yahoo.es>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-09-21 11:40:57 -04:00
Christian Brauner
28272964d4 Enable lxc_fini() to destroy container on shutdown
When lxc.ephemeral is set to 1 in the containers config it will be destroyed on
shutdown.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-09-21 11:40:15 -04:00
Christian Brauner
297c2d5893 Destroy bdevs using bdev_destroy() from bdev.h
Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-09-21 11:40:11 -04:00
Christian Brauner
339c6f1fb4 Add bdev_destroy() and bdev_destroy_wrapper()
static do_bdev_destroy() and bdev_destroy_wrapper() from lxccontainer.c become
public bdev_destroy() and bdev_destroy_wrapper() in bdev.c and bdev.h

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-09-21 11:40:06 -04:00
Christian Brauner
8796becf36 Add lxc.ephemeral lxc.ephemeral indicates whether a container will be destroyed on shutdown Can be 0 for non-ephemeral and 1 for ephemeral.
Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-09-21 11:40:02 -04:00
Serge Hallyn
186bef0024 overlayfs_clone: rsync the mounted rootfs
Closes #655

We can't rsync the delta as unpriv user because we can't create
the chardevs representing a whiteout.  We can however rsync the
rootfs and have the kernel create the whiteouts for us.

do_rsync: pass --delete

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 11:37:31 -04:00
Christian Brauner
ffe9a25a03 Fix reallocation calculation
Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-09-21 11:36:49 -04:00
Serge Hallyn
c4532a2036 Add tests for snapshot clone dependencies
Test edge cases (removing first and last entries in lxc_snapshots and the very
last snapshot) and make sure original container isn't destroyed while there are
snapshots, and is when there are none.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 11:35:32 -04:00
Serge Hallyn
108b88ce31 Add a nesting.conf which can be included to support nesting containers (v2)
Newer kernels have added a new restriction:  if /proc or /sys on the
host has files or non-empty directories which are over-mounted, and
there is no /proc which fully visible, then it assumes there is a
"security" reason for this.  It prevents anyone in a non-initial user
namespace from creating a new proc or sysfs mount.

To work around this, this patch adds a new 'nesting.conf' which can be
lxc.include'd from a container configuration file.  It adds a
non-overmounted mount of /proc and /sys under /dev/.lxc, so that the
kernel can see that we're not trying to *hide* things like /proc/uptime.
and /sys/devices/virtual/net.  If the host adds this to the config file
for container w1, then container w1 will support unprivileged child
containers.

The nesting.conf file also sets the apparmor profile to the with-nesting
variant, since that is required anyway.  This actually means that
supporting nesting isn't really more work than it used to be, just
different.  Instead of adding

lxc.aa_profile = lxc-container-default-with-nesting

you now just need to

lxc.include = /usr/share/lxc/config/nesting.conf

(Look, fewer characters :)

Finally, in order to maintain the current apparmor protections on
proc and sys, we make /dev/.lxc/{proc,sys} non-read/writeable.
We don't need to be able to use them, we're just showing the
kernel what's what.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 11:35:29 -04:00
Sungbae Yoo
76072aec5c doc: Update Korean lxc-snapshot(1) for newname option
Update for commit dedd4f6

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 11:32:07 -04:00
Sungbae Yoo
5033e12328 doc: Add lxc.init_(uid|gid) in Korean lxc.container.conf(5)
update for commit dbca923

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 11:31:43 -04:00
Sungbae Yoo
3703aa9e73 doc: Update Korean lxc.cgroup.use in lxc.system.conf(5)
Update for commit 2d8632d

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 11:31:22 -04:00
Sungbae Yoo
0a05624e82 doc: Add the rename option to lxc-clone(1) in Korean manual
Update for commit 585f3c6

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 11:30:45 -04:00
Sungbae Yoo
b7349f15f7 doc: Add LXC-specific mount option in Korean lxc.container.conf(5)
Update for commit f5b67b3

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 11:30:14 -04:00
KATOH Yasufumi
7c3d395052 doc: Update Japanese lxc-snapshot(1) for newname option
Update for commit dedd4f6

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 11:29:49 -04:00
KATOH Yasufumi
7ee64c0f21 doc: Add lxc.init_(uid|gid) in Japanese lxc.container.conf(5)
update for commit dbca923

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 11:29:25 -04:00
KATOH Yasufumi
3635c5eee8 doc: Add the common and '-s' option in lxc-destroy(1)
* Add the description of '-s' option
* Remove '-P' option, and add common options
* Improve Japanese translation

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 11:28:49 -04:00
KATOH Yasufumi
b332333b43 doc: Add LXC-specific mount option in Japanese lxc.container.conf(5)
Add the description of optional, create=file/dir for lxc.mount.entry.
This is update for commit f5b67b3.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2015-09-21 11:27:06 -04:00
Christian Brauner
f08fee55a1 Do not use strlen() on non-null terminated buffer
Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2015-09-08 08:54:53 -05:00
Serge Hallyn
61111832cd coverity: avoid use of NULL c1
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2015-09-04 13:21:35 -05:00
Serge Hallyn
608e356771 coverity: fix mount_entry_create_dir_file
First, fix use of uninitialized variable 'ret'.  Then, actually use
the value it returned in its caller.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2015-09-04 13:15:13 -05:00
Stéphane Graber
2c5bcd3a53 Merge pull request #649 from major/lxc-delete-network-test
Tear down network devices during container halt
2015-09-03 12:58:53 -04:00
Major Hayden
ce5782df8f Tear down network devices during container halt
On very busy systems, some virtual network devices won't be destroyed after a
container halts.  This patch uses the lxc_delete_network() method to ensure
that network devices attached to the container are destroyed when the
container halts.

Without the patch, some virtual network devices are left over on the system
and must be removed with `ip link del <device>`.  This caused containers
with lxc.network.veth.pair to not be able to start.  For containers using
randomly generated virtual network device names, the old devices will hang
around on the bridge with their original MAC address.

Signed-off-by: Major Hayden <major@mhtx.net>
2015-09-03 08:32:19 -05:00
Stéphane Graber
a2b27d2f85 Merge pull request #646 from brauner/manpages_new
Adapt manpage for lxc-snapshot
2015-08-28 13:36:19 -04:00
Christian Brauner
dedd4f6771 Adapt manpage for lxc-snapshot
Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
2015-08-28 18:57:49 +02:00
Stéphane Graber
c804bedf8b Merge pull request #585 from ptoomey3/lxc-execute-as-user
Add support for specified UID/GID for lxc-execute in a private user namespace
2015-08-28 11:23:13 -04:00
Stéphane Graber
f7512464e5 Merge pull request #643 from raspberrypython/issue-616
Test dpkg for multiarch support in lxc-debian template
2015-08-28 11:22:10 -04:00
David Noyes
92824ee04f Alternative test for dpkg multiarch support in lxc-debian template
Signed-off-by: David Noyes <david.j.noyes@gmail.com>
2015-08-28 14:44:25 +00:00
Patrick Toomey
68d18db8d8 Add support for get_config_item and set_config_item
Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
2015-08-28 08:25:33 -06:00
Patrick Toomey
62d0053955 Update docs to reflect lxc.init_uid and lxc.init_gid options
Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
2015-08-28 08:25:30 -06:00
Patrick Toomey
dbca9237db Update english docs for new lxc.init_uid and lxc.init_gid options
Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
2015-08-28 08:25:23 -06:00
Patrick Toomey
72bb04e4b8 Add support for setting lxc-execute init UID/GID via configuration file
Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
2015-08-28 08:25:19 -06:00
Patrick Toomey
fd9f399bac Clarify struct field comment
Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
2015-08-28 08:25:15 -06:00
Patrick Toomey
c5cd20ce8e Pass UID/GID explicitly through flags
Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
2015-08-28 08:25:11 -06:00
Patrick Toomey
56f8ff00e3 Set UID/GID to parent value for lxc-execute
Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
2015-08-28 08:25:07 -06:00
Patrick Toomey
e06155c9ab Do not switch to root for lxc-execute
Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
2015-08-28 08:24:11 -06:00
David Ward
7b6753e710 Fix verification of start hook without a rootfs
Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-08-27 16:37:20 -05:00
David Ward
0f4cdd7781 When creating container, save configuration if rootfs already exists
Commit 6c6892b "fix multithreaded create()" prevented the container
configuration from being saved if the backing store does not need
to be created.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-08-27 16:37:15 -05:00
David Ward
01958b1fe0 Only mount /proc if needed, even without a rootfs
Use the same code with and without a rootfs to check if mounting
/proc is necessary before doing so. If mounting it is unsuccessful
and there is no rootfs, continue as before.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-08-27 16:37:11 -05:00
David Ward
14221cbb7d Allow autodev without a rootfs
A container without a rootfs is useful for running a collection of
processes in separate namespaces (to provide separate networking as
an example), while sharing the host filesystem (except for specific
paths that are re-mounted as needed). For multiple processes to run
automatically when such a container is started, it can be launched
using lxc-start, and a separate instance of systemd can manage just
the processes inside the container. (This assumes that the path to
the systemd unit files is re-mounted and only contains the services
that should run inside the container.) For this use case, autodev
should be permitted for a container that does not have a rootfs.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2015-08-27 16:37:05 -05:00