Commit Graph

2580 Commits

Author SHA1 Message Date
Serge Hallyn
603c64c289 cgroup: recursively delete cgroups when asked
Currently when a container is shut down, lxc walks the set of all
cgroup paths it created, in reverse order, and tries to remove them.
This doesn't suffice if the container has also created new cgroups.

It'd be impolite to recursively remove all the cgroup paths we created,
since this can include '/lxc' and thereunder all other containers
started since.

This patch changes container shutdown to only delete the container's own
path, but do so recursively.  Note that if we fail during startup,
the container won't have created any cgroup paths so it the old
way works fine.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-12 19:25:08 -05:00
Stéphane Graber
71d3a6590f download: Initial template
This adds a new template called "download". It's a fairly simple
template with a minimal set of dependency which will grab any pre-built
image available on https://images.linuxcontainers.org
Note that the serverside is still work in progress (missing SSL support).

Access is done over https by default with a warning being emitted if
fallback to http was required (may be needed for testing, when behind
proxy and with private servers). All index files and tarballs are
gpg-signed with the default pubkeyid contained in the template itself.

The main benefit of this template is to be entirely
distribution-agnostic, any template that can be integrated with the
server build infrastructure will then work on any LXC machine when using
the download template. This template is also compatible with user
namespaces and will hopefully help widden the number of distros that may
work in unprivileged LXC.

This commit also bundles a small change to the template configs to have
the ubuntu template (used by the download template) to work with
unprivileged LXC.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-12 19:21:49 -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
Stéphane Graber
2e59ba029e One more rename of the system options
This should be the last change of name for those options. This change
basically move them all to lxc.bdev.<backend>.<option>.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-10 23:25:19 -05:00
Serge Hallyn
cd43d2d1b9 Fix bug in preserve_ns
If /proc/self/ns does not exist, then preserve_ns was failing to
initialize the saved_ns[i] to -1.  This caused attach_ns() to try
and attach, and of course fail.

Initialize the saved ns values before returning an error.

The return values of preserve_ns and attach_ns were also being
ignored.  Honor them.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-10 23:24:59 -05:00
Stéphane Graber
dad87e3bd1 Drop usage of LXC_DEFAULT_CONFIG in our code
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-10 11:16:09 -05:00
Stéphane Graber
593e84786e Re-organize API for global lxc.conf config
Instead of having one function for each possible key in lxc.conf which
doesn't really scale and requires an API update for every new key,
switch to a generic lxc_get_global_config_item() function which takes a
key name as argument.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-10 11:16:06 -05:00
Stéphane Graber
9e8be78115 Add lxc.default_config to LXC's own config
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-10 11:16:03 -05:00
Stéphane Graber
2b425d512a Rename all lxc.conf options to lxc.<key>
This is a first step in bringing the lxc.conf configfile in line with
the container's format.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-10 11:15:53 -05:00
KATOH Yasufumi
d7768b9096 doc: Remove unneeded "SEE ALSO" part in lxc-ls(1)
The old version of lxc-ls is the wrapper of ls(1). But now it is
python script, so "see also ls(1)" is not needed.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-09 10:35:07 -05:00
Stephen Ayotte
d659597e03 Support large bdevs on 32-bit; MB units by default.
Change all instances of "unsigned long" where referring to a bdev size
to uint64_t; this fixes some overflows on 32-bit machines, where
"unsigned long" is uint32_t. Support all unit-sizes supported by LVM
except 's' and 'e' [bkmgt]. Print a warning and use default bdev-size if
invalid unit-size specified.

