Commit Graph

63 Commits

Author SHA1 Message Date
Stéphane Graber
207bf0e475 templates: Make sure usual locations are in PATH
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-02-06 17:14:03 -05:00
Serge Hallyn
2133f58c66 create: pass --mapped-gid to templates next to --mapped-uid
That way templates can fix group ownership alongside uid ownership.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-02-04 16:31:37 -05:00
Stéphane Graber
d46417540f lxc-ubuntu-cloud: Update arm* cross
| host arch | arm64 | armhf | armel |
-------------------------------------
| arm64     |   X   |   X   |   X   |
| armhf     |       |   X   |   X   |
| armel     |       |   X   |   X   |
-------------------------------------

Although optional, all existing arm64 silicon supports 32bit instructions.
armel/armhf is only a userspace change, so they are interchangeable.
However armhf isn't supported on all armel platforms (e.g. armv6) but
all those we support have hard-float.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-31 09:38:32 +00:00
Scott Moser
ad3f14ab58 lxc-ubuntu-cloud: various small changes
* ppc64el images now exist and generally function.
   Instead of failing because an arch isnt in the list,
   let that check happen by ability to download something.
 * update the hard coded ubuntu releases to know about 'trusty'
   and drop no longer supported releases (consistent with behavior
   when distro-info is available)
 * shorten the logic that decides if host and container arch
   are supported.
 * support skipping "invalid arch" check entirely via undocumented
   variable UCTEMPLATE_SKIP_ARCH_CHECK.
 * update usage to reference 'tryreleased' as the default 'stream'
 * give good error message if user tries 'released' and there
   is no released version available.

Signed-off-by: Scott Moser <smoser@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-31 09:38:29 +00:00
Stéphane Graber
8a3c76b24d ubuntu/ubuntu-cloud: Add support for arm64 and ppc64el
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-29 11:43:22 +00:00
Dimitri John Ledkov
4b954f1217 lxc-ubuntu-cloud: Default to trying released channel
This adds a fallback to the daily channel if an image couldn't be found
in the released one.

Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 22:00:32 -05:00
Stéphane Graber
9cde0368fb lxc-ubuntu-cloud: Fix cache and lock location
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-15 23:49:02 -05:00
Elan Ruusamäe
17abf2784d handle simple bashisms:
- [[ ]] -> [ ]
- == -> =
- source -> .
- redirect of fd 200 is error in mksh, use fd 9
- &> /dev/null -> > /dev/null 2>&1
- useless function keyword
- echo -e -> printf

still left bash shebang which did not validate with checkbashism, mostly
due 'type' being reported as bashism

Signed-Off-By: Elan Ruusamäe <glen@delfi.ee>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-14 16:16:00 -05:00
Stéphane Graber
3f5f5d99b0 Fix some typos
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-12 19:21:36 -05:00
Serge Hallyn
2b142295af typo fix: create $rootfs/dev/pts
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-12 12:07:36 -06:00
Stéphane Graber
f2a95ee1bf Move some common Ubuntu config
This introduces a new /usr/share/lxc/config directory containing common
configuration snippets.

The two Ubuntu templates are then simplified to just include the
relevant entries avoiding a whole lot of hardcoded cgroup, capabilities
and mount points configuration.

An extra comment is also added at the top of all generated configuration
files telling the user to look at lxc.conf(5) for more information.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-12-06 11:21:46 -05:00
Stéphane Graber
0a3673e807
Some tweak on previous change (timezone)
This adds the same code to the Debian-based templates (Ubuntu and Ubuntu
Cloud) and also avoids a needless fork.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-02 17:42:48 -05:00
Stéphane Graber
5ff337745e ubuntu: Actually attempt to remove /dev/shm
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-12-02 12:36:57 -05:00
Stéphane Graber
c01c25fcdd
Tab/spaces consistency for templates
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:57:34 -05:00
Elan Ruusamäe
853d58fdf5 use awk, instead of 'grep | awk'
Signed-off-by: Elan Ruusamäe <glen@delfi.ee>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:15:12 -05:00
Stéphane Graber
d59feca3be lxc-ubuntu*: Mark non-essential mounts optional
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-12 14:45:53 -06:00
Serge Hallyn
57d116ab50 create_run_template: tell the template what caller's uid was mapped to
conf.c/conf.h: have replaced bool hostid_is_mapped() with int mapped_hostid()
   which returns the mapped uid for the caller's uid on the host, or -1 if
   none

create_run_template: pass caller's uid into template.

lxc-ubuntu-cloud:
	1. accept --mapped-uid argument
	2. don't write to devices cgroup - not allowed.
	3. if running in userns, use $HOME/.cache
	4. chown cached files to the uid to which our caller was
	   mapped
	5. ignore /dev when extracting rootfs in a userns

