Commit Graph

2861 Commits

Author SHA1 Message Date
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
KATOH Yasufumi
2da1f56ce3 lxc-autostart: don't set timeout if user requested -s
same as the commit 25070b6601

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-24 10:05:35 -06:00
Serge Hallyn
37c41004f7 coverity: make sure not to close file handle twice
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-24 10:03:43 -06:00
Andrey Mazo
aaf901be6b Use getmntent_r() for thread-safety
Signed-off-by: Andrey Mazo <mazo@telum.ru>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-24 09:10:46 -06:00
Andrey Mazo
dd1d77f91b Remove process_lock() except where actually needed
Functions like open(), close(), socket(), socketpair(), pipe() and mkdir()
are generally thin wrappers around kernel-provided system calls.
It's the kernel not libc, who ensures race-free handling of file
descriptors.
Thus locking around these functions is unnecessary even on somewhat buggy libcs.

fopen(), fclose() and other stdio functions may maintain internal lists
of open file handles and thus can be prone to race-conditions.
Hopefully, most libcs utilize proper locking or other ways to ensure
thread-safety of these functions.
Bionic used to have non-thread-safe stdio [2] but that must be fixed
since android 4.3 [3, 4].

S.Çağlar Onur showed [1] that openpty() (because of nsswitch) is not thread-safe though.
So we workaround it by protecting openpty() calls with process_lock()/process_unlock().

Because of the need to guard openpty() with process_lock()/process_unlock(),
process_unlock() is still used after fork().

This commit reverts most of 025ed0f391.

[1] https://github.com/lxc/lxc/pull/106#issuecomment-31077269
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=687367
[3] f582340a6a
[4] 6b3f49a537

Signed-off-by: Andrey Mazo <mazo@telum.ru>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-24 09:10:41 -06:00
KATOH Yasufumi
e339d6b9c1 doc: Fix the description of -n option in lxc-info(1)
Commit 5444216 revised -n option from allowing to specify multiple
containers using regex to specifying only one container. But
lxc-info(1) remains original. so
- mark -n required
- remove the description of -n that is included in common options

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-24 12:43:56 +01:00
KATOH Yasufumi
fe8e3acfa2 doc: Update Japanese lxc-stop(1) for -s option
Update for commit 25070b6601

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-24 12:42:06 +01:00
Stéphane Graber
2bc93759f6 configure: Disable python3 builds with clang
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-23 16:06:56 -06:00
Stéphane Graber
d8d446599e configure: Add GnuTLS to configure overview
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-23 16:06:54 -06:00
Andrey Mazo
6ed46d9ea7 Fix invalid free() in lxc_global_config_value().
Commit 4878dac496 introduced possible
incorrect usage of free().
Also remove unneeded strdup().

Signed-off-by: Andrey Mazo <mazo@telum.ru>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-23 12:32:27 -06:00
Serge Hallyn
e99faceca0 Revert "coverity-detected bug: don't free "/""
This reverts commit 5cad2f04be.
2013-12-23 12:32:23 -06:00
Serge Hallyn
916643522f Revert "remove static_lock()/static_unlock() and start to use thread local storage (v2)"
This reverts commit 95b422fccf.

Conflicts:
	src/lxc/utils.c
2013-12-23 12:27:32 -06:00
Serge Hallyn
5cad2f04be coverity-detected bug: don't free "/"
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-23 11:14:58 -06:00
Serge Hallyn
25070b6601 lxc-stop: don't set timeout if user requested -s
A timeout means wait this long before killing the container.
-s means don't kill the container.  timeout defaults to 60
seconds.  So if a shutdown is requested, then set timeout to
0.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-23 10:25:43 -06:00
Stéphane Graber
4878dac496 Set default paths for unprivileged use (v2)
When running unprivileged (euid != 0), LXC will now use the following paths:
 - Default lxc path: ~/.local/share/lxc/
 - Default config path: ~/.config/lxc/lxc.conf

Those two paths are based on standard XDG paths (though ignoring all the
possible override paths for now at least) and so probably don't need to
be configurable at build time.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-23 10:16:07 -06:00
S.Çağlar Onur
619256b5ee remove LXC_CLONE_COPYHOOKS and make lxcapi_clone to copy hooks unconditionally (v3)
changes since v1;
	incorporated Serge's changes
changes since v2;
	added missing Signed-off-by

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-23 10:16:03 -06:00
KATOH Yasufumi
41e8e807c8 plamo: Update template since rc script of plamo was updated
Signed-off-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-22 17:33:05 +01:00
KATOH Yasufumi
1e6409bced doc: Improve Japanese translation of lxc-stop(1)
Signed-off-by: Kouhei Maeda <mkouhei@gmail.com>
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-22 12:00:08 +01:00
Stéphane Graber
f75b4de068
Fix coverity-detected memory leak
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-20 16:09:07 +01:00
KATOH Yasufumi
28f2ab26ea doc: Add Japanese lxc-autostart(1) and update lxc.conf(5)
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-20 13:48:05 +01:00