Signed-off-by: Stephen Ayotte <stephen.ayotte@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-08 12:31:50 -05:00
Qiang Huang
6f63931122 lxc-ls.sgml.in: fix the format issue
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-08 09:49:16 -05:00
Stéphane Graber
2e3b013411
travis: Use NOTICE instead of PRIVMSG on IRC
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-07 12:14:15 -05:00
Stéphane Graber
ddb9359321
Move pkg-config init to way earlier
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-07 11:24:36 -05:00
Jiri Slaby
cc33e055dd lxc-opensuse: add perl-base to prerequisities
It is needed by insserv-compat.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-07 11:24:05 -05:00
Jiri Slaby
12dcc8928f configure: find seccomp using pkg-config
On suse we have the header in a subdir inside /usr/include, so
pkgconfig has to be used to find out proper CFLAGS.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-07 11:23:57 -05:00
Stéphane Graber
baeebd0d79
man: Fix comment syntax
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-07 10:26:16 -05:00
Serge Hallyn
d745b820c2 lxclock: fix stupid scope error
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-07 09:20:25 -06:00
Serge Hallyn
8c9c2c6d74 lxclock: fall back to /tmp if xdg_rundir is not writeable
This happens for instance if you run a test under sudo which
then runs lxc commands under 'su - <someuser>'

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-07 09:22:52 -05:00
KATOH Yasufumi
38d626f8be doc: Update Japanese lxc-stop(1), lxc.conf(5), lxc-start-ephemeral(1)
* nokill option of lxc-stop (commit 84fbfcb434)
* lxc.haltsignal in lxc.conf (commit f0f1d8c076)
* fix sgml (commit d438f5a0ef)

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-07 09:22:06 -05:00
S.Çağlar Onur
29b10e4f47 Setting lxc.console = none causes startup failures for the containers that runs in user namespace
Setting "lxc.console = none" causes following failure during startup

      lxc-start 1389039861.061 INFO     lxc_start_ui - using rcfile lxcpath/original/config
      lxc-start 1389039861.062 INFO     lxc_confile - read uid map: type u nsid 0 hostid 260000 range 10000
      lxc-start 1389039861.062 INFO     lxc_confile - read uid map: type g nsid 0 hostid 260000 range 10000
      lxc-start 1389039861.062 WARN     lxc_log - lxc_log_init called with log already initialized
      lxc-start 1389039861.065 INFO     lxc_lsm - LSM security driver AppArmor
      lxc-start 1389039861.066 DEBUG    lxc_conf - allocated pty '/dev/pts/0' (5/6)
      lxc-start 1389039861.066 DEBUG    lxc_conf - allocated pty '/dev/pts/7' (7/8)
      lxc-start 1389039861.066 DEBUG    lxc_conf - allocated pty '/dev/pts/8' (9/10)
      lxc-start 1389039861.066 DEBUG    lxc_conf - allocated pty '/dev/pts/9' (11/12)
      lxc-start 1389039861.066 INFO     lxc_conf - tty's configured
      lxc-start 1389039861.066 DEBUG    lxc_start - sigchild handler set
      lxc-start 1389039861.066 ERROR    lxc_conf - Error chowning
      lxc-start 1389039861.066 ERROR    lxc_conf - Failed to chown
      lxc-start 1389039861.066 ERROR    lxc_start - Failed to shift tty into container
      lxc-start 1389039861.066 ERROR    lxc_start - failed to initialize the container
      lxc-start 1389039861.067 INFO     lxc_monitor - using monitor sock name lxc/0863ffed81827105/lxcpath

fix it by checking the console.name before using it.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-06 18:11:14 -06:00
S.Çağlar Onur
65b8ba1a4e disable generating documentation for travis
doxygen and graphviz causes travis vm to download ~400 MB from internet
and causes travis builds to timeouts occasionally.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-06 15:26:17 -05:00
Dwight Engen
89f79f6baf allow multiple types of init scripts to be configured
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-06 14:24:53 -05:00
Qiang Huang
6424619e40 configure.ac: add docbook-to-man to dbparsers
Debian and Ubuntu uses docbook2x-man, but some other distr like suse
uses docbook-to-man. I think all of them should work on LXC.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-06 13:02:19 -06:00
Dwight Engen
f0f1d8c076 add lxc.haltsignal for soft shutdown
- use this in the busybox template since busybox's init expects
  to receive SIGUSR1 to halt

- fix lxc.stopsignal to be output by write_config so lxcapi_clone()
  and lxcapi_save_config() will output it

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-06 12:49:44 -05:00
Nick Huber
19a85f1f8f Use the cgroup name for cpuset for lxc-ps
On my Ubuntu 13.10 system, lxc-ps was always giving empty output. The
output of /proc/$initpid/cgroup was

11:name=systemd:/user/1000.user/c3.session
10:hugetlb:/container
9:perf_event:/container
8:blkio:/container
7:freezer:/container
6:devices:/container
5:memory:/container
4:cpuacct:/container
3:cpu:/container
2:cpuset:/container

Using the cpuset line should be a safer option.

