Commit Graph

1578 Commits

Author SHA1 Message Date
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
Stéphane Graber
836676caba Minor documentation updates
- Update COPYING to the current copy of the LPGL-2.1 license from
   common-licences (only difference is some indentation).
 - Remove mixed tabs/spaces in CONTRIBUTING
 - Make INSTALL fit on 79 cols.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-06 00:02:36 -05:00
Stéphane Graber
e1483a0275 Update README
This adds a section about the staging branch to the README and updates
the list of supported architectures.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-06 00:02:33 -05:00
Stéphane Graber
483d21ff46 oracle template: fixes when using fedora host
Let oracle template work when host is fedora or oracle and the lsb_release
command is not present. Verify the arch given is valid. Don't add lxc.network
section again if already present.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-05 17:07:01 -05:00
Dwight Engen
f1a3a3ab8f make install should create /var/cache/lxc directory
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-05 15:23:27 -05:00
Stéphane Graber
f8ddeaa5be lxc-archlinux.in: Apply same LXCPATH/LOCALSTATEDIR
lxc-archlinux was apparently left out of the last change, apply
the same modification as the other templates.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-05 13:33:03 -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
f99c7aa5de lxc-create: refuse to use a custom rootfs (--dir) which already exists.
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-05 11:48:10 -05:00
Stéphane Graber
0749e74060 lxc-ls: Update code to allow non-root listing
Re-arrange the code so that we only grab the container object when doing
something more than building a simple list of existing containers.

This means that now the following calls can run unprivileged:
 - lxc-ls
 - lxc-ls -1

Everything else will still require root privileges.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-05 09:27:57 -05:00
Stéphane Graber
20cf2e976b python: Update to the device related functions
This commit does the following changes to the python API:
 - Rename the add_device API call to add_device_node
 - Adds an extra check that the container is running to add_device_node
 - Introduces a new add_device_net function

And the following changes to the lxc-device tool:
 - Change parser setup to better cope with variable number of arguments
 - Add support for network devices (currently auto-detected)
 - Support for different names on the host and in the container

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-04 18:16:22 -05:00
Stéphane Graber
b1eafd4aeb lxc-device: Show an error message when non-root
Instead of returning a python stacktrace, check what the current euid is
and show an argparse error message similar to that used in lxc-start-ephemeral.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-04 17:32:08 -05:00
Stéphane Graber
daf04e4ce9 lxc-ls: Show a simple error message when non-root
Instead of returning a python stacktrace, check what the current euid is
and show an argparse error message similar to that used in lxc-start-ephemeral.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-04 17:32:04 -05:00
Stéphane Graber
c0b5f522fe lxc-start-ephemeral: Use argparse errors
Use argparse's error function instead of our own print + exit.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-04 17:31:59 -05:00
Serge Hallyn
7b35f3d60a rename physical nics at shutdown
When a physical nic is being set up, store its ifindex and original name
in struct lxc_conf.  At reboot, reset the original name.
We can't just go over the original network list in lxc_conf at shutdown
because that may be tweaked in the meantime through the C api.  The
saved_nics list is only setup during lxc_spawn(), and restored and
freed after lxc_start.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1086244

Changelog: remove non-effect change in execute.c

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-04 14:16:30 -06:00
Dwight Engen
4245ba5007 make install should create $LXCPATH directory
The $LXCPATH (default /var/lib/lxc) directory was not being created by
make install, so unless it gets created by some other means
(packaging tools), commands such as lxc-create will fail.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-04 15:11:23 -05:00
Stéphane Graber
6a85cf9124 Install legacy scripts when built without python.
Re-introduce the old lxc-ls script and manpage under a new legacy
sub-directory.

Those will be installed in place of their python equivalent when LXC
is built without --enable-python.

Any other script ported to python should be added to those lists.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-04 14:01:30 -05:00
Stéphane Graber
4e7186c535 Rewrite lxc-ls in python
This rewrite is mostly compatible with the shell version.
--active and -1 still work and behave as they used to.

This adds --running, --stopped and --frozen as state filters.

A new "fancy" view is also implemented (can be used with --fancy) and
will show containers in a column-based interface with the following fields:
 - name
 - state
 - ipv4
 - ipv6
 - pid of init

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-04 14:00:56 -05:00
Serge Hallyn
4a85ce2ad0 lxc_conf logfile and loglevel support
Add 'lxc.logfile' and 'lxc.loglevel' config items.  Values provided on
the command line override the config items.