Changelog: nov 5: remove debugging INFO line.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-06 09:04:06 -06:00
Stéphane Graber
9c3bc32c57
lxc-ubuntu-cloud: Cope with spaces in paths
Reported-by: Scott Moser <smoser@ubuntu.com>
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-10-08 10:51:53 -04:00
Scott Moser
494fd6b390
lxc-ubuntu-cloud: pass --numeric-owner and -p to untar
Just following up here, Serge raised the question of whether or not the
other two invocations of 'tar' in this script need '--numeric-owner'.
They probably should have it, although its of little concern because the
'build_root_tgz' path is only taken if there is no '-root.tar.gz' file for
download, and the only supported ubuntu release without the -root.tar.gz
download is 10.04 at this point.

Anyway, below is a more complete diff, also including a fix as
'--numeric-uid' is not a valid option to tar.  The name is
'--numeric-owner'.

Signed-off-by: Scott Moser <smoser@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-10-08 10:25:30 -04:00
Serge Hallyn
4d7bcfb638 ubuntu templates: make pstore fstab entry optional
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-16 11:48:38 -05:00
Serge Hallyn
84bce17b8b add pstore to container fstab
Otherwise user-namespace containers will hang on mountall.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-13 15:55:08 -05: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
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
Scott Moser
65d8ae9c4a add a clone hook for ubuntu-cloud images
This allows ability to now specify '--userdata' arguments to 'create' or
to 'clone'. So now, the following means very fast start of instances with
different user-data.

$ sudo lxc-create -t ubuntu-cloud -n precise -- \
   -r precise --arch amd64

$ sudo lxc-clone -B overlayfs -o precise -s -n ephem1 \
   --userdata="my.userdata1"
$ sudo lxc-clone -B overlayfs -o precise -s -n ephem2 \
   --userdata="my.userdata2"

Also present here is
 * an improvement to the static list of Ubuntu releases. It uses
   ubuntu-distro-info if available degrades back to a static list on failure.
 * moving of the replacement variables to the top of the create template This
   is just to make it more obvious what is being replaced and put them in a
   single location.

Signed-off-by: Scott Moser <smoser@ubuntu.com>
2013-08-09 08:40:25 -05:00
Serge Hallyn
d273b8abfa ubuntu-cloud: remove debugging echo
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-08-07 08:53:07 -05:00
Serge Hallyn
1aad9e44d6 ubuntu-cloud: changes to support unprivileged use
don't try to lock if using a specified tarball

The lock/subsys/lxc-ubuntu-cloud lock is to protect the tarballs
managed under /var/cache/lxc/cloud-$release.  Don't lock if we've
been handed a tarball.

fake device creation

Unprivileged users can't create devices, so bind mount null, tty, urandom
and console from the host.

Changelog:
	Jul 22: as Stéphane points out, remove a left-over debug line

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-07-22 12:15:43 -05:00
Serge Hallyn
6f259716e7 ubuntu templates: add some kernel filesystems to container fstab
The debugfs, fusectl, and securityfs may not be mounted inside a
non-init userns.  But mountall hangs waiting for them to be
mounted.  So just pre-mount them using $lxcpath/$name/fstab as
bind mounts, which will prevent mountall from trying to mount
them.

If the kernel doesn't provide them, then the bind mount failure
will be ignored, and mountall in the container will proceed
without the mount since it is 'optional'.  But without these
bind mounts, starting a container inside a user namespace
hangs.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-07-17 09:56:57 -05:00
Serge Hallyn
868a70afea ubuntu-cloud template: accept --rootfs argument
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-07-12 15:33:06 -05:00
Stéphane Graber
9313e1e628
ubuntu: Tweak layout of the config
Just add an extra white line to both templates.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-07-09 18:30:52 -04:00
Serge Hallyn
1897e3bcd3 Move container creation fully into the api
1. implement bdev->create:

python and lua: send NULL for bdevtype and bdevspecs.
They'll want to be updated to pass those in in a way that makes
sense, but I can't think about that right now.

2. templates: pass --rootfs

If the container is backed by a device which must be mounted (i.e.
lvm) then pass the actual rootfs mount destination to the
templates.

Note that the lxc.rootfs can be a mounted block device.  The template
should actually be installing the rootfs under the path where the
lxc.rootfs is *mounted*.

Still, some people like to run templates by hand and assume purely
directory backed containers, so continue to support that use case
(i.e. if no --rootfs is listed).

Make sure the templates don't re-write lxc.rootfs if it is
already in the config.  (Most were already checking for that)

3. Replace lxc-create script with lxc_create.c program.

Changelog:
May 24: when creating a container, create $lxcpath/$name/partial,
and flock it.  When done, close that file and unlink it.  In
lxc_container_new() and lxcapi_start(), check for this file.  If
it is locked, create is ongoing.  If it exists but is not locked,
create() was killed - remove the container.