Signed-off-by: Nick Huber <nicholashuber@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-06 10:34:51 -05:00
Qiang Huang
d438f5a0ef lxc-start-ephemeral: fix the man page
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-06 10:21:11 -05:00
Dwight Engen
84fbfcb434 rename lxc-stop shutdown argument to nokill
This makes the arguments between lxc-stop and lxc-autostart more
consistent, so that --shutdown doesn't have two different meanings.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-06 10:06:05 -05:00
KATOH Yasufumi
a600d021ad doc: Update man pages to the latest information
* lxc-attach(1): Update to the status of kernel 3.8 or higher
* lxc-create(1), lxc-destroy(1): Now lxc-ls don't have "-l" option, so remove
* lxc(7): update description of lxc-ls and lxc-info to current version
* see-also: fix lxc(1) to lxc(7)

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-06 09:51:53 -05:00
KATOH Yasufumi
5fd9f759c1 doc: Update Japanese lxc-autostart(1)
Update for commit a771fe18d2

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-06 09:51:08 -05:00
S.Çağlar Onur
babbea4b30 check pthread_atfork and thread-local storage
Add pthread_atfork check to configure.ac and uses it when necessary,
Introduces tls.m4 macro for checking thread-local storage support, Puts
values array into thread-local storage
(lxc_global_config_value@src/lxc/utils.c), Removes
static_lock/static_unlock from LXC code.

Lastly, it introduces a warning for bionic users about multithreaded
usage of LXC.

(requires 64b1be2903 to be reverted first)

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-06 09:46:32 -05:00
Stéphane Graber
67c4fe9b2d Revert "Revert "Use pthread_atfork() to unlock mutexes after fork()""
This reverts commit 64b1be2903.

Reverting in preparation for another implementation which is
bionic-compatible.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-06 09:45:18 -05:00
Dwight Engen
420dfb599b add lxc-autostart support for sysv init systems
This change updates the way init scripts get installed so that more
than one init system can be supported. Instead of installing the
systemd service file from the spec file, it should be installed at
make install time, so that someone compiling from source also gets
the unit file installed.

Update the plamo template to use a lock file not named just
/var/lock/subsys/lxc since the presence of that file is used by
sysv init rc file to know if it should run the K01lxc script. This
also makes it consistent with the other templates which use
/var/lock/subsys/lxc-$template-name.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-03 13:49:04 -06:00
Serge Hallyn
0a83cbbb75 snapshot: enforce keeping same backing store type (v2)
Stéphane noticed that lxc-snapshot of a dir-backed container
created an overlayfs container.  The expectation is that the
user can continue to modify the original container and later make
a new snapshot, but this doesn't work with the existing behavior -
the overlayfs clone will end up with the modified contents.

So add a 'LXC_CLONE_KEEPBDEVTYPE' flag, which c->snapshot()
passes to c->clone().

Also add a LXC_CLONE_MAYBE_SNAPSHOT.  If this is set and a
backing store does not support snapshotting, then proceed with
a copy clone.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-02 12:12:42 -06:00
Dwight Engen
a771fe18d2 change lxc-autostart shutdown to behave like lxc-stop
It is desirable to have a mode where a soft shutdown is requested,
but then do a hard shutdown if after some time period the container
has not shut down. This the default behaviour of lxc-stop, but is
not currently possible with lxc-autostart. This change makes this
the default behaviour when shutdown is specified to lxc-autostart.
This will be very useful for init scripts.

An indefinte wait for soft shutdown (though I'm not sure how that
would be useful) is still possible by passing a timeout of 0.

Change default timeout value to 60 seconds to match lxc-stop

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-02 11:01:19 -06:00
Michael H. Warfield
99c2fb07d7 Additional logic for dealing with container shutdown / reboot
Additional logic for dealing with container shutdown / reboot

Fix a problem with CentOS containers and legacy Fedora (<16) containers
not shutting down or rebooting properly.  Copy /etc/init.d/halt to
/etc/init.d/lxc-halt, deleting everything from the "hwclock save" and
all after and append a force halt or reboot at the end of the new
script, to prevent reexecing init.  Link that script in as
S00lxc-halt in rc0.d and S00lxc-reboot in rc6.d to intercept the
shutdown process before it gets to S01halt / S01reboot causing the hang.

Fixed some typos in the CentOS template that were introduced in the
previous patch for hwaddr settings and missed in regression testing.

Cleaned up some instruction typos and tabs from previous patch.

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-02 10:11:34 -06:00
Andrey Mazo
0b98289ef9 Bring static and const to tests too
Signed-off-by: Andrey Mazo <mazo@telum.ru>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-02 09:56:36 -06:00
Andrey Mazo
74a3920a97 Mark functions as static and arguments/arrays as const where possible
Mark most of functions that are used within only one file as static.
After 95ee490bbd it's easy to prove they
are not in public API.
Several arrays and structs are also marked static.
This prevents them from being exported from liblxc.so

