Commit Graph

3097 Commits

Author SHA1 Message Date
Stéphane Graber
307ab05d0f Try to be more helpful on container startup failure
This hides some of the confusing "command X failed to receive response"
why are usually caused by another more understandable error.

On failure to start() from lxc-start, a new error message is displayed,
suggesting the user sets logfile and loglevel and if using -d, restarts
the container in the foreground instead.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-06-04 17:03:24 -04:00
Stéphane Graber
809a1539a3 lxc-download: Attempt to get the GPG key 3 times
This is to deal with the GPG pool occasionaly yielding broken servers.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-06-03 15:52:43 -04:00
Michael H. Warfield
e5469dadd9 lxc-fedora.in: Correct some systemd target setups.
Set the halt.target action to be sigpwr.target.  This allows
SIGPWR to properly shut the container down from lxc-stop.

Renable the systemd-journald.service.

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-06-03 15:06:35 -04:00
Serge Hallyn
840f05df8a lxcapi_snapshot: check that c is defined
before using it, like the other snapshot api methods do.

This will need to go into stable-1.0 as well.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-06-03 15:06:30 -04:00
Stéphane Graber
1b03969c7c python3: Handle invalid global config keys
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-06-03 11:31:31 -04:00
Stéphane Graber
8df68465f2 python3: Don't require a template name
The template name isn't required, if it's not passed, then create will
simply be asked to create a container without a rootfs.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-06-03 11:31:09 -04:00
bartekplus
0d6b9aea63 Free lxc configuration structure
Signed-off-by: Bartosz Tomczyk <bartekplus@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-06-03 11:29:20 -04:00
bartekplus
8255688a65 Corrected debug message
Signed-off-by: Bartosz Tomczyk <bartekplus@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-06-03 11:25:50 -04:00
TAMUKI Shoichi
aadd458215 lxc-plamo: fix for configuring network interface
Fix configure_plamo so as not to configure wireless network interface
in containers even if the host uses wireless network interface.

Signed-off-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-06-03 11:11:51 -04:00
Dwight Engen
0520c252da point user to updated man page in template boilerplate
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-06-03 11:11:42 -04:00
Michael H. Warfield
015f0dd792 lxc-autostart: rework boot and group handling
This adds new functionality to lxc-autostart.

*) The -g / --groups option is multiple cummulative entry.
	This may be mixed freely with the previous comma separated
	group list convention.  Groups are processed in the
	order they first appear in the aggregated group list.

*) The NULL group may be specified in the group list using either a
	leading comma, a trailing comma, or an embedded comma.

*) Booting proceeds in order of the groups specified on the command line
	then ordered by lxc.start.order and name collalating sequence.

*) Default host bootup is now specified as "-g onboot," meaning that first
	the "onboot" group is booted and then any remaining enabled
	containers in the NULL group are booted.

*) Adds documentation to lxc-autostart for -g processing order and
	combinations.

*) Parameterizes bootgroups, options, and shutdown delay in init scripts
	and services.

*) Update the various init scripts to use lxc-autostart in a similar way.

Reported-by: CDR <venefax@gmail.com>
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-06-03 11:10:01 -04:00
Serge Hallyn
77ae87cdeb Fix building init.lxc.static under bionic
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-06-03 10:11:09 -04:00
Serge Hallyn
07ffb1303e configure.ac: don't let -lcgmanager end up in LIBS
AC_SEARCH_LIBS always places the library being queried into LIBS.  We
don't want that - we were only checking whether a function is
available.  Not everything (notably not init.lxc.static) needs to
link against -lcgmanager.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-06-03 10:11:05 -04:00
Serge Hallyn
9d9c111c61 execute: don't bind mount init.lxc.static if lxc-init is in the container
Move choose_init into utils.c so we can re-use it.  Make it and on_path
accept an optional rootfs argument to prepend to the paths when checking
whether the file exists.

Also add lxc.init.static to .gitignore

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-06-03 10:11:01 -04:00
Serge Hallyn
041cb4999b execute: try /lxc.init.static as last resort
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-06-03 10:10:56 -04:00
Serge Hallyn
2322903baa execute: bind init.lxc.static into container
Changelog:

May 19: put init.lxc.static into container's root dir
	rather than under SBINDIR [stgraber].

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-06-03 10:10:55 -04:00
Serge Hallyn
2d4b3e3d91 add init.lxc.static binary
To avoid having to copy all the library dependencies into the container.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-06-03 10:10:39 -04:00
bartekplus
c83462d56d Fix incorrect value used in comparison
Signed-off-by: Bartosz Tomczyk <bartekplus@gmail.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
2014-05-28 13:52:12 -04:00
Serge Hallyn
bfd0b144b6 nbd: give paritions some time to show up
If you attach a file to /dev/nbd0, it may take some time for /dev/nbd0p1
to show up.  Allow up to 5 seconds in that case, then bail.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-25 10:43:53 -04:00
Serge Hallyn
35120d9c59 Specially handle block device rootfs
It is not possible to mount a block device from a non-init user namespace.
Therefore if root on the host is starting a container with a uid
mapping, and the rootfs is a block device, then mount the rootfs before
we spawn the container init task.

