Commit Graph

1311 Commits

Author SHA1 Message Date
Dwight Engen
e35cb41b8c oracle template: add support for creating ol4 container from ovm template
Also: disable the interactive part of ovmd so ol5,6 containers won't
hang if started for the first time with -d. Don't let containers do rawio,
or have access to /dev/rtc0, they can mess up the hosts system clock among
other things.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-03 18:12:41 -05:00
Dwight Engen
596a818d4b separate console device from console log
lxc-start -c makes the named file/device the container's console, but using
this with a regular file in order to get a log of the console output does
not work very well if you also want to login on the console. This change
implements an additional option (-L) to simply log the console's output to
a file.

Both options can be used separately or together. For example to get a usable
console and log: lxc-start -n name -c /dev/tty8 -L console.log

The console state is cleaned up more when lxc_delete_console is called, and
some of the clean up paths in lxc_create_console were fixed.

The lxc_priv and lxc_unpriv macros were modified to make use of gcc's local
label feature so they can be expanded more than once in the same function.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-01-02 18:08:12 -05:00
Stéphane Graber
4199da3061 kill -s expects the signal name without SIG
The previous lxc-shutdown change replaced 'kill SIG<name>' by
'kill -s SIG<name>'. Although this works with busybox where it was tested,
this doesn't actually work with all kill implementations. Some requiring just
the signal name without the prefix.

This changes "-s SIG<name>" by just "-s <name>". Tested with busybox and
standard kill.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 13:47:18 -05:00
Natanael Copa
670c6ab8ca lxc-alpine: add support for installing optional packages
Let users append a list of packages they want install in the container

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 13:13:15 -05:00
Natanael Copa
2b49de9a3f lxc-alpine: add support for setting arch from command line
This allows us to lxc-create 32 bit guests on x86_64 hosts.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 13:11:31 -05:00
Natanael Copa
e5846a6f89 lxc-alpine: add --repository option
This allows specifying what repository to use for the container.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 13:06:43 -05:00
Natanael Copa
b1aa0624ba lxc-alpine: indent fixes
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 13:05:23 -05:00
Natanael Copa
8410c48507 templates: install lxc-alpine
Make sure we actually install lxc-alpine

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 13:04:48 -05:00
Natanael Copa
b5dec5f30b lxc-ps: use posix shell and awk instead of bash
Use awk to parse the output pf 'ps' and the tasks files for the
containers.

Use awk fields to find PID column rather than assume that the PID field
is exactly 5 chars wide and has a leading space ' PID'. This works as
long as the PID field is before the command or other field that include
spaces. This also makes it work with busybox 'ps'.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 13:00:32 -05:00
Natanael Copa
600faead38 lxc-shutdown: use posix shell instead of bash
- avoid getopt --longoptions
- use 'which' instead of 'type' to detect existance of tools
- specify -s SIG<signame> with kill

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 12:57:27 -05:00
Dwight Engen
4415d5163c fix open check (0 is a valid fd)
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 12:53:56 -05:00
Natanael Copa
7265dc4344 cleanup: use lxc-info --state-is
We now have the possibility to test for a given state. Use this feature
instead of parsing output with grep or awk

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 12:52:37 -05:00
Natanael Copa
32e8690186 legacy/lxc-ls: improve finding fs mountpoint of hierarchy
We cannot assume that the mount source name always starts with 'cgroup'
so we check the filesystem type instead.

Use 'awk' instead of 'grep -E' and  as it is a better tool for this job.

This fixes the tool on systems using openrc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 12:48:13 -05:00
Natanael Copa
f358385a7c lxc-netstat: improve finding fs mountpoint of hierarchy
We cannot assume that the mount source name always starts with 'cgroup'
so we check the filesystem type instead.

Use 'awk' instead of 'grep -E' and  as it is a better tool for this job.

This fixes the tool on systems using openrc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 12:47:31 -05:00
Alexander Vladimirov
f3849d01d8 Update lxc-archlinux template to work with systemd
Use arch-install-scripts for installation.

Signed-off-by: Alexander Vladimirov <alexander.idkfa.vladimirov@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-01-02 12:42:26 -05:00
Natanael Copa
c44fc03789 lxc-netstat: use posix shell instead of bash
- use case .. in instead of comparison with globs
- avoid 'local'

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-25 17:34:38 +01:00
Natanael Copa
4785915a51 lxc-clone: use posix shell instead of bash
- avoid getopt --longoptions
- use 'which' instead of 'type' to detect existance of tools
- use 'grep -q -w' instead of bash substring variable expansion
  ${line:0:18}

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-25 17:34:26 +01:00
Natanael Copa
2f0e69084e legacy/lxc-ls: use posix shell instead of bash
- use case .. in instead of comparison with globs
- avoid 'local'