List of removed previously exported symbols:
bdevs
btrfs_ops
check_autodev
create_partial
dir_ops
dump_stacktrace
get_mapped_rootid
get_next_index
lock_mutex
loop_ops
lvm_ops
lxc_abort
lxcapi_clone
lxc_attach_drop_privs
lxc_attach_get_init_uidgi
lxc_attach_getpwshell
lxc_attach_remount_sys_pr
lxc_attach_set_environmen
lxc_attach_to_ns
lxc_clear_saved_nics
lxc_config_readline
lxc_devs
lxc_free_idmap
lxc_global_config_value
lxc_poll
lxc_proc_get_context_info
lxc_set_state
lxc_spawn
mk_devtmpfs
mount_check_fs
ongoing_create
overlayfs_destroy
overlayfs_ops
prepend_lxc_header
remove_partial
save_phys_nics
setup_pivot_root
signames
static_mutex
thread_mutex
unlock_mutex
unpriv_assign_nic
zfs_ops

Signed-off-by: Andrey Mazo <mazo@telum.ru>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-02 09:54:03 -06:00
Serge Hallyn
64b1be2903 Revert "Use pthread_atfork() to unlock mutexes after fork()"
This reverts commit 84e9e19793, because
it breaks bionic builds.  The patch is desirable so hopefully we can
come up with a solution or alternate patch soon.
2014-01-02 09:40:16 -06:00
KATOH Yasufumi
9a97d4e4bd doc: Improve Japanese man pages
* Improve Japanese translation
* Fix mis-translation
* Insert linefeed between paragraph, because some paragraph is too
  long, so sometimes git send-email could not use.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-01 14:08:31 -06:00
Andrey Mazo
84e9e19793 Use pthread_atfork() to unlock mutexes after fork()
Signed-off-by: Andrey Mazo <mazo@telum.ru>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-01 14:04:52 -06:00
S.Çağlar Onur
f2363e38d0 adjust include statements (v2)
Use "#include <somefile.h>" style for external or exported headers only.

changes since v1:
 - adjusted formatting as Stéphane suggested

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-01 14:04:51 -06:00
Stéphane Graber
23b9d42893
travis: Configure notifications
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-25 17:36:19 +01:00
Stéphane Graber
53998c00df
travis: Enable tests and add missing dependencies
- Add doxygen and graphviz for the API doc build.
 - Pass --enable-tests to have the tests built (off by default)

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-25 17:24:10 +01:00
Michael H. Warfield
53bd92eafa Fix version checking typos in Fedora template.
Backported typo fixes from CentOS template back to Fedora Template
Bumped default rev from Fedora 18 to Fedora 19

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-25 17:21:09 +01:00
Michael H. Warfield
c6df5ca460 Fix version checking and deal with pam_loginuid in CentOS template.
This deals with a reported issue when running and building containers
on a CentOS host system.

Fixed various typos in version checking when running on a CentOS system.
Added logic for differences between point releases (6.5) and rolling (6).
Added version detection logic when running on RHEL systems as well.
Fixed cpe detection string (CentOS is not adhering to their own registration).
Added logic to disable the pam_loginuid.so binary in containers.

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-25 17:21:03 +01:00
Andrey Mazo
aa5233a676 Remove unused functions
After 95ee490bbd they are not in public
API and are not used throughout the lxc codebase.
This has a bonus of removing workaround for bionic.

Signed-off-by: Andrey Mazo <mazo@telum.ru>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-25 17:15:58 +01:00
Andrey Mazo
579e783eec Allow use of public API from C++
Signed-off-by: Andrey Mazo <mazo@telum.ru>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-25 17:15:55 +01:00
KATOH Yasufumi
db821c3a41 plamo: Improve template for lxc-stop
patch /etc/inittab in plamo container to shutdown when it receives SIGPWR.
(By default, plamo shutdowns to single user mode after 5minutes)

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-25 17:06:55 +01:00
S.Çağlar Onur
1c1c60e4ba add travis-ci support to LXC github repo (v2)
Travis is a free hosted CI platform for the open source community. It integrates
well with github and enables continous builds/tests for both repository itself
and all the pull requests so that one can quickly see the result of the possible
merge.

This yml file is one of the few required steps to enable travis-ci support for
LXC github repo. One of you guys still need to sign in travis-ci through GitHub OAuth
and enable travis support from its profile page https://travis-ci.org/profile

As an example https://travis-ci.org/caglar10ur/lxc-upstream/builds/15872074 can be seen

changes since v1;
 - All external dependencies are now innstalled via before_install section
 - Dropped all configure flags as Stéphane suggested

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-25 17:06:48 +01:00