This addresses https://github.com/lxc/lxc/issues/221

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-25 10:43:50 -04:00
Serge Hallyn
9b8e3c96d8 attach: get personality through get_config command
Newer kernels optionally disallow reading /proc/$$/personality by
non-root users.  We can get the personality through the lxc command
interface, so do so.

Also try to be more consistent about personality being a signed long.
We had it as int, unsigned long, signed long throughout the code.

(This addresses bug
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1322067 :
3.15.0-1.x breaks lxc-attach for unprivileged containers)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-25 10:40:29 -04:00
S.Çağlar Onur
7e36f87e25 destroy the original container after making sure the snapshot exists (fixes #224)
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-05-25 10:39:20 -04:00
S.Çağlar Onur
f49ad55851 move bdev_specs struct into lxccontainer.h to allow API users to use it
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-05-21 15:23:40 -04:00
Serge Hallyn
ef4deb7f20 unpriv tests: also move caller into unbound cgroups
Otherwise the name=systemd cgroup isn't changed to one which
the lxc-unpriv user can write to, causing the test to fail.

This allows lxc-test-unpriv and lxc-test-usernic to pass when run in an
unprivileged container with cgmanager.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-21 15:23:40 -04:00
Serge Hallyn
df9b1831fb coverity: null check after dereference
we actually meant to check *p not p.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-05-21 11:53:11 -05:00
Dwight Engen
5b457f7bd8 lxc-oracle: fix ssh login under libvirt-lxc
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-20 17:09:27 -04:00
Serge Hallyn
fd527175ad cgmanager: slow down there (don't always grab abs cgroup path)
When I converted attach and enter to using move_pid_abs, these needed
to use the new get_pid_cgroup_abs method to get an absolute path.  But
for some inexplicable reason I also converted the functions which get
and set cgroup properties to use the absolute paths.  These are simply
not compatible with the cgmanager set_value and get_value methods.
This breaks for instance lxc-test-cgpath.

So undo that.  With this patch lxc-test-cgpath, lxc-test-autotest,
and lxc-test-concurrent once again pass in a nested container.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-20 17:09:13 -04:00
Dwight Engen
fd4d297dd6 lxc-oracle: set hostname with systemd
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-20 10:49:18 -04:00
ChangZhuo Chen (陳昌倬)
e702123afe lxc-devsetup: Don't use [[ because sh does not support it
Signed-off-by: ChangZhuo Chen (陳昌倬) <czchen@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-20 14:53:11 +02:00
Dwight Engen
b20ded6371 remove TODO file with old item in it
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-19 23:29:11 +02:00
Stéphane Graber
16bc569bc3
Fix syntax error in japanese manpage
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-19 23:03:43 +02:00
KATOH Yasufumi
a4dbc45fc7 doc: Update Japanese lxc.container.conf(5) for lxc.rootfs conventions
Update for commit f1c26f2

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-19 18:09:06 +02:00
KATOH Yasufumi
e053b31ef0 doc: Update Japanese lxc.container.conf(5) for guidance of lxc.mount.entry
Update for commit 6191f4f

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-19 18:09:02 +02:00
Serge Hallyn
6191f4f421 lxc.container.conf(5): update guidance for lxc.mount.entry mount target
For years it has been best practice to use a relative path as
the mount target.  But the manpage hasn't reflect that.  Fix it.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
2014-05-16 14:26:52 -04:00
Serge Hallyn
3abd3e54eb nbd: exit cleanly if nbd fails to attach
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
2014-05-16 09:58:39 -04:00
Serge Hallyn
f1c26f2cbd lxc.container.conf: document the type: lxc.rootfs conventions
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
2014-05-16 09:58:22 -04:00
Serge Hallyn
76a26f559f add support for nbd
backing stores supported by qemu-nbd can be attached to a nbd block
device using qemu-nbd.  This user-space process (pair) stays around for
the duration of the device attachment.  Obviously we want it to go away
when the container shuts down, but not before the filesystems have been
cleanly unmounted.

The device attachment is done from the task which will become the
container monitor before the container setup+init task is spawned.
That task starts in a new pid namespace to ensure that the qemu-nbd
process will be killed if need be.  It sets its parent death signal
to sighup, and, on receiving sighup, attempts to do a clean
qemu-device detach, then exits.  This should ensure that the
device is detached if the qemu monitor crashes or exits.

It may be worth adding a delay before the qemu-nbd is detached, but
my brief tests haven't seen any data corruption.

Only the parts required for running a nbd-backed container are
implemented here.  Create, destroy, and clone are not.  The first
use of this that I imagine is for people to use downloaded nbd-backed
images (like ubuntu cloud images, or anything previously used with
qemu).  I imagine people will want to create/clone/destroy out of
band using qemu-img, but if I'm wrong about that we can implement
the rest later.

Because attach_block_device() is done before the bdev is initialized,
and bdev_init needs to know the nbd index so that it can mount the
filesystem, we now need to pass the lxc_conf.

file_exists() is moved to utils.c so we can use it from bdev.c

The nbd attach/detach should lay the groundwork for trivial implementation
of qed and raw images.

changelog (may 12): fix idx check at detach
changelog (may 15): generalize qcow2 to nbd

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
2014-05-16 09:58:03 -04:00
Dwight Engen
7e4ca1a21d lxc-oracle: export upstart environment variable for maygetty
This is a fix to commit 5f2ea8cfcb.
Sorry, not sure how I missed this in testing the original patch.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-05-16 09:56:03 -04:00
Edvinas Klovas
44464003ee archlinux template: fix lxc.root for btrfs backend
when using btrfs backend lxc-create first creates rootfs in /usr/lib/lxc/rootfs
directory before moving it to /var/lib/lxc or other directory supplied by the
command line. Archlinux template relied in $rootfs_path which made containers
created with btrfs backend have lxc.rootfs set to /usr/lib/lxc/rootfs. By using
$path instead of $rootfs_path we make sure that lxc.rootfs is always correct.

Signed-off-by: Edvinas Klovas <edvinas@pnd.io>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-05-13 15:28:22 -04:00
Dwight Engen
5f2ea8cfcb lxc-oracle: add pts/[1-4] to securetty for libvirt-lxc
Don't spawn a getty on /dev/console when running under libvirt-lxc

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-05-12 22:59:47 -04:00
S.Çağlar Onur
f1a4a029f6 use same ifndef/define format for all headers
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-09 05:12:22 -05:00
Serge Hallyn
29b0b04b32 cgmanager: detect whether cgmanager supports name= subsystems
On older cgmanager the support was broken.  So rather than
fail container starts altogether, just keep the old lxc behavior
in this case by not using name= subsystems.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-08 12:57:03 -05:00
KATOH Yasufumi
58291e3a43 doc: Fix Japanese lxc.container.conf(5)
commit aafea1f was incomplete.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-08 10:53:08 -05:00
Dwight Engen
0b648faeca python3: remove assert since hwaddr isn't set by the download template
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-07 08:54:41 -05:00
Dwight Engen
3cd4af2e86 install lxc-patch.py 644 to fix rpmlint warning
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-07 08:48:20 -05:00
Edvinas Klovas
31efc34cff archlinux template: added sigpwr handling to systemd (lxc-stop)
archlinux is using systemd and systemd's configuration does not have any
services setup to handle sigpwr hook which is sent by lxc-stop command. By
enabling sigpwr service we make sure that lxc-stop will work.

Signed-off-by: Edvinas Klovas <edvinas@pnd.io>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-07 08:38:36 -05:00
Serge Hallyn
25c7531cf0 cgmanager: use absolute cgroup path to switch cgroups at attach
If an unprivileged user does 'lxc-start -n u1' in one
login session, followed by 'lxc-attach -n u1' in another
session, the attach will fail if the sessions are in different
cgroups.  The same is true of lxc-cgroup commands.

Address this by using the GetPidCgroupAbs and MovePidAbs
which work with the containers' cgroup path relative to
the cgproxy.

Since GetPidCgroupAbs is new to api version 3 in cgmanager,
use the old method if we are on an older cgmanager.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Tested-by: "S.Çağlar Onur" <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-06 22:54:39 -05:00
Serge Hallyn
cbf0bae67c cgmanager: also handle named subsystems (like name=systemd)
Read /proc/self/cgroup instead of /proc/cgroups, so as to catch
named subsystems.  Otherwise the contaienrs will not be fully
moved into the container cgroups.

Also free line which was being leaked.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-06 22:54:39 -05:00
Serge Hallyn
44a706bdaf btrfs: support unprivileged destroy
Do this by calling the bdev->destroy() hook from a user namespace
configured as the container's.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-06 22:54:39 -05:00
Serge Hallyn
2659c7cbd5 btrfs: support unprivileged create and clone
btrfs subvolume ioctls are usable by unprivileged users, so allow
unprivileged containers to reside on btrfs.

This patch does not yet enable destroy.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-05-06 22:54:39 -05:00