Have lxccontainer not set a default loglevel and logfile.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-04 11:38:25 -06:00
Serge Hallyn
44d397891e templates: use hardlink detection in rsync
I'm not sure whether we want this:  is -H ubiquitous?

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
2012-12-04 10:10:24 -06:00
Serge Hallyn
2130af2665 lxc-clone: use hardlink detection in rsync
Otherwise busybox clones have been reported to explode from
2M to 440M.

Reported-by: Rene K. Mueller <spiritdude@gmail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
2012-12-04 10:10:00 -06:00
Dwight Engen
6902a6c664 Create busybox commands as symlinks instead of hardlinks
I was getting a "Too many links" error when creating a busybox container on
a btrfs file system. This change has the template create the links as
symlinks instead. It also generates the list of commands to be symlinked from
busybox itself instead of a hardcoded list in the template.

Also set the root password to root, to match what other templates do.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-12-03 10:00:30 -05:00
Stéphane Graber
1d4f064658 lxc-create: Script cleanup
- Removes the mixed tabs/spaces, replacing by standard 4 spaces indent.
 - Fix a bunch of bashisms.
 - Use shell syntax for and/or in if statements instead of the "test" syntax.
 - Improve block spacing a bit.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-03 09:59:17 -05:00
Stéphane Graber
fa0e6e1bf4 lxc-create: Store template information in config
Change lxc-create to add the name of the template, checksum and any parameters
to the container's configuration.
This makes it easier to debug and figure out exactly how a container was built.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-12-03 09:57:38 -05:00
Serge Hallyn
61435768cd check and warn of return value from fchdir
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-11-29 20:05:37 -06:00
Dwight Engen
cc423c6739 Include lxc-ubuntu when doing make dist
Removing templates/lxc-ubuntu from configure.ac makes it so that it is
not included in the tarball that make dist builds (and therefore also
breaks the rpm build).

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-11-29 13:32:34 -05:00
Serge Hallyn
91c3830e22 Description: run MAKEDEV console when doing lxc.autodev
mounted-dev.conf won't be running that in container's userspace as it
previously would have, so make sure that all the devices it would have
created (other than ones which lxc later finagles) get created.
To achieve this, we have to first mount /dev, then run MAKEDEV, then
run setup_autodev to populate the rest of /dev.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1075717

Changelog:
  v2: Use INFO rather than ERROR when makedev fails, since we won't stop the container boot.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-11-29 11:14:07 -06:00
Dwight Engen
5f29734f7d Fix build with --enable-tests on Fedora
When using --enable-tests on Fedora, the linker complains with:
"undefined reference to symbol sem_getvalue", which nm shows to be in
libpthread not librt. Build tested on Fedora, Oracle Linux, and Ubuntu.

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-11-29 10:28:06 -05:00
Stéphane Graber
89573feb5b lxc-ubuntu: Fix wrong variable name
$LANGPACK_LIST was renamed to $langpacks but not all the code was updated.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-11-29 10:26:54 -05:00
Stéphane Graber
1e1f8eeb14 lxc-ubuntu: Fix mixed indent
Replace all remaining tabs by 8 spaces, to properly indent by 4 spaces.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-11-29 10:26:29 -05:00
Stéphane Graber
8e100cef8b lxc-ubuntu: Rename from lxc-ubuntu.in
lxc-ubuntu no longer uses any build time variables, therefore it can
now be simply copied to the target without any autoconf magic.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-11-29 10:26:26 -05:00
Stéphane Graber
fade719ed9 lxc-ubuntu: Guess a list of langpacks to install
In addition to creating the current locale in the container, also
try to scan the host and extra the list of langpacks installed there,
then pass that list to debootstrap as additional packages to install.

On distros that don't have dpkg, only language-pack-en will be installed.
The code will always ensure that language-pack-en is ALWAYS installed in the
target, similar to what Ubuntu does with its various media.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-11-29 10:26:23 -05:00
Stéphane Graber
18f823c1ca lxc-ubuntu: Always create the needed locales
Move some old code from the trim() function into the main configure_ubuntu
function so that we always create a locale in the container.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2012-11-29 10:26:20 -05:00
Dwight Engen
e62fa3f9ce Fix busybox template to not have extra aa_profile hunk
Both 69d66f1e and f02ce27d added the aa_profile = unconfined hunk, but only
the first was needed, maybe a merge error? The second one causes the
template to get an error on the EOF line. This essentially reverts
f02ce27d.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-11-29 10:18:41 -05:00
Serge Hallyn
bf555f0384 revert inadvertent un-doing of lxc-clone fix
commit 8f2c3a702a reverted a fix
for bad handling by lxc-clone of 'lxc.mount[ \t]' lines.
Fix.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-11-28 09:57:59 -06:00