While here, also avoid 'find ... -printf' which is not supported on busybox

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-25 17:34:03 +01:00
Natanael Copa
11bdaa7475 lxc-destroy: use posix shell instead of bash
- avoid use getopt --longoptions

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-25 17:30:19 +01:00
Natanael Copa
2a9a0a0807 templates: initial support for Alpine Linux
Requires apk-tools (http://git.alpinelinux.org/cgit/apk-tools)

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-25 12:59:36 +01:00
Kyle Russell
5270bf4b08 Fix compile warning on uninitialized return value
Signed-off-by: Kyle Russell <bkylerussell@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-25 12:59:24 +01:00
Natanael Copa
859a6da0fa define MS_SHARED if needed
Fixes build on uClibc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-25 12:58:50 +01:00
Serge Hallyn
964fe051e9 Clear environment for container
Clear env before starting a container.  Do it right before setting
the container=lxc variable.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-22 11:34:28 +01:00
Serge Hallyn
cc28d0b0a6 Support MS_SHARED /
(I'll be out until Jan 2, but in the meantime, here is hopefully a
little newyears gift - this seems to allow lxc-start with / being
MS_SHARED on the host)

When / is MS_SHARED (for instance with f18 and modern arch), lxc-start
fails on pivot_root.  The kernel enforces that, when doing pivot_root,
the parent of current->fs->root (as well as the new root and the putold
location) not be MS_SHARED.

To work around this, check /proc/self/mountinfo for a 'shared:' in
the '/' line.  If it is there, then create a tiny MS_SLAVE tmpfs dir to
serve as parent of /, recursively bind mount / into /root under that dir,
make it rslave, and chroot into it.

Tested with ubuntu raring image after doing 'mount --make-rshared /'.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-20 10:51:01 +01:00
Dwight Engen
963aef6f7f lxc-destroy container only if it is in the STOPPED state
Currently, lxc-destory will attempt to destroy a container if it is not in
the RUNNING state, but doing so is not good when the container is FROZEN, or
in other transitional states.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-19 17:07:50 +01:00
Daniel Lezcano
56655134e4 Version 0.9.0.alpha2 2012-12-14 09:42:55 +01:00
Daniel Lezcano
2a061f55f9 Merge git://github.com/lxc/lxc 2012-12-14 09:42:21 +01:00
Dwight Engen
d2e30e99b4 Fix race/corruption with multiple lxc-start, lxc-execute
If you start more than one lxc-start/lxc-execute with the same name at the
same time, or just do an lxc-start/lxc-execute with the name of a container
that is already running, lxc doesn't figure out that the container with this
name is already running until fairly late in the initialization process: ie
when __lxc_start() -> lxc_poll() -> lxc_command_mainloop_add() attempts to
create the same abstract socket name.

By this point a fair amount of initialization has been done that actually
messes up the running container. For example __lxc_start() -> lxc_spawn() ->
lxc_cgroup_create() -> lxc_one_cgroup_create() -> try_to_move_cgname() moves
the running container's cgroup to a name of deadXXXXXX.

The solution in this patch is to use the atomic existence of the abstract
socket name as the indicator that the container is already running.  To do
so, I just refactored lxc_command_mainloop_add() into an lxc_command_init()
routine that attempts to bind the socket, and ensure this is called earlier
before much initialization has been done.

In testing, I verified that maincmd_fd was still open at the time of lxc_fini,
so the entire lifetime of the container's run should be covered. The only
explicit close of this fd was in the reboot case of lxcapi_start(), which is
now moved to lxc_fini(), which I think is more appropriate.

Even though it is not checked any more, set maincmd_fd to -1 instead of 0 to
indicate its not open since 0 could be a valid fd.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-13 23:26:39 -05:00
Daniel Lezcano
d984bb4e75 Version 0.9.0.alpha1
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-12-13 21:51:03 +01:00
Daniel Lezcano
2e3ae157d5 Merge git://github.com/lxc/lxc
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-12-13 21:48:22 +01:00
Dwight Engen
222fea5a10 Don't attempt to symlink kmsg without rootfs->path
For example doing "lxc-execute -n tmpct /bin/bash" will call setup_kmsg(), but
in this case rootfs->mount/dev directory doesn't even exist so the call to
symlink fails with ENOENT. Commit f62b3449 made this failure not fatal, but
we should not even try it when we know it will fail. See similar code in
setup_tty(), setup_console(), etc.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-11 15:29:39 -05:00
Serge Hallyn
769872f9f2 support new libseccomp api
Detect the new api by existence in seccomp.h of the scmp_filter_ctx
type in configure.ac.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-12-11 12:33:40 -06:00
Serge Hallyn
a02264fb1e README: fix typo in example script
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-12-11 11:39:26 -06:00
Serge Hallyn
ff918b1832 seccomp: free conf->seccomp (filename char *)
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-12-11 11:08:09 -06:00
Dwight Engen
7323456ec3 assume LXCPATH took on default localstatedir based value in configure
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Michael H. Warfield <mhw@WittsEnd.com>
2012-12-10 12:34:53 -05:00
Stéphane Graber
d8521cc375 python: Update add_device_node to use the new API
Update add_device_node to use the new set_cgroup_item call instead
of having to figure out the cgroup paths and update the entries manually.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-10 09:26:21 -05:00
Stéphane Graber
f2924f7898 gitignore: Update for python files
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-10 09:26:17 -05:00
Stéphane Graber
f4d3a9fddb python: Add binding for {get|set}_cgroup_item
Updates the binding for the two new functions.

This also fixes some problems with the argument checking of
get_config_item that'd otherwise lead to a segfault.

The python binding for set_cgroup_item and get_cgroup_item are pretty
raw as lxc has little control over the cgroup entries.
That means that we don't try to interpret lists as we do for the config
entries.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-10 09:26:07 -05:00
Stéphane Graber
703c562d2e python: get_keys() doesn't require a path
The python binding was forcing the user to pass a base path to
get_keys() even though the C binding doesn't require it.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-10 09:26:03 -05:00
Serge Hallyn
f3c7020ad8 dont save loglevel if it is unset
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-12-07 14:18:57 -06:00
Stéphane Graber
d4f6fa926d python3-lxc: Fix build prefix/destdir
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-07 12:38:48 -05:00
Serge Hallyn
794dd12099 api: add set_cgroup_item and get_cgroup_item (to c api)
set_cgroup_item takes a pointer to a running container, a cgroup subsystem
name, and a char *value and it mimicks
	'lxc-cgroup -n containername subsys value'
get_cgroup_item takes a pointer to a running container, a a cgroup
subsystem name, a destination value * and the length of the value being
sent in, and returns the length of what was read from the cgroup file.
If a 0 len is passed in, then the length of the file is returned.  So
you can do

	len = c->get_cgroup_item(c, "devices.list", NULL, 0);
	v = malloc(len+1);
	ret = c->get_cgroup_item(c, "devices.list", v, len);

to read the whole file.

This patch also disables the lxc-init part of the startone test, which
was failing because lxc-init has been moved due to multiarch issues.
The test is salvagable, but saving it was beyond this effort.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-07 12:35:12 -05:00
Stéphane Graber
ab4a150176 lxc-create: Allow for empty or unset template name
This restores an old behaviour where lxc-create can be called without
a template. In such case, only a minimal configuration is built and no
rootfs is created. However the various backingstore code is still used.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-07 12:25:54 -05:00
Dwight Engen
1c6085cdd9 lxc.spec: add openssl and rsync as Required since both are used in lxc-clone
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-06 10:08:20 -05:00
Stéphane Graber
2495cc911b python: Remove hardcoded LXCPATH
Switch the python scripts to using @LXCPATH@.

According to grep, this was the last occurence of a /var/*/lxc
path in the code.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-06 09:43:33 -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
75350ec8c7 lxc-archlinux: Don't hardcode /var/lib/lxc in help
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-06 09:43:26 -05:00
Stéphane Graber
7c38257226 lxc-ubuntu: Don't hardcode path to cache
Use LOCALSTATEDIR to generate the path to the cache.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-06 09:43:23 -05:00
Stéphane Graber
14d9c0f09d Update for consistent indent
This commit updates all scripts using mixed indent to a consistent
4 spaces indent.

In the past quite a few of those scripts used tabs to instead of 8 spaces or
instead of 4 spaces, sometimes mixing those in the same line and sometimes
changing the tab width within the same file.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-06 00:04:27 -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