May 24: dont disk-lock during lxcapi_create.  The partial lock
is sufficient.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-05-25 19:27:07 -05:00
Serge Hallyn
b85ab7989e ubuntu templates: add comments to show how to enable nesting
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-05-02 16:28:10 -05:00
Serge Hallyn
eee3ba81c8 templates: deny writes to host's clock (v2)
Don't allow write to /dev/rtc0, and remove sys_time.

Thanks, Christoph.

v2: drop sys_time, sys_module, mac_admin and mac_override in
all templates.

Reported-by: Christoph Mitasch <cmitasch@thomas-krenn.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-05-01 14:00:41 -05:00
Stéphane Graber
a2abaa9ec6
ubuntu: Various fixes
- Drop disabled entries from allowed devices list
 - Improve generated config layout a bit
 - Drop redundant uname call
 - Re-generate the SSH host keys on container creation

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-04-22 08:59:53 +02:00
Christian Bühler
ed4616b1cf Use "uname -m" instead of "arch"
According to "arch"'s manpage, it's identical to "uname -m".

Some distros ship uname but don't ship arch, however all distros ship uname,
therefore it makes sense to use "uname -m" whenever possible.

Signed-off-by: Christian Bühler <christian@cbuehler.de>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-04-21 20:23:40 +02:00
Stéphane Graber
8a63c0a9d9 ubuntu: Tweak architecture support
This updates the various checks to match the grid below:

== lxc-ubuntu support per architecture ==
amd64: amd64, i386, armel, armhf, powerpc
i386: i386, armel, armhf, powerpc
armel: armel, armhf
armhf: armhf, armel
powerpc: powerpc

== lxc-ubuntu-cloud support per architecture ==
amd64: amd64, i386
i386: i386
armel: armel, armhf
armhf: armhf, armel

Note that most of the foreign architectures on x86 are supported
through the use of qemu-user-static. This one however isn't yet
support for cloud images (I'll send a patch for 1.0).

Also, qemu-user-static is technically able to emulate amd64 on i386
but qemu-debootstrap doesn't appear to know that and fails quite miserably.

We may also want to add a test for amd64 kernel but i386 userspace, which
is a valid combination that allows running an amd64 container on an i386
host without requiring emulation, but that's for another patch.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-03-27 09:19:42 -04:00
Stéphane Graber
daaf41b367 lxc-ubuntu{-cloud}: Config layout tweaking
This commit tweaks the layout of the config file for the Ubuntu templates.

With this, we now get a clear network config group, then a path related group,
then a bunch of random config options and the end of the config is apparmor,
capabilities and cgroups.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-02-19 14:51:09 -05:00
Stéphane Graber
fe253caa8b 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>
2012-12-06 09:43:29 -05:00
Stéphane Graber
eba7df9ee0 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>
2012-12-06 00:02:40 -05:00
Dwight Engen
e29bf450ca 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>
2012-12-05 13:31:06 -05:00
Serge Hallyn
6b1a07ba08 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>
2012-11-26 15:12:26 -05:00
Serge Hallyn
1881820ae4 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>
2012-11-12 13:13:52 -05:00
Serge Hallyn
192df6e2eb 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>
2012-10-25 10:37:59 +02:00
Stéphane Graber
c215bff6df 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>
2012-10-25 10:37:54 +02:00
Serge Hallyn
bf7d76cf3a 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
2012-10-25 10:36:42 +02:00
Scott Moser
b942e67226 ubuntu-cloud template cleanups
Fix for quantal images which do not have the user 'ubuntu' present.
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1045955

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:25:30 +02:00
Serge Hallyn
10f73bfa4a lxc-ubuntu-cloud: get full pathname to userdata file
When passing '--userdata somefile' to the ubuntu-cloud template, a user
may pass a relative pathname.  The template uses the filename after
changing current directory, so store the full pathname for the userdata
file instead of a potential relative pathname.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:19:17 +02:00
Stéphane Graber
f02ce27d4b 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>
2012-10-25 10:16:23 +02:00
Stéphane Graber
e470cba076 Use lxc_putold as the pivot_root put dir in the ubuntu templates
By default we use mnt, but that means that lxc fstab entries do not work
when placed under the container's /mnt/.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:09:30 +02:00
Stéphane Graber
542939c31b Fix lxc-ubuntu and lxc-ubuntu-cloud to properly deal with /dev/shm.
Now that initscripts in Debian and Ubuntu has been updated to no longer
do silly things with /dev/shm and /run/shm on installation/update, the
check needs updating to detect any remaining broken case and fix it.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:09:25 +02:00
Serge Hallyn
f1ccde27c0 ubuntu and debian templates: Clean up cache if cache build is interrupted
Otherwise the next lxc-create may rsync a bad cache.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:07:04 +02:00